minor bio submission cleanups
Hi all,
this series cleans up a few loose ends in the btrfs bio submission path.
Diffstat:
compression.c | 11 +++++------ compression.h | 4 ++-- ctree.h | 5 ++--- disk-io.c | 26 ++++++++++---------------- disk-io.h | 4 ++-- extent_io.c | 39 +++++++++++++++++++++++++++++++++++---- extent_io.h | 18 ++---------------- inode.c | 49 ++++++++++--------------------------------------- 8 files changed, 68 insertions(+), 88 deletions(-)
PATCH 1/5 btrfs: move btrfs_readpage to extent_io.c
Keep btrfs_readpage next to btrfs_do_readpage and the other address space operations. This allows to keep submit_one_bio and struct btrfs_bio_ctrl file local in extent_io.c.
--- fs/btrfs/ctree.h | 1 - fs/btrfs/extent_io.c | 36 ++++++++++++++++++++++++++++++++++-- fs/btrfs/extent_io.h | 16 +--------------- fs/btrfs/inode.c | 20 -------------------- 4 files changed, 35 insertions(+), 38 deletions(-)
fs/btrfs/ctree.h +0 -1
@@ -3312,7 +3312,6 @@ void btrfs_split_delalloc_extent(struct inode *inode, struct extent_state *orig, u64 split);void btrfs_set_range_writeback (struct btrfs_inode *inode,u64 start,u64 end);vm_fault_t btrfs_page_mkwrite (struct vm_fault *vmf); -int btrfs_readpage (struct file *file,struct page *page);void btrfs_evict_inode (struct inode *inode);int btrfs_write_inode (struct inode *inode,struct writeback_control *wbc);struct inode *btrfs_alloc_inode (struct super_block *sb);
fs/btrfs/extent_io.c +34 -2
@@ -137,6 +137,17 @@ struct tree_entry {struct rb_node rb_node; }; +/* +* Structure to record info about the bio being assembled, and other info like +* how many bytes are there before stripe/ordered extent boundary. +*/ +struct btrfs_bio_ctrl { +struct bio *bio; +unsigned long bio_flags; +u32 len_to_stripe_boundary; +u32 len_to_oe_boundary; +}; +struct extent_page_data {struct btrfs_bio_ctrl bio_ctrl;/* tells writepage not to lock the state bits for this range
@@ -166,7 +177,8 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,return ret; } -void submit_one_bio (struct bio *bio,int mirror_num,unsigned long bio_flags) +static void submit_one_bio (struct bio *bio,int mirror_num, +unsigned long bio_flags) {struct extent_io_tree *tree = bio->bi_private;
@@ -3604,7 +3616,7 @@ __get_extent_map(struct inode *inode, struct page *page, size_t pg_offset,* XXX JDM: This needs looking at to ensure proper page locking * return 0 on success, otherwise return error */ -int btrfs_do_readpage (struct page *page,struct extent_map **em_cached, +static int btrfs_do_readpage (struct page *page,struct extent_map **em_cached,struct btrfs_bio_ctrl *bio_ctrl,unsigned int read_flags,u64 *prev_em_start) {
@@ -3793,6 +3805,26 @@ int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,return ret; } +int btrfs_readpage (struct file *file,struct page *page) +{ +struct btrfs_inode *inode =BTRFS_I (page->mapping->host); +u64 start =page_offset (page); +u64 end = start +PAGE_SIZE -1 ; +struct btrfs_bio_ctrl bio_ctrl = {0 }; +int ret; + +btrfs_lock_and_flush_ordered_range (inode, start, end,NULL ); + + ret =btrfs_do_readpage (page,NULL , &bio_ctrl,0 ,NULL ); +/* +* If btrfs_do_readpage() failed we will want to submit the assembled +* bio to do the cleanup. +*/ +if (bio_ctrl.bio) +submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.bio_flags); +return ret; +} + static inline void contiguous_readpages(struct page *pages[], int nr_pages, u64 start, u64 end, struct extent_map **em_cached,
fs/btrfs/extent_io.h +1 -15
@@ -102,17 +102,6 @@ struct extent_buffer {#endif }; -/* -* Structure to record info about the bio being assembled, and other info like -* how many bytes are there before stripe/ordered extent boundary. -*/ -struct btrfs_bio_ctrl { -struct bio *bio; -unsigned long bio_flags; -u32 len_to_stripe_boundary; -u32 len_to_oe_boundary; -}; -/* * Structure to record how many bytes and which ranges are set/cleared */
@@ -178,10 +167,7 @@ typedef struct extent_map *(get_extent_t)(struct btrfs_inode *inode,int try_release_extent_mapping (struct page *page,gfp_t mask);int try_release_extent_buffer (struct page *page); -void submit_one_bio (struct bio *bio,int mirror_num,unsigned long bio_flags); -int btrfs_do_readpage (struct page *page,struct extent_map **em_cached, -struct btrfs_bio_ctrl *bio_ctrl, -unsigned int read_flags,u64 *prev_em_start); +int btrfs_readpage (struct file *file,struct page *page);int extent_write_full_page (struct page *page,struct writeback_control *wbc);int extent_write_locked_range (struct inode *inode,u64 start,u64 end); int extent_writepages(struct address_space *mapping,
fs/btrfs/inode.c +0 -20
@@ -8147,26 +8147,6 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,return extent_fiemap (BTRFS_I (inode), fieinfo, start, len); } -int btrfs_readpage (struct file *file,struct page *page) -{ -struct btrfs_inode *inode =BTRFS_I (page->mapping->host); -u64 start =page_offset (page); -u64 end = start +PAGE_SIZE -1 ; -struct btrfs_bio_ctrl bio_ctrl = {0 }; -int ret; - -btrfs_lock_and_flush_ordered_range (inode, start, end,NULL ); - - ret =btrfs_do_readpage (page,NULL , &bio_ctrl,0 ,NULL ); -/* -* If btrfs_do_readpage() failed we will want to submit the assembled -* bio to do the cleanup. -*/ -if (bio_ctrl.bio) -submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.bio_flags); -return ret; -} -static int btrfs_writepage (struct page *page,struct writeback_control *wbc) {struct inode *inode = page->mapping->host;
Signature · 1 line
2.30.2
PATCH 2/5 btrfs: remove the unused bio_flags argument to btrfs_submit_metadata_bio
In reply to Christoph HellwigThis argument is unused since commit 953651eb308f ("btrfs: factor out helper adding a page to bio") and commit 1b36294a6cd5 ("btrfs: call submit_bio_hook directly for metadata pages") reworked the way metadata bio submission is handled.
--- fs/btrfs/disk-io.c | 2 +- fs/btrfs/disk-io.h | 2 +- fs/btrfs/extent_io.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/disk-io.c +1 -1
@@ -921,7 +921,7 @@ static bool should_async_write(struct btrfs_fs_info *fs_info, }blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +int mirror_num) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);blk_status_t ret;
fs/btrfs/disk-io.h +1 -1
@@ -88,7 +88,7 @@ int btrfs_validate_metadata_buffer(struct btrfs_bio *bbio, struct page *page, u64 start, u64 end, int mirror);blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +int mirror_num);#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct btrfs_root *btrfs_alloc_dummy_root (struct btrfs_fs_info *fs_info);#endif
fs/btrfs/extent_io.c +1 -2
@@ -191,8 +191,7 @@ static void submit_one_bio(struct bio *bio, int mirror_num,btrfs_submit_data_bio (tree->private_data, bio, mirror_num, bio_flags); else - btrfs_submit_metadata_bio(tree->private_data, bio, -mirror_num ,bio_flags ); + btrfs_submit_metadata_bio(tree->private_data, bio, mirror_num);/* * Above submission hooks will handle the error by ending the bio, * which will do the cleanup properly. So here we should not return
Signature · 1 line
2.30.2
Re: [PATCH 2/5] btrfs: remove the unused bio_flags argument to btrfs_submit_metadata_bio
Quoted 6 lines · Christoph Hellwig
This argument is unused since commit
953651eb308f("btrfs: factor out helper adding a page to bio") and commit1b36294a6cd5("btrfs: callsubmit_bio_hookdirectly for metadata pages") reworked the way metadata bio submission is handled.Signed-off-by Christoph Hellwig <[email protected]>
Thanks,
Qu
Quoted 46 lines
--- fs/btrfs/disk-io.c | 2 +- fs/btrfs/disk-io.h | 2 +- fs/btrfs/extent_io.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-)fs/btrfs/disk-io.c +1
-1@@ -921,7 +921,7 @@ static bool should_async_write(struct btrfs_fs_info *fs_info, }blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +int mirror_num) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);blk_status_t ret;fs/btrfs/disk-io.h +1
-1@@ -88,7 +88,7 @@ int btrfs_validate_metadata_buffer(struct btrfs_bio *bbio, struct page *page, u64 start, u64 end, int mirror);blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +int mirror_num);#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct btrfs_root *btrfs_alloc_dummy_root (struct btrfs_fs_info *fs_info);#endif fs/btrfs/extent_io.c +1
-2@@ -191,8 +191,7 @@ static void submit_one_bio(struct bio *bio, int mirror_num,btrfs_submit_data_bio (tree->private_data, bio, mirror_num, bio_flags); else - btrfs_submit_metadata_bio(tree->private_data, bio, -mirror_num ,bio_flags ); + btrfs_submit_metadata_bio(tree->private_data, bio, mirror_num);/* * Above submission hooks will handle the error by ending the bio, * which will do the cleanup properly. So here we should not return
PATCH 3/5 btrfs: do not return errors from btrfs_submit_metadata_bio
In reply to Christoph Hellwigbtrfs_submit_metadata_bio already calls ->bi_end_io on error and the caller must ignore the return value, so remove it.
--- fs/btrfs/disk-io.c | 26 ++++++++++---------------- fs/btrfs/disk-io.h | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-)
fs/btrfs/disk-io.c +10 -16
@@ -920,8 +920,8 @@ static bool should_async_write(struct btrfs_fs_info *fs_info,return true; } -blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num) +void btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, +int mirror_num) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);blk_status_t ret;
@@ -933,14 +933,12 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,*/ ret =btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_METADATA ); -if (ret) - goto out_w_error; - ret =btrfs_map_bio (fs_info, bio, mirror_num); +if (!ret) + ret =btrfs_map_bio (fs_info, bio, mirror_num); }else if (!should_async_write (fs_info,BTRFS_I (inode))) { ret =btree_csum_one_bio (bio); -if (ret) - goto out_w_error; - ret =btrfs_map_bio (fs_info, bio, mirror_num); +if (!ret) + ret =btrfs_map_bio (fs_info, bio, mirror_num); }else {/* * kthread helpers are used to submit writes so that
@@ -950,14 +948,10 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, 0, btree_submit_bio_start); } -if (ret) - goto out_w_error; -return 0 ; - -out_w_error: - bio->bi_status = ret; -bio_endio (bio); -return ret; +if (ret) { + bio->bi_status = ret; +bio_endio (bio); + } }#ifdef CONFIG_MIGRATION
fs/btrfs/disk-io.h +2 -2
@@ -87,8 +87,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,int btrfs_validate_metadata_buffer (struct btrfs_bio *bbio,struct page *page,u64 start,u64 end,int mirror); -blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num); +void btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, +int mirror_num);#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct btrfs_root *btrfs_alloc_dummy_root (struct btrfs_fs_info *fs_info);#endif
Signature · 1 line
2.30.2
Re: [PATCH 3/5] btrfs: do not return errors from btrfs_submit_metadata_bio
Quoted 2 lines · Christoph Hellwig
btrfs_submit_metadata_bioalready calls ->bi_end_io on error and the caller must ignore the return value, so remove it.
I think your cleanup is doing the first step towards a proper defined behavior on how we should handle bios: just fire and forget.
Thanks,
Qu
Quoted 75 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/btrfs/disk-io.c | 26 ++++++++++---------------- fs/btrfs/disk-io.h | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-)fs/btrfs/disk-io.c +10
-16@@ -920,8 +920,8 @@ static bool should_async_write(struct btrfs_fs_info *fs_info,return true; } -blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num) +void btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, +int mirror_num) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);blk_status_t ret;@@ -933,14 +933,12 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,*/ ret =btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_METADATA ); -if (ret) - goto out_w_error; - ret =btrfs_map_bio (fs_info, bio, mirror_num); +if (!ret) + ret =btrfs_map_bio (fs_info, bio, mirror_num); }else if (!should_async_write (fs_info,BTRFS_I (inode))) { ret =btree_csum_one_bio (bio); -if (ret) - goto out_w_error; - ret =btrfs_map_bio (fs_info, bio, mirror_num); +if (!ret) + ret =btrfs_map_bio (fs_info, bio, mirror_num); }else {/* * kthread helpers are used to submit writes so that @@ -950,14 +948,10 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, 0, btree_submit_bio_start); } -if (ret) - goto out_w_error; -return 0 ; - -out_w_error: - bio->bi_status = ret; -bio_endio (bio); -return ret; +if (ret) { + bio->bi_status = ret; +bio_endio (bio); + } }#ifdef CONFIG_MIGRATION fs/btrfs/disk-io.h +2
-2@@ -87,8 +87,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,int btrfs_validate_metadata_buffer (struct btrfs_bio *bbio,struct page *page,u64 start,u64 end,int mirror); -blk_status_t btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, -int mirror_num); +void btrfs_submit_metadata_bio (struct inode *inode,struct bio *bio, +int mirror_num);#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS struct btrfs_root *btrfs_alloc_dummy_root (struct btrfs_fs_info *fs_info);#endif
PATCH 4/5 btrfs: do not return errors from btrfs_submit_compressed_read
In reply to Christoph Hellwigbtrfs_submit_compressed_read already calls ->bi_end_io on error and the caller must ignore the return value, so remove it.
--- fs/btrfs/compression.c | 11 +++++------ fs/btrfs/compression.h | 4 ++-- fs/btrfs/inode.c | 8 +++----- 3 files changed, 10 insertions(+), 13 deletions(-)
fs/btrfs/compression.c +5 -6
@@ -801,8 +801,8 @@ static noinline int add_ra_bio_pages(struct inode *inode,* After the compressed pages are read, we copy the bytes into the * bio we were passed and then call the bio end_io calls */ -blk_status_t btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +void btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct extent_map_tree *em_tree;
@@ -947,7 +947,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, comp_bio =NULL ; } } -return BLK_STS_OK ; +return ; fail:if (cb->compressed_pages) {
@@ -963,7 +963,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,free_extent_map (em); bio->bi_status = ret;bio_endio (bio); -return ret; +return ; finish_cb:if (comp_bio) { comp_bio->bi_status = ret;
@@ -971,7 +971,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, }/* All bytes of @cb is submitted, endio will free @cb */ if (cur_disk_byte == disk_bytenr + compressed_len) -return ret; +return ;wait_var_event (cb,refcount_read (&cb->pending_sectors) == (disk_bytenr + compressed_len - cur_disk_byte) >>
@@ -983,7 +983,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,ASSERT (refcount_read (&cb->pending_sectors));/* Now we are the only one referring @cb, can finish it safely. */ finish_compressed_bio_read (cb); -return ret; }/*
fs/btrfs/compression.h +2 -2
@@ -102,8 +102,8 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,unsigned int write_flags, struct cgroup_subsys_state *blkcg_css, bool writeback); -blk_status_t btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +void btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags);unsigned int btrfs_compress_str2level (unsigned int type,const char *str);
fs/btrfs/inode.c +3 -5
@@ -2618,10 +2618,9 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,* the bio if there were any errors, so just return * here. */ - ret =btrfs_submit_compressed_read (inode, bio, - mirror_num, - bio_flags); - goto out_no_endio; +btrfs_submit_compressed_read (inode, bio, mirror_num, + bio_flags); +return BLK_STS_OK ; }else {/* * Lookup bio sums does extra checks around whether we
@@ -2655,7 +2654,6 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio, bio->bi_status = ret;bio_endio (bio); } -out_no_endio:return ret; }
Signature · 1 line
2.30.2
Re: [PATCH 4/5] btrfs: do not return errors from btrfs_submit_compressed_read
Quoted 4 lines · Christoph Hellwig
btrfs_submit_compressed_readalready calls ->bi_end_io on error and the caller must ignore the return value, so remove it.Signed-off-by Christoph Hellwig <[email protected]>
The patch itself is fine.
Although more such cleanups are going to bring some question on how those bio handling functions should behavior.
More and more bio submit functions are returning void and endio of the bio.
But there are still quite some not doing this, like btrfs_map_bio().
I'm wondering at which boundary we should return void and handle everything in-house?
Thanks,
Qu
Quoted 97 lines
--- fs/btrfs/compression.c | 11 +++++------ fs/btrfs/compression.h | 4 ++-- fs/btrfs/inode.c | 8 +++----- 3 files changed, 10 insertions(+), 13 deletions(-)fs/btrfs/compression.c +5
-6@@ -801,8 +801,8 @@ static noinline int add_ra_bio_pages(struct inode *inode,* After the compressed pages are read, we copy the bytes into the * bio we were passed and then call the bio end_io calls */ -blk_status_t btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +void btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct extent_map_tree *em_tree;@@ -947,7 +947,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, comp_bio =NULL ; } } -return BLK_STS_OK ; +return ; fail:if (cb->compressed_pages) {@@ -963,7 +963,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,free_extent_map (em); bio->bi_status = ret;bio_endio (bio); -return ret; +return ; finish_cb:if (comp_bio) { comp_bio->bi_status = ret;@@ -971,7 +971,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, }/* All bytes of @cb is submitted, endio will free @cb */ if (cur_disk_byte == disk_bytenr + compressed_len) -return ret; +return ;wait_var_event (cb,refcount_read (&cb->pending_sectors) == (disk_bytenr + compressed_len - cur_disk_byte) >>@@ -983,7 +983,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,ASSERT (refcount_read (&cb->pending_sectors));/* Now we are the only one referring @cb, can finish it safely. */ finish_compressed_bio_read (cb); -return ret; }/* fs/btrfs/compression.h +2
-2@@ -102,8 +102,8 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,unsigned int write_flags, struct cgroup_subsys_state *blkcg_css, bool writeback); -blk_status_t btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +void btrfs_submit_compressed_read (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags);unsigned int btrfs_compress_str2level (unsigned int type,const char *str);fs/btrfs/inode.c +3
-5@@ -2618,10 +2618,9 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,* the bio if there were any errors, so just return * here. */ - ret =btrfs_submit_compressed_read (inode, bio, - mirror_num, - bio_flags); - goto out_no_endio; +btrfs_submit_compressed_read (inode, bio, mirror_num, + bio_flags); +return BLK_STS_OK ; }else {/* * Lookup bio sums does extra checks around whether we @@ -2655,7 +2654,6 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio, bio->bi_status = ret;bio_endio (bio); } -out_no_endio:return ret; }
Re: [PATCH 4/5] btrfs: do not return errors from btrfs_submit_compressed_read
Quoted 6 lines · Qu Wenruo
More and more bio submit functions are returning void and endio of the bio.
But there are still quite some not doing this, like
btrfs_map_bio().I'm wondering at which boundary we should return void and handle everything in-house?
I don't think it is quite clear. All the I/O errors with a bio should be handled through end_io, and we already have that, module the compressed case with it's extra layer of bios. Now at what point we call the endio handler is a different question. Duplicating it everywhere is a bit annoying, so having some low-level helpers that just return an error might be useful. I plan a fair amount of refactoring around btrfs_map_bio, so I'll see if lifting the end_io call into it might or might no make sense while I'm at it.
Re: [PATCH 4/5] btrfs: do not return errors from btrfs_submit_compressed_read
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Qu Wenruo
More and more bio submit functions are returning void and endio of the bio.
But there are still quite some not doing this, like
btrfs_map_bio().I'm wondering at which boundary we should return void and handle everything in-house?
Quoted 8 lines
I don't think it is quite clear. All the I/O errors with a bio should be handled through
end_io, and we already have that, module the compressed case with it's extra layer of bios. Now at what point we call the endio handler is a different question. Duplicating it everywhere is a bit annoying, so having some low-level helpers that just return an error might be useful. I plan a fair amount of refactoring aroundbtrfs_map_bio, so I'll see if lifting theend_iocall into it might or might no make sense while I'm at it.
Great to know that.
Thanks,
Qu
Re: [PATCH 4/5] btrfs: do not return errors from btrfs_submit_compressed_read
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
Quoted 6 lines · Qu Wenruo
More and more bio submit functions are returning void and endio of the bio.
But there are still quite some not doing this, like
btrfs_map_bio().I'm wondering at which boundary we should return void and handle everything in-house?
Quoted 8 lines
I don't think it is quite clear. All the I/O errors with a bio should be handled through
end_io, and we already have that, module the compressed case with it's extra layer of bios. Now at what point we call the endio handler is a different question. Duplicating it everywhere is a bit annoying, so having some low-level helpers that just return an error might be useful. I plan a fair amount of refactoring aroundbtrfs_map_bio, so I'll see if lifting theend_iocall into it might or might no make sense while I'm at it.
Please try to limit number of patches in a series to 10ish, this works much better when there's something to change in the early patches or everything is fine and it will get merged for testing. Also there are always other patches in flux so this helps me to schedule. Thanks.
PATCH 5/5 btrfs: do not return errors from submit_bio_hook_t instances
In reply to Christoph HellwigBoth btrfs_repair_one_sector and submit_bio_one as the direct caller of one of the instances ignore errors as they expect the methods themselves to call ->bi_end_io on error. Remove the unused and dangerous return value.
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 23 ++++++++--------------- 3 files changed, 11 insertions(+), 18 deletions(-)
fs/btrfs/ctree.h +2 -2
@@ -3249,8 +3249,8 @@ void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_sizu64 btrfs_file_extent_end (const struct btrfs_path *path);/* inode.c */ -blk_status_t btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags);unsigned int btrfs_verify_data_csum (struct btrfs_bio *bbio,u32 bio_offset,struct page *page,u64 start,u64 end);
fs/btrfs/extent_io.h +1 -1
@@ -71,7 +71,7 @@ struct btrfs_fs_info;struct io_failure_record ;struct extent_io_tree ; -typedef blk_status_t (submit_bio_hook_t )(struct inode *inode,struct bio *bio, +typedef void (submit_bio_hook_t )(struct inode *inode,struct bio *bio,int mirror_num,unsigned long bio_flags);
fs/btrfs/inode.c +8 -15
@@ -2581,9 +2581,8 @@ static blk_status_t extract_ordered_extent(struct btrfs_inode *inode,* * c-3) otherwise: async submit */ -blk_status_t btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) - +void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, +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;
@@ -2620,7 +2619,7 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,*/ btrfs_submit_compressed_read (inode, bio, mirror_num, bio_flags); -return BLK_STS_OK ; +return ; }else {/* * Lookup bio sums does extra checks around whether we
@@ -2654,7 +2653,6 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio, bio->bi_status = ret;bio_endio (bio); } -return ret; }/*
@@ -7798,25 +7796,20 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)kfree (dip); } -static blk_status_t submit_dio_repair_bio (struct inode *inode,struct bio *bio, -int mirror_num, -unsigned long bio_flags) +static void submit_dio_repair_bio (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags) {struct btrfs_dio_private *dip = bio->bi_private;struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb); -blk_status_t ret;BUG_ON (bio_op (bio) ==REQ_OP_WRITE ); - ret =btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_DATA ); -if (ret) -return ret; +if (btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_DATA )) +return ;refcount_inc (&dip->refs); - ret =btrfs_map_bio (fs_info, bio, mirror_num); -if (ret) +if (btrfs_map_bio (fs_info, bio, mirror_num))refcount_dec (&dip->refs); -return ret; } static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
Signature · 1 line
2.30.2
Re: [PATCH 5/5] btrfs: do not return errors from submit_bio_hook_t instances
Quoted 6 lines · Christoph Hellwig
Both
btrfs_repair_one_sectorandsubmit_bio_oneas the direct caller of one of the instances ignore errors as they expect the methods themselves to call ->bi_end_io on error. Remove the unused and dangerous return value.Signed-off-by Christoph Hellwig <[email protected]>
Thanks,
Qu
Quoted 98 lines
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 23 ++++++++--------------- 3 files changed, 11 insertions(+), 18 deletions(-)fs/btrfs/ctree.h +2
-2@@ -3249,8 +3249,8 @@ void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_sizu64 btrfs_file_extent_end (const struct btrfs_path *path);/* inode.c */ -blk_status_t btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags);unsigned int btrfs_verify_data_csum (struct btrfs_bio *bbio,u32 bio_offset,struct page *page,u64 start,u64 end);fs/btrfs/extent_io.h +1
-1@@ -71,7 +71,7 @@ struct btrfs_fs_info;struct io_failure_record ;struct extent_io_tree ; -typedef blk_status_t (submit_bio_hook_t )(struct inode *inode,struct bio *bio, +typedef void (submit_bio_hook_t )(struct inode *inode,struct bio *bio,int mirror_num,unsigned long bio_flags);fs/btrfs/inode.c +8
-15@@ -2581,9 +2581,8 @@ static blk_status_t extract_ordered_extent(struct btrfs_inode *inode,* * c-3) otherwise: async submit */ -blk_status_t btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) - +void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, +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;@@ -2620,7 +2619,7 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,*/ btrfs_submit_compressed_read (inode, bio, mirror_num, bio_flags); -return BLK_STS_OK ; +return ; }else {/* * Lookup bio sums does extra checks around whether we @@ -2654,7 +2653,6 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio, bio->bi_status = ret;bio_endio (bio); } -return ret; }/* @@ -7798,25 +7796,20 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)kfree (dip); } -static blk_status_t submit_dio_repair_bio (struct inode *inode,struct bio *bio, -int mirror_num, -unsigned long bio_flags) +static void submit_dio_repair_bio (struct inode *inode,struct bio *bio, +int mirror_num,unsigned long bio_flags) {struct btrfs_dio_private *dip = bio->bi_private;struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb); -blk_status_t ret;BUG_ON (bio_op (bio) ==REQ_OP_WRITE ); - ret =btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_DATA ); -if (ret) -return ret; +if (btrfs_bio_wq_end_io (fs_info, bio,BTRFS_WQ_ENDIO_DATA )) +return ;refcount_inc (&dip->refs); - ret =btrfs_map_bio (fs_info, bio, mirror_num); -if (ret) +if (btrfs_map_bio (fs_info, bio, mirror_num))refcount_dec (&dip->refs); -return ret; } static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
Quoted 3 lines · Christoph Hellwig
Hi all,
this series cleans up a few loose ends in the btrfs bio submission path.
Mind to share which commit your code are based on?
After patch 3/5 "btrfs: do not return errors from btrfs_submit_metadata_bio", I was expecting the same cleanup for btrfs_submit_data_bio(), but it doesn't.
Thus I guess it already handled by other patches in your branch?
Thanks,
Qu
Quoted 11 lines
Diffstat:
compression.c | 11 +++++------ compression.h | 4 ++-- ctree.h | 5 ++--- disk-io.c | 26 ++++++++++---------------- disk-io.h | 4 ++-- extent_io.c | 39 +++++++++++++++++++++++++++++++++++---- extent_io.h | 18 ++---------------- inode.c | 49 ++++++++++--------------------------------------- 8 files changed, 68 insertions(+), 88 deletions(-)
Quoted 1 line · Qu Wenruo
Mind to share which commit your code are based on?
the misc-next branch as of yesterday.
Quoted 4 lines
After patch 3/5 "btrfs: do not return errors from
btrfs_submit_metadata_bio", I was expecting the same cleanup forbtrfs_submit_data_bio(), but it doesn't.
patch 5 handles it, but it btrfs_submit_data_bio can't be done standalone as it is also used as a callback for btrfs_repair_one_sector.
Nikolay Borisov
Reviewed-byQuoted 5 lines · Christoph Hellwig
Hi all,
this series cleans up a few loose ends in the btrfs bio submission path.
Diffstat:
Quoted 10 lines
compression.c | 11 +++++------ compression.h | 4 ++-- ctree.h | 5 ++--- disk-io.c | 26 ++++++++++---------------- disk-io.h | 4 ++-- extent_io.c | 39 +++++++++++++++++++++++++++++++++++---- extent_io.h | 18 ++---------------- inode.c | 49 ++++++++++--------------------------------------- 8 files changed, 68 insertions(+), 88 deletions(-)
For the whole series:
Quoted 5 lines · Christoph Hellwig
Hi all,
this series cleans up a few loose ends in the btrfs bio submission path.
Diffstat:
Quoted 9 lines
compression.c | 11 +++++------ compression.h | 4 ++-- ctree.h | 5 ++--- disk-io.c | 26 ++++++++++---------------- disk-io.h | 4 ++-- extent_io.c | 39 +++++++++++++++++++++++++++++++++++---- extent_io.h | 18 ++---------------- inode.c | 49 ++++++++++--------------------------------------- 8 files changed, 68 insertions(+), 88 deletions(-)
Added to misc-next, thanks.