Blob Blame History Raw
From: Robbie Ko <robbieko@synology.com>
Date: Tue, 17 Mar 2020 14:31:02 +0800
Git-commit: 6ff06729c22ec0b7498d900d79cc88cfb8aceaeb
Patch-mainline: 5.7
References: bsc#1171761
Subject: [PATCH] btrfs: fix missing semaphore unlock in btrfs_sync_file

Ordered ops are started twice in sync file, once outside of inode mutex
and once inside, taking the dio semaphore. There was one error path
missing the semaphore unlock.

Fixes: aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
CC: stable@vger.kernel.org # 4.19+
Signed-off-by: Robbie Ko <robbieko@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
[ add changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c2ada42..733c5d8 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2112,6 +2112,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	ret = start_ordered_ops(inode, start, end);
 	if (ret) {
+		up_write(&BTRFS_I(inode)->dio_sem);
 		inode_unlock(inode);
 		goto out;
 	}
-- 
2.16.4