svn commit: r308617 - head/sys/kern

Konstantin Belousov kib at FreeBSD.org
Sun Nov 13 21:39:57 UTC 2016


Author: kib
Date: Sun Nov 13 21:39:55 2016
New Revision: 308617
URL: https://svnweb.freebsd.org/changeset/base/308617

Log:
  Move common cleanup code into helper.
  
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Sun Nov 13 17:55:27 2016	(r308616)
+++ head/sys/kern/vfs_mount.c	Sun Nov 13 21:39:55 2016	(r308617)
@@ -1235,6 +1235,24 @@ vfs_check_usecounts(struct mount *mp)
 	return (0);
 }
 
+static void
+dounmount_cleanup(struct mount *mp, struct vnode *coveredvp, int mntkflags)
+{
+
+	mtx_assert(MNT_MTX(mp), MA_OWNED);
+	mp->mnt_kern_flag &= ~mntkflags;
+	if ((mp->mnt_kern_flag & MNTK_MWAIT) != 0) {
+		mp->mnt_kern_flag &= ~MNTK_MWAIT;
+		wakeup(mp);
+	}
+	MNT_IUNLOCK(mp);
+	if (coveredvp != NULL) {
+		VOP_UNLOCK(coveredvp, 0);
+		vdrop(coveredvp);
+	}
+	vn_finished_write(mp);
+}
+
 /*
  * Do the actual filesystem unmount.
  */
@@ -1282,12 +1300,7 @@ dounmount(struct mount *mp, int flags, s
 	MNT_ILOCK(mp);
 	if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 ||
 	    !TAILQ_EMPTY(&mp->mnt_uppers)) {
-		MNT_IUNLOCK(mp);
-		if (coveredvp != NULL) {
-			VOP_UNLOCK(coveredvp, 0);
-			vdrop(coveredvp);
-		}
-		vn_finished_write(mp);
+		dounmount_cleanup(mp, coveredvp, 0);
 		return (EBUSY);
 	}
 	mp->mnt_kern_flag |= MNTK_UNMOUNT | MNTK_NOINSMNTQ;
@@ -1296,17 +1309,8 @@ dounmount(struct mount *mp, int flags, s
 		error = vfs_check_usecounts(mp);
 		MNT_ILOCK(mp);
 		if (error != 0) {
-			mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ);
-			if (mp->mnt_kern_flag & MNTK_MWAIT) {
-				mp->mnt_kern_flag &= ~MNTK_MWAIT;
-				wakeup(mp);
-			}
-			MNT_IUNLOCK(mp);
-			if (coveredvp != NULL) {
-				VOP_UNLOCK(coveredvp, 0);
-				vdrop(coveredvp);
-			}
-			vn_finished_write(mp);
+			dounmount_cleanup(mp, coveredvp, MNTK_UNMOUNT |
+			    MNTK_NOINSMNTQ);
 			return (error);
 		}
 	}


More information about the svn-src-head mailing list