aboutsummaryrefslogtreecommitdiff
path: root/sys/nfsclient/nfs_vfsops.c
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2013-04-18 23:20:16 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2013-04-18 23:20:16 +0000
commit64a0e848abbc491831a2969e72ecfb6a0ae9716c (patch)
tree123e23f31a2970af6a69b52f37d7e4e48743083c /sys/nfsclient/nfs_vfsops.c
parent3cc7ae06fd8c2cac6eb5051a5e48ab00d17adc1b (diff)
downloadsrc-64a0e848abbc491831a2969e72ecfb6a0ae9716c.tar.gz
src-64a0e848abbc491831a2969e72ecfb6a0ae9716c.zip
When an NFS unmount occurs, once vflush() writes the last dirty
buffer for the last vnode on the mount back to the server, it returns. At that point, the code continues with the unmount, including freeing up the nfs specific part of the mount structure. It is possible that an nfsiod thread will try to check for an empty I/O queue in the nfs specific part of the mount structure after it has been free'd by the unmount. This patch avoids this problem by setting the iodmount entries for the mount back to NULL while holding the mutex in the unmount and checking the appropriate entry is non-NULL after acquiring the mutex in the nfsiod thread. Reported and tested by: pho Reviewed by: kib MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=249630
Diffstat (limited to 'sys/nfsclient/nfs_vfsops.c')
-rw-r--r--sys/nfsclient/nfs_vfsops.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index 6f00cf90de2f..7a26aa20aff1 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -1362,7 +1362,7 @@ static int
nfs_unmount(struct mount *mp, int mntflags)
{
struct nfsmount *nmp;
- int error, flags = 0;
+ int error, flags = 0, i;
if (mntflags & MNT_FORCE)
flags |= FORCECLOSE;
@@ -1387,6 +1387,14 @@ nfs_unmount(struct mount *mp, int mntflags)
/*
* We are now committed to the unmount.
*/
+ /* Make sure no nfsiods are assigned to this mount. */
+ mtx_lock(&nfs_iod_mtx);
+ for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
+ if (nfs_iodmount[i] == nmp) {
+ nfs_iodwant[i] = NFSIOD_AVAILABLE;
+ nfs_iodmount[i] = NULL;
+ }
+ mtx_unlock(&nfs_iod_mtx);
nfs_disconnect(nmp);
free(nmp->nm_nam, M_SONAME);