ZFS_DEBUG + enable ZFS ASSERTS with INVARIANTS any objections?

Andriy Gapon avg at FreeBSD.org
Fri Jul 26 08:05:23 UTC 2013



Justin, Steven, all,

do you have any news on this topic?
I think that having something in the tree would be better than having nothing at
all (as it is now), unless that something would make future work very hard.

BTW, I've thought just a little bit about this issue and here is how I would
implement INVARIANTS support for code that has come and will come from
OpenSolaris and its descendants.  However, I am not sure how feasible and hard
this approach would be in a technical sense.

So, add something like the following at the end of auto-generated opt_global.h:
#if defined(INVARIANTS) && defined(OPENSOLARIS_FILE)
#ifndef DEBUG
#define DEBUG
#endif
#ifndef ZFS_DEBUG
#define ZFS_DEBUG
#endif
#endif

Then all that remains to be done is to tag each file that uses OpenSolaris DEBUG
semantics with OPENSOLARIS_FILE.  That's easy, right? :-)
Seriously though, there is already ZFS_C / ZFS_CFLAGS defined to be used with
files that compiled into kernel.  We could just add -DOPENSOLARIS_FILE there.
For all the modules, we'd have to amend CFLAGS with -DOPENSOLARIS_FILE.
Tedious, but doable.

Alternatively, we could have a special header file that would contain:
#if defined(INVARIANTS)
#ifndef DEBUG
#define DEBUG
#endif
#ifndef ZFS_DEBUG
#define ZFS_DEBUG
#endif
#endif

And then pass -include the/special/file.h in CFLAGS for all the relevant
files/modules.

What do you think?

-- 
Andriy Gapon


More information about the zfs-devel mailing list