aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2019-01-03 10:50:01 +0200
committerDavid Sterba <dsterba@suse.com>2019-02-25 14:13:19 +0100
commitbd4691a0e866e774c9690f09fec573e845495f91 (patch)
tree4f4179bb92f11f58a073f8695cc49d8266b90917 /fs/btrfs
parentbtrfs: Remove isize local variable in compress_file_range (diff)
downloadlinux-dev-bd4691a0e866e774c9690f09fec573e845495f91.tar.xz
linux-dev-bd4691a0e866e774c9690f09fec573e845495f91.zip
btrfs: Use ihold instead of igrab in cow_file_range_async
ihold is supposed to be used when the caller already has a reference to the inode. In the case of cow_file_range_async this invariants holds, since the 3 call chains leading to this function all take a reference: btrfs_writepage <--- does igrab extent_write_full_page __extent_writepage writepage_delalloc btrfs_run_delalloc_range cow_file_range_async extent_write_cache_pages <--- does igrab __extent_writepage (same callchain as above) and submit_compressed_extents <-- already called from async CoW submit path, which would have done ihold. extent_write_locked_range __extent_writepage Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> [ add comment ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/inode.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3c11982d73f7..d548538d0b16 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1193,7 +1193,12 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
while (start < end) {
async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
BUG_ON(!async_cow); /* -ENOMEM */
- async_cow->inode = igrab(inode);
+ /*
+ * igrab is called higher up in the call chain, take only the
+ * lightweight reference for the callback lifetime
+ */
+ ihold(inode);
+ async_cow->inode = inode;
async_cow->fs_info = fs_info;
async_cow->locked_page = locked_page;
async_cow->start = start;