From owner-freebsd-fs@FreeBSD.ORG Fri May 4 01:51:18 2012 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: by hub.freebsd.org (Postfix, from userid 821) id C61FF1065673; Fri, 4 May 2012 01:51:18 +0000 (UTC) Date: Fri, 4 May 2012 01:51:18 +0000 From: John To: freebsd-fs@FreeBSD.org Message-ID: <20120504015118.GA42954@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Cc: Subject: ZFS zfs_freebsd_* routines and ASSERT( ... | SAVENAME) usage X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 01:51:18 -0000 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