aboutsummaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2020-04-03 20:43:25 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2020-04-03 20:43:25 +0000
commit2baca885842a49ff8f2522c275a22cb71fe77139 (patch)
treed3d9e4c2b06c831a89c9d8be636b770b89c95d54 /sys/ufs
parentaedb9cc6621c4b9eea3f771b278a3486b6e980fd (diff)
downloadsrc-2baca885842a49ff8f2522c275a22cb71fe77139.tar.gz
src-2baca885842a49ff8f2522c275a22cb71fe77139.zip
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
Notes
Notes: svn path=/head/; revision=359613
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_inode.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 237436fb167e..ccb3f7cde899 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -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,10 +434,15 @@ 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);
size = blksize(fs, ip, lbn);