Skip to content

Commit d924a0b

Browse files
fdmananagregkh
authored andcommitted
btrfs: fix double inode unlock for direct IO sync writes
commit e0391e9 upstream. If we do a direct IO sync write, at btrfs_sync_file(), and we need to skip inode logging or we get an error starting a transaction or an error when flushing delalloc, we end up unlocking the inode when we shouldn't under the 'out_release_extents' label, and then unlock it again at btrfs_direct_write(). Fix that by checking if we have to skip inode unlocking under that label. Reported-by: syzbot+7dbbb74af6291b5a5a8b@syzkaller.appspotmail.com Link: https://lore.kernel.org/linux-btrfs/000000000000dfd631061eaeb4bc@google.com/ Fixes: 939b656 ("btrfs: fix corruption after buffer fault in during direct IO append write") Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ec87dd6 commit d924a0b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

fs/btrfs/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
20802080

20812081
out_release_extents:
20822082
btrfs_release_log_ctx_extents(&ctx);
2083-
btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
2083+
if (skip_ilock)
2084+
up_write(&BTRFS_I(inode)->i_mmap_lock);
2085+
else
2086+
btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
20842087
goto out;
20852088
}
20862089

0 commit comments

Comments
 (0)