Subject: kern/15421: vnode VOP_()erations handle SAVESTART inconsistently
To: None <gnats-bugs@gnats.netbsd.org>
From: Chris Jepeway <jepeway@blasted-heath.com>
List: netbsd-bugs
Date: 01/29/2002 15:27:49
>Number:         15421
>Category:       kern
>Synopsis:       vnode VOP()erations handle SAVESTART inconsistently
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 29 12:28:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Chris Jepeway
>Release:        NetBSD-current
>Organization:
	Blasted Heath Consulting, LLC
>Environment:
	i386
	NetBSD-current
>Description:
	For a given file system, vnode operations that take a
	componentname as an arg each handle the SAVESTART bit
	in cn_flags differently.  For example, ufs_link() ignores
	SAVESTART, but ufs_create() will honor it.

	For a given VOP that takes a componentname, different
	file systems handle the SAVESTART bit differently.
	Eg, msdosfs_mkdir() will honor SAVESTART, but ext2fs_mkdir()
	doesn't.

	These inconsistencies make it hard to do things like
	implementing a layered file system that wants to use
	cn_pnbuf after calling its sub-layer.  Well, not hard
	exactly, but inefficient.

>How-To-Repeat:
	Check the end of sys/msdosfs/msdosfs_vops.c:msdosfs_mkdir()
	and contrast it to the end of sys/ufs/ufs/ufs_vnops.c:ufs_mkdir().
	While you're there, follow ufs_create() down to the end of
	ufs_makeinode().  Contrast to the end of ufs_link().
>Fix:
	Make a policy decision as to which vnode operations taking
	componentnames should honor the SAVESTART bit.  ISTM that
	all vops should honor it, but see ufs_rename() for some
	trickiness that I can't follow that could be an argument
	against honoring SAVESTART.

	Then, audit all code implementing VOP_()s that take componentnames
	and make them handle SAVESTART according to policy.  A fix to
	get ufs_link() to care about SAVESTART would look like this

Index: ufs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ufs_vnops.c	2001/10/25 21:49:09	1.1
+++ ufs_vnops.c	2002/01/27 18:49:29	1.2
@@ -679,7 +679,8 @@
 		if (DOINGSOFTDEP(vp))
 			softdep_change_linkcnt(ip);
 	}
-	PNBUF_PUT(cnp->cn_pnbuf);
+	if ((cnp->cn_flags & SAVESTART) == 0)
+		PNBUF_PUT(cnp->cn_pnbuf);
  out1:
 	if (dvp != vp)
 		VOP_UNLOCK(vp, 0);


>Release-Note:
>Audit-Trail:
>Unformatted: