Skip to contentSkip to conversation

Btrfs: fix missing semaphore unlock

PATCH In review robbieko 3 participants 3 messages Mar 17, 2020 Btrfs file system

lore
Share & tools
lore

robbieko

author
#0 lore raw

PATCH 1/1 Btrfs: fix missing semaphore unlock

From: Robbie Ko <[email protected]>

Fixes aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/file.c +1 -0
index a16da274c9aa..ae903da21588 100644
@@ -2124,6 +2124,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;
 	}
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · robbieko

From: Robbie Ko <[email protected]>

Fixes aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")

Looks good, thanks.

Quoted 19 lines
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/file.c +1 -1
index a16da274c9aa..ae903da21588 100644
@@ -2124,6 +2124,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.17.1

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
#2 lore raw
In reply to robbieko
Quoted 1 line · robbieko

From: Robbie Ko <[email protected]>

This is not a trivial patch that could go without a changelog.

Quoted 11 lines
Fixes aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/file.c +0 -0
index a16da274c9aa..ae903da21588 100644

fs/btrfs/file.c int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) · line 2127

Quoted 4 lines
fs/btrfs/file.c +1 -0
@@ -2124,6 +2124,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);

I did not spot on first sight that there's was missing semaphore unlock and a few lines below there's down_write(dio_sem). Turns out there are two calls to start_ordered_ops, one before dio_sem and one inside the locked section. So I solved the puzzle but I'd prefer not having to and get a patch with instructions.