diff mbox series

Btrfs: fix missing semaphore unlock

Message ID 20200317063102.8869-1-robbieko@synology.com (mailing list archive)
State New, archived
Headers show
Series Btrfs: fix missing semaphore unlock | expand

Commit Message

robbieko March 17, 2020, 6:31 a.m. UTC
From: Robbie Ko <robbieko@synology.com>

Fixes: aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Filipe Manana March 17, 2020, 11:57 a.m. UTC | #1
On Tue, Mar 17, 2020 at 6:41 AM robbieko <robbieko@synology.com> wrote:
>
> From: Robbie Ko <robbieko@synology.com>
>
> Fixes: aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
> Signed-off-by: Robbie Ko <robbieko@synology.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/file.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a16da274c9aa..ae903da21588 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -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
>
David Sterba March 17, 2020, 7:51 p.m. UTC | #2
On Tue, Mar 17, 2020 at 02:31:02PM +0800, robbieko wrote:
> From: Robbie Ko <robbieko@synology.com>

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

> Fixes: aab15e8ec2576 ("Btrfs: fix rare chances for data loss when doing a fast fsync")
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/file.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index a16da274c9aa..ae903da21588 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -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.
diff mbox series

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a16da274c9aa..ae903da21588 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -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;
 	}