Date: Sun, 14 Feb 1999 00:43:34 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: dfr@nlsystems.com (Doug Rabson) Cc: dillon@apollo.backplane.com, hackers@FreeBSD.ORG Subject: Re: VOP_REMOVE() rules for freeing a_cnp ? Message-ID: <199902140043.RAA00134@usr06.primenet.com> In-Reply-To: <Pine.BSF.4.05.9902131337370.351-100000@herring.nlsystems.com> from "Doug Rabson" at Feb 13, 99 01:50:24 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > I can't make heads or tails of the VOP_REMOVE() rules for freeing > > a_cnp. > > > > The man page doesn't say anything about having to free cnp. > > > > ufs_remove() doesn't bother. > > > > nfs_remove() always frees it. > > > > And the unlink() system call seems to expect the cnp to be freed > > by the VOP_REMOVE() function. > > > > Typically the rule for freeing a struct componentname in a VOP > > routine is 'free it if you return an error, otherwise only free > > it if the SAVESTART flag is not set in cn_flags'. > > > > I would appreciate it if a VFS guru could look at this junk and > > tell me whos right. > > I'm sure that someone changed the semantics for who frees the pathnames > and who releases the vnodes during the 3.0 development cycle but I can't > quite remember who (Mike someone maybe, not Mike Smith). I think that the > intention was to always free the path and release the vnodes in the > caller, not in the filesystem (which was supposed to make it easier to > write layers). > > I have a vague recollection that VOP_RENAME was the only one which wasn't > changed since it does some wildly complicated things with its vnodes. I changed them. But the changes were not integrated. It is still "callee free", e.g., in /sys/ufs/ufs/ufs_vnops.c: /* * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually * done. If a buffer has been saved in anticipation of a CREATE, delete it. */ /* ARGSUSED */ int ufs_abortop(ap) struct vop_abortop_args /* { struct vnode *a_dvp; struct componentname *a_cnp; } */ *ap; { if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF) zfree(namei_zone, ap->a_cnp->cn_pnbuf); return (0); } This is incidently, probably what Matt was looking for: VOP_ABORTOP(). As an interesting aside, you will not be able to implement a working writeable NTFS for FreeBSD until these semantics change to "caller frees" instead of "callee frees". See the Helen Custor book on NTFS with specific attention to rollback through operational abort for the gory details. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902140043.RAA00134>