freebsd-dev/sys/nfsclient
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
..
bootp_subr.c Convert GIANT_REQUIRED to NET_ASSERT_GIANT where Giant is used to 2004-06-16 03:12:50 +00:00
krpc_subr.c Convert GIANT_REQUIRED to NET_ASSERT_GIANT where Giant is used to 2004-06-16 03:12:50 +00:00
krpc.h
nfs_bio.c Remove bad cookie vp kernel printf; while it does notify about an 2004-06-17 00:15:37 +00:00
nfs_diskless.c Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfs_lock.c University of Michigan's Citi NFSv4 kernel client code. 2003-11-14 20:54:10 +00:00
nfs_lock.h Remove a case of exposing 'struct ucred' to userspace. Use a struct xucred 2002-08-15 21:52:22 +00:00
nfs_nfsiod.c Clean up properly when unloading NFS client module. 2004-04-11 13:30:20 +00:00
nfs_node.c Clean up properly when unloading NFS client module. 2004-04-11 13:30:20 +00:00
nfs_socket.c When updating sb_flags, acquire the socket buffer lock to prevent 2004-06-24 03:12:13 +00:00
nfs_subs.c When we traverse the vnodes on a mountpoint we need to look out for 2004-07-04 08:52:35 +00:00
nfs_vfsops.c When we traverse the vnodes on a mountpoint we need to look out for 2004-07-04 08:52:35 +00:00
nfs_vnops.c Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfs.h Clean up properly when unloading NFS client module. 2004-04-11 13:30:20 +00:00
nfsargs.h Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfsdiskless.h Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfsm_subs.h Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfsmount.h Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nfsnode.h Let the NFS client notice a file's size changing as a modification. 2004-04-14 23:23:55 +00:00
nfsstats.h Remove advertising clause from University of California Regent's 2004-04-07 05:00:01 +00:00
nlminfo.h