ZFS zfs_freebsd_* routines and ASSERT( ... | SAVENAME) usage

John jwd at FreeBSD.org
Fri May 4 01:51:18 UTC 2012


Hi Folks,

   I've been trying to trace down namei buffer usage. In the ZFS code
in sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c there
are the zfs_freebsd_*() routines. Many of them contain code similar to
the following:

ASSERT(cnp->cn_flags & SAVENAME);

   However, zfs_freebsd_lookup() does not. Later, in zfs_lookup() there
is this comment:

/* Translate errors and add SAVENAME when needed. */

   and this code:

        if (cnp->cn_flags & ISLASTCN) {
                switch (nameiop) {
                case CREATE:
                case RENAME:
                        if (error == ENOENT) {
                                error = EJUSTRETURN;
                                cnp->cn_flags |= SAVENAME;
                                break;
                        }
                        /* FALLTHROUGH */
                case DELETE:
                        if (error == 0)  
                                cnp->cn_flags |= SAVENAME;
                        break;
                }       
        }


   Can someone with more knowledge of the ZFS code shed some light
on what is happening here?  Why does ZFS need SAVENAME in these
instances.

   Also, maybe I'm missing some logic, would it read more clearly
with "error == ENOENT || error == 0" in an isolated CREATE and RENAME
case (without the fall through)?

   I appreciate any pointers.

Thanks,
John



More information about the freebsd-fs mailing list