Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Mar 2019 13:42:38 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r345641 - stable/12/sys/fs/nullfs
Message-ID:  <201903281342.x2SDgcpP060210@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Mar 28 13:42:37 2019
New Revision: 345641
URL: https://svnweb.freebsd.org/changeset/base/345641

Log:
  MFC r345376:
  nullfs: fix unmounts when filesystem is active.

Modified:
  stable/12/sys/fs/nullfs/null_vfsops.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/nullfs/null_vfsops.c
==============================================================================
--- stable/12/sys/fs/nullfs/null_vfsops.c	Thu Mar 28 13:27:34 2019	(r345640)
+++ stable/12/sys/fs/nullfs/null_vfsops.c	Thu Mar 28 13:42:37 2019	(r345641)
@@ -235,7 +235,7 @@ nullfs_unmount(mp, mntflags)
 {
 	struct null_mount *mntdata;
 	struct mount *ump;
-	int error, flags;
+	int error, flags, rootrefs;
 
 	NULLFSDEBUG("nullfs_unmount: mp = %p\n", (void *)mp);
 
@@ -244,10 +244,20 @@ nullfs_unmount(mp, mntflags)
 	else
 		flags = 0;
 
-	/* There is 1 extra root vnode reference (nullm_rootvp). */
-	error = vflush(mp, 1, flags, curthread);
-	if (error)
-		return (error);
+	for (rootrefs = 1;; rootrefs = 0) {
+		/* There is 1 extra root vnode reference (nullm_rootvp). */
+		error = vflush(mp, rootrefs, flags, curthread);
+		if (error)
+			return (error);
+		MNT_ILOCK(mp);
+		if (mp->mnt_nvnodelistsize == 0) {
+			MNT_IUNLOCK(mp);
+			break;
+		}
+		MNT_IUNLOCK(mp);
+		if ((mntflags & MNT_FORCE) == 0)
+			return (EBUSY);
+	}
 
 	/*
 	 * Finally, throw away the null_mount structure



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903281342.x2SDgcpP060210>