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

btrfs: remove the compress_type argument to submit_extent_page

Update the compress_type in the btrfs_bio_ctrl after forcing out the
previous bio in btrfs_do_readpage, so that alloc_new_bio can just use
the compress_type member in struct btrfs_bio_ctrl instead of passing the
same information redundantly as a function argument.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
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 a140453b
...@@ -967,8 +967,7 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, ...@@ -967,8 +967,7 @@ static void calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
static void alloc_new_bio(struct btrfs_inode *inode, static void alloc_new_bio(struct btrfs_inode *inode,
struct btrfs_bio_ctrl *bio_ctrl, struct btrfs_bio_ctrl *bio_ctrl,
u64 disk_bytenr, u32 offset, u64 file_offset, u64 disk_bytenr, u32 offset, u64 file_offset)
enum btrfs_compression_type compress_type)
{ {
struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct bio *bio; struct bio *bio;
...@@ -979,13 +978,12 @@ static void alloc_new_bio(struct btrfs_inode *inode, ...@@ -979,13 +978,12 @@ static void alloc_new_bio(struct btrfs_inode *inode,
* For compressed page range, its disk_bytenr is always @disk_bytenr * For compressed page range, its disk_bytenr is always @disk_bytenr
* passed in, no matter if we have added any range into previous bio. * passed in, no matter if we have added any range into previous bio.
*/ */
if (compress_type != BTRFS_COMPRESS_NONE) if (bio_ctrl->compress_type != BTRFS_COMPRESS_NONE)
bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT; bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
else else
bio->bi_iter.bi_sector = (disk_bytenr + offset) >> SECTOR_SHIFT; bio->bi_iter.bi_sector = (disk_bytenr + offset) >> SECTOR_SHIFT;
btrfs_bio(bio)->file_offset = file_offset; btrfs_bio(bio)->file_offset = file_offset;
bio_ctrl->bio = bio; bio_ctrl->bio = bio;
bio_ctrl->compress_type = compress_type;
calc_bio_boundaries(bio_ctrl, inode, file_offset); calc_bio_boundaries(bio_ctrl, inode, file_offset);
if (bio_ctrl->wbc) { if (bio_ctrl->wbc) {
...@@ -1006,7 +1004,6 @@ static void alloc_new_bio(struct btrfs_inode *inode, ...@@ -1006,7 +1004,6 @@ static void alloc_new_bio(struct btrfs_inode *inode,
* @size: portion of page that we want to write to * @size: portion of page that we want to write to
* @pg_offset: offset of the new bio or to check whether we are adding * @pg_offset: offset of the new bio or to check whether we are adding
* a contiguous page to the previous one * a contiguous page to the previous one
* @compress_type: compress type for current bio
* *
* The will either add the page into the existing @bio_ctrl->bio, or allocate a * The will either add the page into the existing @bio_ctrl->bio, or allocate a
* new one in @bio_ctrl->bio. * new one in @bio_ctrl->bio.
...@@ -1015,8 +1012,7 @@ static void alloc_new_bio(struct btrfs_inode *inode, ...@@ -1015,8 +1012,7 @@ static void alloc_new_bio(struct btrfs_inode *inode,
*/ */
static int submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, static int submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl,
u64 disk_bytenr, struct page *page, u64 disk_bytenr, struct page *page,
size_t size, unsigned long pg_offset, size_t size, unsigned long pg_offset)
enum btrfs_compression_type compress_type)
{ {
struct btrfs_inode *inode = BTRFS_I(page->mapping->host); struct btrfs_inode *inode = BTRFS_I(page->mapping->host);
unsigned int cur = pg_offset; unsigned int cur = pg_offset;
...@@ -1035,14 +1031,13 @@ static int submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl, ...@@ -1035,14 +1031,13 @@ static int submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl,
/* Allocate new bio if needed */ /* Allocate new bio if needed */
if (!bio_ctrl->bio) { if (!bio_ctrl->bio) {
alloc_new_bio(inode, bio_ctrl, disk_bytenr, alloc_new_bio(inode, bio_ctrl, disk_bytenr,
offset, page_offset(page) + cur, offset, page_offset(page) + cur);
compress_type);
} }
/* /*
* We must go through btrfs_bio_add_page() to ensure each * We must go through btrfs_bio_add_page() to ensure each
* page range won't cross various boundaries. * page range won't cross various boundaries.
*/ */
if (compress_type != BTRFS_COMPRESS_NONE) if (bio_ctrl->compress_type != BTRFS_COMPRESS_NONE)
added = btrfs_bio_add_page(bio_ctrl, page, disk_bytenr, added = btrfs_bio_add_page(bio_ctrl, page, disk_bytenr,
size - offset, pg_offset + offset); size - offset, pg_offset + offset);
else else
...@@ -1314,13 +1309,15 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, ...@@ -1314,13 +1309,15 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
continue; continue;
} }
if (bio_ctrl->compress_type != compress_type) if (bio_ctrl->compress_type != compress_type) {
submit_one_bio(bio_ctrl); submit_one_bio(bio_ctrl);
bio_ctrl->compress_type = compress_type;
}
if (force_bio_submit) if (force_bio_submit)
submit_one_bio(bio_ctrl); submit_one_bio(bio_ctrl);
ret = submit_extent_page(bio_ctrl, disk_bytenr, page, iosize, ret = submit_extent_page(bio_ctrl, disk_bytenr, page, iosize,
pg_offset, compress_type); pg_offset);
if (ret) { if (ret) {
/* /*
* We have to unlock the remaining range, or the page * We have to unlock the remaining range, or the page
...@@ -1626,7 +1623,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, ...@@ -1626,7 +1623,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
btrfs_page_clear_dirty(fs_info, page, cur, iosize); btrfs_page_clear_dirty(fs_info, page, cur, iosize);
ret = submit_extent_page(bio_ctrl, disk_bytenr, page, ret = submit_extent_page(bio_ctrl, disk_bytenr, page,
iosize, cur - page_offset(page), 0); iosize, cur - page_offset(page));
if (ret) { if (ret) {
has_error = true; has_error = true;
if (!saved_ret) if (!saved_ret)
...@@ -2116,7 +2113,7 @@ static int write_one_subpage_eb(struct extent_buffer *eb, ...@@ -2116,7 +2113,7 @@ static int write_one_subpage_eb(struct extent_buffer *eb,
bio_ctrl->end_io_func = end_bio_subpage_eb_writepage; bio_ctrl->end_io_func = end_bio_subpage_eb_writepage;
ret = submit_extent_page(bio_ctrl, eb->start, page, eb->len, ret = submit_extent_page(bio_ctrl, eb->start, page, eb->len,
eb->start - page_offset(page), 0); eb->start - page_offset(page));
if (ret) { if (ret) {
btrfs_subpage_clear_writeback(fs_info, page, eb->start, eb->len); btrfs_subpage_clear_writeback(fs_info, page, eb->start, eb->len);
set_btree_ioerr(page, eb); set_btree_ioerr(page, eb);
...@@ -2153,8 +2150,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, ...@@ -2153,8 +2150,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
clear_page_dirty_for_io(p); clear_page_dirty_for_io(p);
set_page_writeback(p); set_page_writeback(p);
ret = submit_extent_page(bio_ctrl, disk_bytenr, p, ret = submit_extent_page(bio_ctrl, disk_bytenr, p, PAGE_SIZE, 0);
PAGE_SIZE, 0, 0);
if (ret) { if (ret) {
set_btree_ioerr(p, eb); set_btree_ioerr(p, eb);
if (PageWriteback(p)) if (PageWriteback(p))
...@@ -4423,7 +4419,7 @@ static int read_extent_buffer_subpage(struct extent_buffer *eb, int wait, ...@@ -4423,7 +4419,7 @@ static int read_extent_buffer_subpage(struct extent_buffer *eb, int wait,
btrfs_subpage_start_reader(fs_info, page, eb->start, eb->len); btrfs_subpage_start_reader(fs_info, page, eb->start, eb->len);
ret = submit_extent_page(&bio_ctrl, eb->start, page, eb->len, ret = submit_extent_page(&bio_ctrl, eb->start, page, eb->len,
eb->start - page_offset(page), 0); eb->start - page_offset(page));
if (ret) { if (ret) {
/* /*
* In the endio function, if we hit something wrong we will * In the endio function, if we hit something wrong we will
...@@ -4534,7 +4530,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num, ...@@ -4534,7 +4530,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
ClearPageError(page); ClearPageError(page);
err = submit_extent_page(&bio_ctrl, err = submit_extent_page(&bio_ctrl,
page_offset(page), page, page_offset(page), page,
PAGE_SIZE, 0, 0); PAGE_SIZE, 0);
if (err) { if (err) {
/* /*
* We failed to submit the bio so it's the * We failed to submit the bio so it's the
......
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