Simplifications around submit_bio_hook
cover Simplifications around submit_bio_hook
I've been taking a look at the submit_bio_hook et al and I saw some opportunities for improvement. First I begin by simplifying the definition of submit_bio_hook callback and making one of its arguments explicit.
Patch 3 removes a redundant extent_io_tree argument that was passed through several layers of functions and ultimately made it somewhat cumbersome to reason what extent_io_tree is being used.
Patch 4 and 5 hardcode a 0 being passed for the bio_offset parameter to btrfs_submit_bio_start/btree_submit_bio_start since it only matters for DIO.
Patch 6 finally does away with the bio_offset parameter of submit_bio_hook.
Here is the output of bloat-o-meter for posterity:
add/remove: 0/0 grow/shrink: 4/7 up/down: 48/-319 (-271)
Function old new delta read_extent_buffer_pages 784 822 +38 btrfs_add_ordered_sum 100 104 +4 btrfs_submit_bio_hook 364 367 +3 btree_submit_bio_hook 175 178 +3 end_bio_extent_readpage 2119 2116 -3 btrfs_reloc_clone_csums 272 262 -10 btrfs_csum_one_bio 1358 1348 -10 btree_read_extent_buffer_pages 282 272 -10 readahead_tree_block 73 55 -18 reada_tree_block_flagged 194 165 -29
submit_one_bio 313 74 -239
Total: Before=1072719, After=1072448, chg -0.03%
Nikolay Borisov (6):
btrfs: Define submit_bio_hook's type directly
btrfs: Change submit_bio_hook to taking an inode directly
btrfs: Remove 'tree' argument from read_extent_buffer_pages
btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
btrfs: Always pass 0 bio_offset for btree_submit_bio_start
btrfs: Remove bio_offset argument from submit_bio_hook
fs/btrfs/disk-io.c | 22 +++++++--------------- fs/btrfs/extent_io.c | 10 ++++------ fs/btrfs/extent_io.h | 9 +++------ fs/btrfs/inode.c | 11 +++++------ 4 files changed, 19 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/6 btrfs: Define submit_bio_hook's type directly
There is no need to use a typedef to define the type of the function and then use that to define the respective member in extent_io_ops. Define struct's member directly. No functional changes.
--- fs/btrfs/extent_io.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.h +3 -4
@@ -95,9 +95,6 @@ struct btrfs_inode;struct btrfs_io_bio ;struct io_failure_record ; -typedef blk_status_t (extent_submit_bio_hook_t )(void *private_data,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset);typedef blk_status_t (extent_submit_bio_start_t )(void *private_data,struct bio *bio,u64 bio_offset);
@@ -107,7 +104,9 @@ struct extent_io_ops {* The following callbacks must be always defined, the function * pointer will be called unconditionally. */ -extent_submit_bio_hook_t *submit_bio_hook; +blk_status_t (*submit_bio_hook)(void *private_data,struct bio *bio, +int mirror_num,unsigned long bio_flags, +u64 bio_offset);int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio,u64 phy_offset,struct page *page,u64 start,u64 end,int mirror);
Signature · 1 line
2.17.1
Re: [PATCH 1/6] btrfs: Define submit_bio_hook's type directly
Looks good,
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 2/6 btrfs: Change submit_bio_hook to taking an inode directly
In reply to Nikolay BorisovThe only possible 'private_data' that is passed to this function is actually an inode. Make that explicit by changing the signature of the call back. No functional changes.
--- fs/btrfs/disk-io.c | 5 ++--- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-)
fs/btrfs/disk-io.c +2 -3
@@ -885,11 +885,10 @@ static int check_async_write(struct btrfs_inode *bi)return 1 ; } -static blk_status_t btree_submit_bio_hook (void *private_data,struct bio *bio, +static blk_status_t btree_submit_bio_hook (struct inode *inode,struct bio *bio,int mirror_num,unsigned long bio_flags,u64 bio_offset) { -struct inode *inode = private_data;struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);int async =check_async_write (BTRFS_I (inode));blk_status_t ret;
@@ -915,7 +914,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio,* checksumming can happen in parallel across all CPUs */ ret =btrfs_wq_submit_bio (fs_info, bio, mirror_num,0 , - bio_offset, private_data, + bio_offset, inode, btree_submit_bio_start); }
fs/btrfs/extent_io.h +1 -1
@@ -104,7 +104,7 @@ struct extent_io_ops {* The following callbacks must be always defined, the function * pointer will be called unconditionally. */ -blk_status_t (*submit_bio_hook)(void *private_data,struct bio *bio, +blk_status_t (*submit_bio_hook)(struct inode *inode,struct bio *bio,int mirror_num,unsigned long bio_flags,u64 bio_offset); int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio, u64 phy_offset,
fs/btrfs/inode.c +1 -2
@@ -1953,11 +1953,10 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,* * c-3) otherwise: async submit */ -static blk_status_t btrfs_submit_bio_hook (void *private_data,struct bio *bio, +static blk_status_t btrfs_submit_bio_hook (struct inode *inode,struct bio *bio,int mirror_num,unsigned long bio_flags,u64 bio_offset) { -struct inode *inode = private_data;struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;enum btrfs_wq_endio_type metadata =BTRFS_WQ_ENDIO_DATA ;
Signature · 1 line
2.17.1
Re: [PATCH 2/6] btrfs: Change submit_bio_hook to taking an inode directly
Quoted 3 lines · Nikolay Borisov
The only possible '
private_data' that is passed to this function is actually an inode. Make that explicit by changing the signature of the call back. No functional changes.
Can't we change struct extent_io_tree::private_data and extent_io_tree_init(..., void *private_data) to be an inode as well?
If I didn't overlook something we always pass in an inode or NULL.
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 2/6] btrfs: Change submit_bio_hook to taking an inode directly
Quoted 9 lines · Johannes Thumshirn
Quoted 3 lines · Nikolay Borisov
The only possible '
private_data' that is passed to this function is actually an inode. Make that explicit by changing the signature of the call back. No functional changes.Can't we change struct
extent_io_tree::private_dataandextent_io_tree_init(..., void *private_data)to be an inode as well?If I didn't overlook something we always pass in an inode or NULL.
You are right, latest refactoring I did made it so. I can send patches atop this series.
David, how do you like to organise this? Resend the series with 2 more patches in it or shall I send them as separate once this lands?
Quoted 1 line
PATCH 3/6 btrfs: Remove 'tree' argument from read_extent_buffer_pages
In reply to Nikolay BorisovThis function always uses the btree inode's io_tree. Stop taking the tree as a function argument and instead access it internally from read_extent_buffer_pages. No functional changes.
--- fs/btrfs/disk-io.c | 12 +++--------- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/extent_io.h | 3 +-- 3 files changed, 6 insertions(+), 13 deletions(-)
fs/btrfs/disk-io.c +3 -9
@@ -465,8 +465,7 @@ static int btree_read_extent_buffer_pages(struct extent_buffer *eb, io_tree = &BTRFS_I (fs_info->btree_inode)->io_tree;while (1 ) {clear_bit (EXTENT_BUFFER_CORRUPT , &eb->bflags); - ret =read_extent_buffer_pages (io_tree, eb,WAIT_COMPLETE , - mirror_num); + ret =read_extent_buffer_pages (eb,WAIT_COMPLETE , mirror_num);if (!ret) {if (verify_parent_transid (io_tree, eb, parent_transid,0 ))
@@ -1034,15 +1033,13 @@ static const struct address_space_operations btree_aops = {void readahead_tree_block (struct btrfs_fs_info *fs_info,u64 bytenr) {struct extent_buffer *buf =NULL ; -struct inode *btree_inode = fs_info->btree_inode;int ret; buf =btrfs_find_create_tree_block (fs_info, bytenr);if (IS_ERR (buf))return ; - ret =read_extent_buffer_pages (&BTRFS_I (btree_inode)->io_tree, buf, -WAIT_NONE ,0 ); + ret =read_extent_buffer_pages (buf,WAIT_NONE ,0 );if (ret <0 )free_extent_buffer_stale (buf);else
@@ -1053,8 +1050,6 @@ int reada_tree_block_flagged(struct btrfs_fs_info *fs_info, u64 bytenr, int mirror_num, struct extent_buffer **eb) { struct extent_buffer *buf = NULL; -struct inode *btree_inode = fs_info->btree_inode; -struct extent_io_tree *io_tree = &BTRFS_I (btree_inode)->io_tree;int ret; buf =btrfs_find_create_tree_block (fs_info, bytenr);
@@ -1063,8 +1058,7 @@ int reada_tree_block_flagged(struct btrfs_fs_info *fs_info, u64 bytenr,set_bit (EXTENT_BUFFER_READAHEAD , &buf->bflags); - ret =read_extent_buffer_pages (io_tree, buf,WAIT_PAGE_LOCK , - mirror_num); + ret =read_extent_buffer_pages (buf,WAIT_PAGE_LOCK , mirror_num);if (ret) {free_extent_buffer_stale (buf);return ret;
fs/btrfs/extent_io.c +2 -2
@@ -5330,8 +5330,7 @@ void set_extent_buffer_uptodate(struct extent_buffer *eb) } } -int read_extent_buffer_pages (struct extent_io_tree *tree, -struct extent_buffer *eb,int wait,int mirror_num) +int read_extent_buffer_pages (struct extent_buffer *eb,int wait,int mirror_num) {int i;struct page *page;
@@ -5343,6 +5342,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,unsigned long num_reads =0 ;struct bio *bio =NULL ;unsigned long bio_flags =0 ; +struct extent_io_tree *tree = &BTRFS_I (eb->fs_info->btree_inode)->io_tree;if (test_bit (EXTENT_BUFFER_UPTODATE , &eb->bflags))return 0 ;
fs/btrfs/extent_io.h +1 -2
@@ -433,8 +433,7 @@ void free_extent_buffer_stale(struct extent_buffer *eb);#define WAIT_NONE 0#define WAIT_COMPLETE 1#define WAIT_PAGE_LOCK 2 -int read_extent_buffer_pages (struct extent_io_tree *tree, -struct extent_buffer *eb,int wait, +int read_extent_buffer_pages (struct extent_buffer *eb,int wait,int mirror_num);void wait_on_extent_buffer_writeback (struct extent_buffer *eb);
Signature · 1 line
2.17.1
Re: [PATCH 3/6] btrfs: Remove 'tree' argument from read_extent_buffer_pages
Looks good,
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 4/6 btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
In reply to Nikolay BorisovBuffered writeback always calls btrfs_csum_one_bio with the last 2 arguments being 0 irrespective of what the bio_offset has been passed to btrfs_submit_bio_start. Make this apparent by explicitly passing 0 for bio_offset when calling btrfs_wq_submit_bio from btrfs_submit_bio_hook. This will allow for further simplifications down the line. No functional changes.
--- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
@@ -1991,8 +1991,7 @@ static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, goto mapit;/* we're doing a write, do the async checksumming */ ret =btrfs_wq_submit_bio (fs_info, bio, mirror_num, bio_flags, - bio_offset, inode, - btrfs_submit_bio_start); +0 , inode, btrfs_submit_bio_start); goto out; }else if (!skip_sum) { ret =btrfs_csum_one_bio (inode, bio,0 ,0 );
Signature · 1 line
2.17.1
Re: [PATCH 4/6] btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
Quoted 18 lines · Nikolay Borisov
Buffered writeback always calls
btrfs_csum_one_biowith the last 2 arguments being 0 irrespective of what thebio_offsethas been passed tobtrfs_submit_bio_start. Make this apparent by explicitly passing 0 forbio_offsetwhen callingbtrfs_wq_submit_biofrombtrfs_submit_bio_hook. This will allow for further simplifications down the line. No functional changes.Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/inode.c +0
-0
fs/btrfs/inode.c static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, · line 1997
Quoted 9 lines
fs/btrfs/inode.c +1
-2@@ -1991,8 +1991,7 @@ static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio, goto mapit;/* we're doing a write, do the async checksumming */ ret =btrfs_wq_submit_bio (fs_info, bio, mirror_num, bio_flags, - bio_offset, inode, - btrfs_submit_bio_start); +0 , inode, btrfs_submit_bio_start); goto out; }else if (!skip_sum) { ret =btrfs_csum_one_bio (inode, bio,0 ,0 );
I think we can also kill 'async_submit_bio::bio_offset' as no other value than 0 is ever used.
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 4/6] btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
Quoted 2 lines · Johannes Thumshirn
I think we can also kill '
async_submit_bio::bio_offset' as no other value than 0 is ever used.
Right, this is what the following patches do. Ignore this.
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 4/6] btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
Quoted 5 lines · Johannes Thumshirn
Quoted 2 lines · Johannes Thumshirn
I think we can also kill '
async_submit_bio::bio_offset' as no other value than 0 is ever used.Right, this is what the following patches do. Ignore this.
Actually they don't particularly kill async_submit_bio::bio_offset. But it could be done :)
Quoted 2 lines
Johannes Thumshirn
Reviewed-byRe: [PATCH 4/6] btrfs: Pass 0 for bio_offset to btrfs_wq_submit_bio
Quoted 11 lines · Nikolay Borisov
Quoted 5 lines · Johannes Thumshirn
Quoted 2 lines · Johannes Thumshirn
I think we can also kill '
async_submit_bio::bio_offset' as no other value than 0 is ever used.Right, this is what the following patches do. Ignore this.
Actually they don't particularly kill
async_submit_bio::bio_offset. But it could be done :)
Yes but that's a follow up I guess. Anyways,
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 5/6 btrfs: Always pass 0 bio_offset for btree_submit_bio_start
In reply to Nikolay BorisovThe btree submit hook queues the async csum and forwards the bio_offset parameter passed to btree_submit_bio_hook. This is redundant since btree_submit_bio_start calls btree_csum_one_bio which doesn't use the offset at all. No functional changes.
--- fs/btrfs/disk-io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/disk-io.c +1 -2
@@ -913,8 +913,7 @@ static blk_status_t btree_submit_bio_hook(struct inode *inode, struct bio *bio,* checksumming can happen in parallel across all CPUs */ ret =btrfs_wq_submit_bio (fs_info, bio, mirror_num,0 , - bio_offset, inode, - btree_submit_bio_start); +0 , inode, btree_submit_bio_start); }if (ret)
Signature · 1 line
2.17.1
Re: [PATCH 5/6] btrfs: Always pass 0 bio_offset for btree_submit_bio_start
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 6/6 btrfs: Remove bio_offset argument from submit_bio_hook
In reply to Nikolay BorisovNone of the implementers of the submit_bio_hook use the bio_offset parameter, simply remove it. No functional changes.
--- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent_io.c | 6 ++---- fs/btrfs/extent_io.h | 3 +-- fs/btrfs/inode.c | 5 +++-- 4 files changed, 8 insertions(+), 10 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -885,8 +885,8 @@ static int check_async_write(struct btrfs_inode *bi) }static blk_status_t btree_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);int async =check_async_write (BTRFS_I (inode));
fs/btrfs/extent_io.c +2 -4
@@ -152,16 +152,14 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,struct bio_vec *bvec =bio_last_bvec_all (bio);struct bio_vec bv;struct extent_io_tree *tree = bio->bi_private; -u64 start;mp_bvec_last_segment (bvec, &bv); - start =page_offset (bv.bv_page) + bv.bv_offset; bio->bi_private =NULL ;if (tree->ops) ret = tree->ops->submit_bio_hook (tree->private_data, bio, - mirror_num, bio_flags, start); + mirror_num, bio_flags);else btrfsic_submit_bio (bio);
@@ -2546,7 +2544,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, read_mode, failrec->this_mirror, failrec->in_validation); status = tree->ops->submit_bio_hook (tree->private_data, bio, failrec->this_mirror, - failrec->bio_flags,0 ); + failrec->bio_flags);if (status) {free_io_failure (failure_tree, tree, failrec);bio_put (bio);
fs/btrfs/extent_io.h +1 -2
@@ -105,8 +105,7 @@ struct extent_io_ops {* pointer will be called unconditionally. */ blk_status_t (*submit_bio_hook)(struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset); +int mirror_num,unsigned long bio_flags);int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio,u64 phy_offset,struct page *page,u64 start,u64 end,int mirror);
fs/btrfs/inode.c +3 -2
@@ -1954,8 +1954,9 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,* c-3) otherwise: async submit */ static blk_status_t btrfs_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) + {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;
Signature · 1 line
2.17.1
Re: [PATCH 6/6] btrfs: Remove bio_offset argument from submit_bio_hook
Quoted 31 lines · Nikolay Borisov
None of the implementers of the
submit_bio_hookuse thebio_offsetparameter, simply remove it. No functional changes.Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent_io.c | 6 ++---- fs/btrfs/extent_io.h | 3 +-- fs/btrfs/inode.c | 5 +++-- 4 files changed, 8 insertions(+), 10 deletions(-)fs/btrfs/disk-io.c +2
-2@@ -885,8 +885,8 @@ static int check_async_write(struct btrfs_inode *bi) }static blk_status_t btree_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);int async =check_async_write (BTRFS_I (inode));fs/btrfs/extent_io.c +0
-0
fs/btrfs/extent_io.c static int __must_check submit_one_bio(struct bio *bio, int mirror_num, · line 158
Quoted 7 lines
fs/btrfs/extent_io.c +0
-2@@ -152,16 +152,14 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,struct bio_vec *bvec =bio_last_bvec_all (bio);struct bio_vec bv;struct extent_io_tree *tree = bio->bi_private; -u64 start;mp_bvec_last_segment (bvec, &bv); - start =page_offset (bv.bv_page) + bv.bv_offset;
This hunk could be extended even further by removing bv/bvec definitions as well as the call to mp_bvec_last_segment. Shall I resend or are you going to fold this change David?
Quoted 50 lines
fs/btrfs/extent_io.c +2
-2bio->bi_private =NULL ;if (tree->ops) ret = tree->ops->submit_bio_hook (tree->private_data, bio, - mirror_num, bio_flags, start); + mirror_num, bio_flags);else btrfsic_submit_bio (bio);@@ -2546,7 +2544,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, read_mode, failrec->this_mirror, failrec->in_validation); status = tree->ops->submit_bio_hook (tree->private_data, bio, failrec->this_mirror, - failrec->bio_flags,0 ); + failrec->bio_flags);if (status) {free_io_failure (failure_tree, tree, failrec);bio_put (bio);fs/btrfs/extent_io.h +1
-2@@ -105,8 +105,7 @@ struct extent_io_ops {* pointer will be called unconditionally. */ blk_status_t (*submit_bio_hook)(struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset); +int mirror_num,unsigned long bio_flags);int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio,u64 phy_offset,struct page *page,u64 start,u64 end,int mirror);fs/btrfs/inode.c +3
-2@@ -1954,8 +1954,9 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,* c-3) otherwise: async submit */ static blk_status_t btrfs_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) + {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;
PATCH v2 1/1 btrfs: Remove bio_offset argument from submit_bio_hook
In reply to Nikolay BorisovNone of the implementers of the submit_bio_hook use the bio_offset parameter, simply remove it. No functional changes.
---
Change since v1:
* Remove code dealing with bio internals in submit_one_bio.
fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent_io.c | 10 ++-------- fs/btrfs/extent_io.h | 3 +-- fs/btrfs/inode.c | 5 +++-- 4 files changed, 8 insertions(+), 14 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -885,8 +885,8 @@ static int check_async_write(struct btrfs_inode *bi) }static blk_status_t btree_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);int async =check_async_write (BTRFS_I (inode));
fs/btrfs/extent_io.c +2 -8
@@ -149,19 +149,13 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num, unsigned long bio_flags) {blk_status_t ret =0 ; -struct bio_vec *bvec =bio_last_bvec_all (bio); -struct bio_vec bv;struct extent_io_tree *tree = bio->bi_private; -u64 start; - -mp_bvec_last_segment (bvec, &bv); - start =page_offset (bv.bv_page) + bv.bv_offset; bio->bi_private =NULL ;if (tree->ops) ret = tree->ops->submit_bio_hook (tree->private_data, bio, - mirror_num, bio_flags, start); + mirror_num, bio_flags);else btrfsic_submit_bio (bio);
@@ -2546,7 +2540,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, read_mode, failrec->this_mirror, failrec->in_validation); status = tree->ops->submit_bio_hook (tree->private_data, bio, failrec->this_mirror, - failrec->bio_flags,0 ); + failrec->bio_flags);if (status) {free_io_failure (failure_tree, tree, failrec);bio_put (bio);
fs/btrfs/extent_io.h +1 -2
@@ -105,8 +105,7 @@ struct extent_io_ops {* pointer will be called unconditionally. */ blk_status_t (*submit_bio_hook)(struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset); +int mirror_num,unsigned long bio_flags);int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio,u64 phy_offset,struct page *page,u64 start,u64 end,int mirror);
fs/btrfs/inode.c +3 -2
@@ -1954,8 +1954,9 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,* c-3) otherwise: async submit */ static blk_status_t btrfs_submit_bio_hook (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 bio_offset) +int mirror_num, +unsigned long bio_flags) + {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;
Signature · 1 line
2.17.1
Re: [PATCH v2] btrfs: Remove bio_offset argument from submit_bio_hook
Looks good,
Here you could also add the removal of bio_offset from async_submit_bio.
Signature · 6 lines
Johannes Thumshirn SUSE Labs Filesystems [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH v2] btrfs: Remove bio_offset argument from submit_bio_hook
Quoted 5 lines · Johannes Thumshirn
Looks good,
Reviewed-by Johannes Thumshirn <[email protected]>Here you could also add the removal of
bio_offsetfromasync_submit_bio.
Actually no, we can't since for DIO case we do use it from:btrfs_submit_dio_bio->btrfs_wq_submit_bio
Quoted 30 lines · Nikolay Borisov
I've been taking a look at the
submit_bio_hooket al and I saw some opportunities for improvement. First I begin by simplifying the definition ofsubmit_bio_hookcallback and making one of its arguments explicit.Patch 3 removes a redundant
extent_io_treeargument that was passed through several layers of functions and ultimately made it somewhat cumbersome to reason whatextent_io_treeis being used.Patch 4 and 5 hardcode a 0 being passed for the
bio_offsetparameter to btrfs_submit_bio_start/btree_submit_bio_start since it only matters for DIO.Patch 6 finally does away with the
bio_offsetparameter ofsubmit_bio_hook.Here is the output of bloat-o-meter for posterity:
add/remove: 0/0 grow/shrink: 4/7 up/down: 48/-319 (-271)
Function old new delta read_extent_buffer_pages 784 822 +38 btrfs_add_ordered_sum 100 104 +4 btrfs_submit_bio_hook 364 367 +3 btree_submit_bio_hook 175 178 +3 end_bio_extent_readpage 2119 2116 -3 btrfs_reloc_clone_csums 272 262 -10 btrfs_csum_one_bio 1358 1348 -10 btree_read_extent_buffer_pages 282 272 -10 readahead_tree_block 73 55 -18 reada_tree_block_flagged 194 165 -29
submit_one_bio313 74 -239
Total: Before=1072719, After=1072448, chg -0.03%
Quoted 7 lines
Nikolay Borisov (6):
btrfs: Define submit_bio_hook's type directly
btrfs: Changesubmit_bio_hookto taking an inode directly
btrfs: Remove 'tree' argument fromread_extent_buffer_pages
btrfs: Pass 0 forbio_offsettobtrfs_wq_submit_bio
btrfs: Always pass 0bio_offsetforbtree_submit_bio_start
btrfs: Removebio_offsetargument fromsubmit_bio_hook
Patchset added to misc-next, thanks.