Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Apr 2020 20:43:25 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r359613 - head/sys/ufs/ffs
Message-ID:  <202004032043.033KhP4j049833@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



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