diff options
-rw-r--r-- | fs/btrfs/inode.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b7f398c36cb7..06075043da5d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -986,8 +986,10 @@ static noinline void async_cow_start(struct btrfs_work *work) | |||
986 | compress_file_range(async_cow->inode, async_cow->locked_page, | 986 | compress_file_range(async_cow->inode, async_cow->locked_page, |
987 | async_cow->start, async_cow->end, async_cow, | 987 | async_cow->start, async_cow->end, async_cow, |
988 | &num_added); | 988 | &num_added); |
989 | if (num_added == 0) | 989 | if (num_added == 0) { |
990 | iput(async_cow->inode); | ||
990 | async_cow->inode = NULL; | 991 | async_cow->inode = NULL; |
992 | } | ||
991 | } | 993 | } |
992 | 994 | ||
993 | /* | 995 | /* |
@@ -1020,6 +1022,8 @@ static noinline void async_cow_free(struct btrfs_work *work) | |||
1020 | { | 1022 | { |
1021 | struct async_cow *async_cow; | 1023 | struct async_cow *async_cow; |
1022 | async_cow = container_of(work, struct async_cow, work); | 1024 | async_cow = container_of(work, struct async_cow, work); |
1025 | if (async_cow->inode) | ||
1026 | iput(async_cow->inode); | ||
1023 | kfree(async_cow); | 1027 | kfree(async_cow); |
1024 | } | 1028 | } |
1025 | 1029 | ||
@@ -1038,7 +1042,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, | |||
1038 | while (start < end) { | 1042 | while (start < end) { |
1039 | async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); | 1043 | async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); |
1040 | BUG_ON(!async_cow); /* -ENOMEM */ | 1044 | BUG_ON(!async_cow); /* -ENOMEM */ |
1041 | async_cow->inode = inode; | 1045 | async_cow->inode = igrab(inode); |
1042 | async_cow->root = root; | 1046 | async_cow->root = root; |
1043 | async_cow->locked_page = locked_page; | 1047 | async_cow->locked_page = locked_page; |
1044 | async_cow->start = start; | 1048 | async_cow->start = start; |