Commit c7ee1819 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_submit_compressed_write take btrfs_inode

Majority of its uses are for btrfs_inode so take it as an argument
directly.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4cc61209
...@@ -405,7 +405,7 @@ static void end_compressed_bio_write(struct bio *bio) ...@@ -405,7 +405,7 @@ static void end_compressed_bio_write(struct bio *bio)
* This also checksums the file bytes and gets things ready for * This also checksums the file bytes and gets things ready for
* the end io hooks. * the end io hooks.
*/ */
blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
unsigned long len, u64 disk_start, unsigned long len, u64 disk_start,
unsigned long compressed_len, unsigned long compressed_len,
struct page **compressed_pages, struct page **compressed_pages,
...@@ -413,7 +413,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -413,7 +413,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
unsigned int write_flags, unsigned int write_flags,
struct cgroup_subsys_state *blkcg_css) struct cgroup_subsys_state *blkcg_css)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct bio *bio = NULL; struct bio *bio = NULL;
struct compressed_bio *cb; struct compressed_bio *cb;
unsigned long bytes_left; unsigned long bytes_left;
...@@ -421,7 +421,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -421,7 +421,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
struct page *page; struct page *page;
u64 first_byte = disk_start; u64 first_byte = disk_start;
blk_status_t ret; blk_status_t ret;
int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; int skip_sum = inode->flags & BTRFS_INODE_NODATASUM;
WARN_ON(!PAGE_ALIGNED(start)); WARN_ON(!PAGE_ALIGNED(start));
cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS); cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
...@@ -429,7 +429,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -429,7 +429,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
return BLK_STS_RESOURCE; return BLK_STS_RESOURCE;
refcount_set(&cb->pending_bios, 0); refcount_set(&cb->pending_bios, 0);
cb->errors = 0; cb->errors = 0;
cb->inode = inode; cb->inode = &inode->vfs_inode;
cb->start = start; cb->start = start;
cb->len = len; cb->len = len;
cb->mirror_num = 0; cb->mirror_num = 0;
...@@ -455,7 +455,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -455,7 +455,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
int submit = 0; int submit = 0;
page = compressed_pages[pg_index]; page = compressed_pages[pg_index];
page->mapping = inode->i_mapping; page->mapping = inode->vfs_inode.i_mapping;
if (bio->bi_iter.bi_size) if (bio->bi_iter.bi_size)
submit = btrfs_bio_fits_in_stripe(page, PAGE_SIZE, bio, submit = btrfs_bio_fits_in_stripe(page, PAGE_SIZE, bio,
0); 0);
...@@ -475,8 +475,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -475,8 +475,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
if (!skip_sum) { if (!skip_sum) {
ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, ret = btrfs_csum_one_bio(inode, bio, start, 1);
start, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
...@@ -508,7 +507,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -508,7 +507,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
if (!skip_sum) { if (!skip_sum) {
ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, start, 1); ret = btrfs_csum_one_bio(inode, bio, start, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <linux/sizes.h> #include <linux/sizes.h>
struct btrfs_inode;
/* /*
* We want to make sure that amount of RAM required to uncompress an extent is * We want to make sure that amount of RAM required to uncompress an extent is
* reasonable, so we limit the total size in ram of a compressed extent to * reasonable, so we limit the total size in ram of a compressed extent to
...@@ -88,7 +90,7 @@ int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start, ...@@ -88,7 +90,7 @@ int btrfs_decompress_buf2page(const char *buf, unsigned long buf_start,
unsigned long total_out, u64 disk_start, unsigned long total_out, u64 disk_start,
struct bio *bio); struct bio *bio);
blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
unsigned long len, u64 disk_start, unsigned long len, u64 disk_start,
unsigned long compressed_len, unsigned long compressed_len,
struct page **compressed_pages, struct page **compressed_pages,
......
...@@ -887,7 +887,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) ...@@ -887,7 +887,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
NULL, EXTENT_LOCKED | EXTENT_DELALLOC, NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
PAGE_UNLOCK | PAGE_CLEAR_DIRTY | PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
PAGE_SET_WRITEBACK); PAGE_SET_WRITEBACK);
if (btrfs_submit_compressed_write(inode, if (btrfs_submit_compressed_write(BTRFS_I(inode),
async_extent->start, async_extent->start,
async_extent->ram_size, async_extent->ram_size,
ins.objectid, ins.objectid,
......
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