freebsd-skq/sys/nfs4client
Poul-Henning Kamp e3c5a7a4dd When we traverse the vnodes on a mountpoint we need to look out for
our cached 'next vnode' being removed from this mountpoint.  If we
find that it was recycled, we restart our traversal from the start
of the list.

Code to do that is in all local disk filesystems (and a few other
places) and looks roughly like this:

		MNT_ILOCK(mp);
	loop:
		for (vp = TAILQ_FIRST(&mp...);
		    (vp = nvp) != NULL;
		    nvp = TAILQ_NEXT(vp,...)) {
			if (vp->v_mount != mp)
				goto loop;
			MNT_IUNLOCK(mp);
			...
			MNT_ILOCK(mp);
		}
		MNT_IUNLOCK(mp);

The code which takes vnodes off a mountpoint looks like this:

	MNT_ILOCK(vp->v_mount);
	...
	TAILQ_REMOVE(&vp->v_mount->mnt_nvnodelist, vp, v_nmntvnodes);
	...
	MNT_IUNLOCK(vp->v_mount);
	...
	vp->v_mount = something;

(Take a moment and try to spot the locking error before you read on.)

On a SMP system, one CPU could have removed nvp from our mountlist
but not yet gotten to assign a new value to vp->v_mount while another
CPU simultaneously get to the top of the traversal loop where it
finds that (vp->v_mount != mp) is not true despite the fact that
the vnode has indeed been removed from our mountpoint.

Fix:

Introduce the macro MNT_VNODE_FOREACH() to traverse the list of
vnodes on a mountpoint while taking into account that vnodes may
be removed from the list as we go.  This saves approx 65 lines of
duplicated code.

Split the insmntque() which potentially moves a vnode from one mount
point to another into delmntque() and insmntque() which does just
what the names say.

Fix delmntque() to set vp->v_mount to NULL while holding the
mountpoint lock.
2004-07-04 08:52:35 +00:00
..
nfs4_dev.c Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
nfs4_dev.h fix for 64-bit arch: 2004-03-26 22:44:59 +00:00
nfs4_idmap.c in idmap_uid_to_name(), don't try to use the entry after freeing it, in the 2004-02-21 22:52:02 +00:00
nfs4_idmap.h
nfs4_socket.c Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
nfs4_subs.c NFSv4 fixes from Connectathon 2004: 2004-02-27 19:37:43 +00:00
nfs4_vfs_subs.c
nfs4_vfs.h
nfs4_vfsops.c When we traverse the vnodes on a mountpoint we need to look out for 2004-07-04 08:52:35 +00:00
nfs4_vn_subs.c Second half of the dev_t cleanup. 2004-06-17 17:16:53 +00:00
nfs4_vn.h
nfs4_vnops.c Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00
nfs4.h
nfs4m_subs.h