freebsd-skq/sys/fs
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
..
cd9660 Remove "register" keyword and trailing white space. 2004-07-03 16:56:45 +00:00
coda When we traverse the vnodes on a mountpoint we need to look out for 2004-07-04 08:52:35 +00:00
deadfs
devfs Reduce a fair bit of the atomics because we are now called with a 2004-06-18 08:08:47 +00:00
fdescfs
fifofs Remove unlocked read annotation for sbspace(); the read is locked. 2004-06-23 00:35:50 +00:00
hpfs Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
msdosfs When we traverse the vnodes on a mountpoint we need to look out for 2004-07-04 08:52:35 +00:00
ntfs Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
nullfs
nwfs Make vm_page's PG_ZERO flag immutable between the time of the page's 2004-05-06 05:03:23 +00:00
portalfs Remove spls from portal_open(). Acquire socket lock while sleeping 2004-06-24 00:47:23 +00:00
procfs
pseudofs
smbfs Make vm_page's PG_ZERO flag immutable between the time of the page's 2004-05-06 05:03:23 +00:00
specfs Second half of the dev_t cleanup. 2004-06-17 17:16:53 +00:00
udf Make the udf_vnops side endian clean. 2004-06-23 21:49:03 +00:00
umapfs
unionfs