Author: mckusick
Date: Fri Apr  3 20:43:25 2020
New Revision: 359613
URL: https://svnweb.freebsd.org/changeset/base/359613

Log:
  When shrinking the size of a directory it is sometimes necessary to
  sync it to disk before shrinking it. Complete the sync before getting
  the buffer for the block to be updated to do the shrink to avoid
  panicing with a recursive lock on one of the directory's buffers.
  
  Reviewed by:  Chuck Silvers (chs)
  MFC after:    3 days
  Sponsored by: Netflix

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

Modified: head/sys/ufs/ffs/ffs_inode.c
==============================================================================
--- head/sys/ufs/ffs/ffs_inode.c        Fri Apr  3 20:30:45 2020        
(r359612)
+++ head/sys/ufs/ffs/ffs_inode.c        Fri Apr  3 20:43:25 2020        
(r359613)
@@ -426,11 +426,6 @@ ffs_truncate(vp, length, flags, cred)
                ip->i_size = length;
                DIP_SET(ip, i_size, length);
        } else {
-               lbn = lblkno(fs, length);
-               flags |= BA_CLRBUF;
-               error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp);
-               if (error)
-                       return (error);
                /*
                 * When we are doing soft updates and the UFS_BALLOC
                 * above fills in a direct block hole with a full sized
@@ -439,9 +434,14 @@ ffs_truncate(vp, length, flags, cred)
                 * so that we do not get a soft updates inconsistency
                 * when we create the fragment below.
                 */
+               lbn = lblkno(fs, length);
                if (DOINGSOFTDEP(vp) && lbn < UFS_NDADDR &&
                    fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize &&
                    (error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
+                       return (error);
+               flags |= BA_CLRBUF;
+               error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp);
+               if (error)
                        return (error);
                ip->i_size = length;
                DIP_SET(ip, i_size, length);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to