[PATCH] btrfs: Add missing skip-lock for locks
From: Edward Adam Davis
Date: Fri Aug 02 2024 - 07:59:51 EST
The commit 939b656bc8ab missing a skip-lock in btrfs_sync_file,
it cause syzbot report WARNING: bad unlock balance in btrfs_direct_write.
Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
Reported-and-tested-by: syzbot+7dbbb74af6291b5a5a8b@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=7dbbb74af6291b5a5a8b
Signed-off-by: Edward Adam Davis <eadavis@xxxxxx>
---
fs/btrfs/file.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 9f10a9f23fcc..9914419f3b7d 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1868,7 +1868,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
out_release_extents:
btrfs_release_log_ctx_extents(&ctx);
- btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+ if (skip_ilock)
+ up_write(&inode->i_mmap_lock);
+ else
+ btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
goto out;
}
--
2.43.0