Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 May 2012 01:51:18 +0000
From:      John <jwd@FreeBSD.org>
To:        freebsd-fs@FreeBSD.org
Subject:   ZFS zfs_freebsd_* routines and ASSERT( ... | SAVENAME) usage
Message-ID:  <20120504015118.GA42954@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120504015118.GA42954>