Author: kib
Date: Mon Sep  9 11:22:38 2019
New Revision: 352058
URL: https://svnweb.freebsd.org/changeset/base/352058

Log:
  Remove some unneeded vfs_busy() calls in SU code.
  
  When softdep_fsync() is running, a caller must already started write
  for the mount point.  Since unmount or remount to ro suspends mount
  point, it cannot run in parallel with softdep_fsync(), which makes
  vfs_busy() call there not needed.
  
  Doing blocking vfs_busy() there effectively causes lock order reversal
  between vn_start_write() and setting MNTK_UNMOUNT, because
  vfs_busy(mp, 0) sleeps waiting for MNTK_UNMOUNT becoming clear, while
  unmount sets the flag and starts the suspension.
  
  Note that all other uses of vfs_busy() in SU code are non-blocking.
  
  Reported by:  chs by mckusick
  Reviewed by:  mckusick
  Tested by:    pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c      Mon Sep  9 11:20:15 2019        
(r352057)
+++ head/sys/ufs/ffs/ffs_softdep.c      Mon Sep  9 11:22:38 2019        
(r352058)
@@ -12507,24 +12507,13 @@ restart:
                FREE_LOCK(ump);
                if (ffs_vgetf(mp, parentino, LK_NOWAIT | LK_EXCLUSIVE, &pvp,
                    FFSV_FORCEINSMQ)) {
-                       error = vfs_busy(mp, MBF_NOWAIT);
-                       if (error != 0) {
-                               vfs_ref(mp);
-                               VOP_UNLOCK(vp, 0);
-                               error = vfs_busy(mp, 0);
-                               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-                               vfs_rel(mp);
-                               if (error != 0)
-                                       return (ENOENT);
-                               if (vp->v_iflag & VI_DOOMED) {
-                                       vfs_unbusy(mp);
-                                       return (ENOENT);
-                               }
-                       }
+                       /*
+                        * Unmount cannot proceed after unlock because
+                        * caller must have called vn_start_write().
+                        */
                        VOP_UNLOCK(vp, 0);
                        error = ffs_vgetf(mp, parentino, LK_EXCLUSIVE,
                            &pvp, FFSV_FORCEINSMQ);
-                       vfs_unbusy(mp);
                        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                        if (vp->v_iflag & VI_DOOMED) {
                                if (error == 0)
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to