Commit e43a6210 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: don't free the async_extent in submit_uncompressed_range

Let submit_one_async_extent, which is the only caller of
submit_uncompressed_range handle freeing of the async_extent in one
central place.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 05d06a5c
...@@ -945,10 +945,9 @@ static int submit_uncompressed_range(struct btrfs_inode *inode, ...@@ -945,10 +945,9 @@ static int submit_uncompressed_range(struct btrfs_inode *inode,
ret = cow_file_range(inode, locked_page, start, end, &page_started, ret = cow_file_range(inode, locked_page, start, end, &page_started,
&nr_written, 0, NULL); &nr_written, 0, NULL);
/* Inline extent inserted, page gets unlocked and everything is done */ /* Inline extent inserted, page gets unlocked and everything is done */
if (page_started) { if (page_started)
ret = 0; return 0;
goto out;
}
if (ret < 0) { if (ret < 0) {
btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1); btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1);
if (locked_page) { if (locked_page) {
...@@ -962,14 +961,11 @@ static int submit_uncompressed_range(struct btrfs_inode *inode, ...@@ -962,14 +961,11 @@ static int submit_uncompressed_range(struct btrfs_inode *inode,
end_extent_writepage(locked_page, ret, page_start, page_end); end_extent_writepage(locked_page, ret, page_start, page_end);
unlock_page(locked_page); unlock_page(locked_page);
} }
goto out; return ret;
} }
ret = extent_write_locked_range(&inode->vfs_inode, start, end);
/* All pages will be unlocked, including @locked_page */ /* All pages will be unlocked, including @locked_page */
out: return extent_write_locked_range(&inode->vfs_inode, start, end);
kfree(async_extent);
return ret;
} }
static int submit_one_async_extent(struct btrfs_inode *inode, static int submit_one_async_extent(struct btrfs_inode *inode,
...@@ -1001,8 +997,10 @@ static int submit_one_async_extent(struct btrfs_inode *inode, ...@@ -1001,8 +997,10 @@ static int submit_one_async_extent(struct btrfs_inode *inode,
lock_extent(io_tree, start, end, NULL); lock_extent(io_tree, start, end, NULL);
/* We have fall back to uncompressed write */ /* We have fall back to uncompressed write */
if (!async_extent->pages) if (!async_extent->pages) {
return submit_uncompressed_range(inode, async_extent, locked_page); ret = submit_uncompressed_range(inode, async_extent, locked_page);
goto done;
}
ret = btrfs_reserve_extent(root, async_extent->ram_size, ret = btrfs_reserve_extent(root, async_extent->ram_size,
async_extent->compressed_size, async_extent->compressed_size,
...@@ -1067,6 +1065,7 @@ static int submit_one_async_extent(struct btrfs_inode *inode, ...@@ -1067,6 +1065,7 @@ static int submit_one_async_extent(struct btrfs_inode *inode,
if (async_chunk->blkcg_css) if (async_chunk->blkcg_css)
kthread_associate_blkcg(NULL); kthread_associate_blkcg(NULL);
*alloc_hint = ins.objectid + ins.offset; *alloc_hint = ins.objectid + ins.offset;
done:
kfree(async_extent); kfree(async_extent);
return ret; return ret;
...@@ -1081,8 +1080,7 @@ static int submit_one_async_extent(struct btrfs_inode *inode, ...@@ -1081,8 +1080,7 @@ static int submit_one_async_extent(struct btrfs_inode *inode,
PAGE_UNLOCK | PAGE_START_WRITEBACK | PAGE_UNLOCK | PAGE_START_WRITEBACK |
PAGE_END_WRITEBACK | PAGE_SET_ERROR); PAGE_END_WRITEBACK | PAGE_SET_ERROR);
free_async_extent_pages(async_extent); free_async_extent_pages(async_extent);
kfree(async_extent); goto done;
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment