Cleanups of blk_status_t use
David Sterba
maintainercover Cleanups of blk_status_t use
Use the blk_status_t only for interaction with block layer API and remove it from our functions. Do some naming unifications and minor cleanups.
David Sterba (12):
btrfs: drop redundant local variable in raid_wait_write_end_io()
btrfs: change return type of btrfs_lookup_bio_sums() to int
btrfs: change return type of btrfs_csum_one_bio() to int
btrfs: change return type of btree_csum_one_bio() to int
btrfs: change return type of btrfs_bio_csum() to int
btrfs: rename ret to status in btrfs_submit_chunk()
btrfs: rename error to ret in btrfs_submit_chunk()
btrfs: simplify reading bio status in end_compressed_writeback()
btrfs: rename ret to status in btrfs_submit_compressed_read()
btrfs: rename ret2 to ret in btrfs_submit_compressed_read()
btrfs: change return type of btrfs_alloc_dummy_sum() to int
btrfs: raid56: rename parameter err to status in endio helpers
fs/btrfs/bio.c | 33 ++++++++++++++++++--------------- fs/btrfs/compression.c | 22 +++++++++++----------- fs/btrfs/disk-io.c | 16 ++++++++-------- fs/btrfs/disk-io.h | 2 +- fs/btrfs/file-item.c | 20 ++++++++++---------- fs/btrfs/file-item.h | 6 +++--- fs/btrfs/raid56.c | 13 ++++++------- 7 files changed, 57 insertions(+), 55 deletions(-)
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 1/12 btrfs: drop redundant local variable in raid_wait_write_end_io()
The bio status is read only once, no variable needed for that.
--- fs/btrfs/raid56.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/raid56.c +1 -2
@@ -2291,9 +2291,8 @@ static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)static void raid_wait_write_end_io (struct bio *bio) {struct btrfs_raid_bio *rbio = bio->bi_private; -blk_status_t err = bio->bi_status; -if (err) +if (bio->bi_status)rbio_update_error_bitmap (rbio, bio);bio_put (bio);if (atomic_dec_and_test (&rbio->stripes_pending))
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 2/12 btrfs: change return type of btrfs_lookup_bio_sums() to int
In reply to David SterbaThe type blk_status_t is from block layer and not related to checksums in our context. Use int internally and do the conversions to blk_status_t as needed in btrfs_submit_chunk().
--- fs/btrfs/bio.c | 3 ++- fs/btrfs/file-item.c | 12 ++++++------ fs/btrfs/file-item.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
fs/btrfs/bio.c +2 -1
@@ -714,7 +714,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)*/ if (bio_op (bio) ==REQ_OP_READ &&is_data_bbio (bbio)) { bbio->saved_iter = bio->bi_iter; - ret =btrfs_lookup_bio_sums (bbio); + error =btrfs_lookup_bio_sums (bbio); + ret =errno_to_blk_status (error);if (ret) goto fail; }
fs/btrfs/file-item.c +6 -6
@@ -336,7 +336,7 @@ static int search_csum_tree(struct btrfs_fs_info *fs_info,* * Return: BLK_STS_RESOURCE if allocating memory fails, BLK_STS_OK otherwise. */ -blk_status_t btrfs_lookup_bio_sums (struct btrfs_bio *bbio) +int btrfs_lookup_bio_sums (struct btrfs_bio *bbio) {struct btrfs_inode *inode = bbio->inode;struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@ -347,12 +347,12 @@ blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio)u32 orig_len = bio->bi_iter.bi_size;u64 orig_disk_bytenr = bio->bi_iter.bi_sector <<SECTOR_SHIFT ;const unsigned int nblocks = orig_len >> fs_info->sectorsize_bits; -blk_status_t ret =BLK_STS_OK ; +int ret =0 ;u32 bio_offset =0 ;if ((inode->flags &BTRFS_INODE_NODATASUM ) ||test_bit (BTRFS_FS_STATE_NO_DATA_CSUMS , &fs_info->fs_state)) -return BLK_STS_OK ; +return 0 ;/* * This function is only called for read bio.
@@ -369,12 +369,12 @@ blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio)ASSERT (bio_op (bio) ==REQ_OP_READ ); path =btrfs_alloc_path ();if (!path) -return BLK_STS_RESOURCE ; +return -ENOMEM ;if (nblocks * csum_size >BTRFS_BIO_INLINE_CSUM_SIZE ) { bbio->csum =kmalloc_array (nblocks, csum_size,GFP_NOFS );if (!bbio->csum) -return BLK_STS_RESOURCE ; +return -ENOMEM ; }else { bbio->csum = bbio->csum_inline; }
@@ -406,7 +406,7 @@ blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio) count =search_csum_tree (fs_info, path, cur_disk_bytenr, orig_len - bio_offset, csum_dst);if (count <0 ) { - ret =errno_to_blk_status (count); + ret = count;if (bbio->csum != bbio->csum_inline)kfree (bbio->csum); bbio->csum =NULL ;
fs/btrfs/file-item.h +1 -1
@@ -53,7 +53,7 @@ static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)int btrfs_del_csums (struct btrfs_trans_handle *trans,struct btrfs_root *root,u64 bytenr,u64 len); -blk_status_t btrfs_lookup_bio_sums (struct btrfs_bio *bbio); +int btrfs_lookup_bio_sums (struct btrfs_bio *bbio);int btrfs_insert_hole_extent (struct btrfs_trans_handle *trans,struct btrfs_root *root,u64 objectid,u64 pos,u64 num_bytes);
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 3/12 btrfs: change return type of btrfs_csum_one_bio() to int
In reply to David SterbaThe type blk_status_t is from block layer and not related to checksums in our context. Use int internally and do the conversions to blk_status_t as needed in btrfs_bio_csum().
--- fs/btrfs/bio.c | 2 +- fs/btrfs/file-item.c | 4 ++-- fs/btrfs/file-item.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/bio.c +1 -1
@@ -516,7 +516,7 @@ static blk_status_t btrfs_bio_csum(struct btrfs_bio *bbio) {if (bbio->bio.bi_opf &REQ_META )return btree_csum_one_bio (bbio); -return btrfs_csum_one_bio (bbio); +return errno_to_blk_status (btrfs_csum_one_bio (bbio)); }/*
fs/btrfs/file-item.c +2 -2
@@ -735,7 +735,7 @@ int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,/* * Calculate checksums of the data contained inside a bio. */ -blk_status_t btrfs_csum_one_bio (struct btrfs_bio *bbio) +int btrfs_csum_one_bio (struct btrfs_bio *bbio) {struct btrfs_ordered_extent *ordered = bbio->ordered;struct btrfs_inode *inode = bbio->inode;
@@ -757,7 +757,7 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio)memalloc_nofs_restore (nofs_flag);if (!sums) -return BLK_STS_RESOURCE ; +return -ENOMEM ; sums->len = bio->bi_iter.bi_size;INIT_LIST_HEAD (&sums->list);
fs/btrfs/file-item.h +1 -1
@@ -64,7 +64,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,int btrfs_csum_file_blocks (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_ordered_sum *sums); -blk_status_t btrfs_csum_one_bio (struct btrfs_bio *bbio); +int btrfs_csum_one_bio (struct btrfs_bio *bbio);blk_status_t btrfs_alloc_dummy_sum (struct btrfs_bio *bbio); int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, struct list_head *list, int search_commit,
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 5/12 btrfs: change return type of btrfs_bio_csum() to int
In reply to David SterbaThe type blk_status_t is from block layer and not related to checksums in our context. Use int internally and do the conversions to blk_status_t as needed.
--- fs/btrfs/bio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/btrfs/bio.c +7 -6
@@ -512,11 +512,11 @@ static void btrfs_submit_bio(struct bio *bio, struct btrfs_io_context *bioc, } } -static blk_status_t btrfs_bio_csum (struct btrfs_bio *bbio) +static int btrfs_bio_csum (struct btrfs_bio *bbio) {if (bbio->bio.bi_opf &REQ_META ) -return errno_to_blk_status (btree_csum_one_bio (bbio)); -return errno_to_blk_status (btrfs_csum_one_bio (bbio)); +return btree_csum_one_bio (bbio); +return btrfs_csum_one_bio (bbio); }/*
@@ -543,11 +543,11 @@ static void run_one_async_start(struct btrfs_work *work) {struct async_submit_bio *async = container_of(work, struct async_submit_bio, work); -blk_status_t ret; +int ret; ret =btrfs_bio_csum (async->bbio);if (ret) - async->bbio->bio.bi_status = ret; + async->bbio->bio.bi_status =errno_to_blk_status (ret); }/*
@@ -748,7 +748,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) btrfs_wq_submit_bio(bbio, bioc, &smap, mirror_num)) goto done; - ret =btrfs_bio_csum (bbio); + error =btrfs_bio_csum (bbio); + ret =errno_to_blk_status (error);if (ret) goto fail; } else if (use_append ||
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 4/12 btrfs: change return type of btree_csum_one_bio() to int
In reply to David SterbaThe type blk_status_t is from block layer and not related to checksums in our context. Use int internally and do the conversions to blk_status_t as needed in btrfs_bio_csum().
--- fs/btrfs/bio.c | 2 +- fs/btrfs/disk-io.c | 16 ++++++++-------- fs/btrfs/disk-io.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-)
fs/btrfs/bio.c +1 -1
@@ -515,7 +515,7 @@ static void btrfs_submit_bio(struct bio *bio, struct btrfs_io_context *bioc,static blk_status_t btrfs_bio_csum (struct btrfs_bio *bbio) {if (bbio->bio.bi_opf &REQ_META ) -return btree_csum_one_bio (bbio); +return errno_to_blk_status (btree_csum_one_bio (bbio));return errno_to_blk_status (btrfs_csum_one_bio (bbio)); }
fs/btrfs/disk-io.c +8 -8
@@ -256,7 +256,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *eb,/* * Checksum a dirty tree block before IO. */ -blk_status_t btree_csum_one_bio (struct btrfs_bio *bbio) +int btree_csum_one_bio (struct btrfs_bio *bbio) {struct extent_buffer *eb = bbio->private;struct btrfs_fs_info *fs_info = eb->fs_info;
@@ -267,9 +267,9 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)/* Btree blocks are always contiguous on disk. */ if (WARN_ON_ONCE (bbio->file_offset != eb->start)) -return BLK_STS_IOERR ; +return -EIO ;if (WARN_ON_ONCE (bbio->bio.bi_iter.bi_size != eb->len)) -return BLK_STS_IOERR ; +return -EIO ;/* * If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't
@@ -278,13 +278,13 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)*/ if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) {memzero_extent_buffer (eb,0 , eb->len); -return BLK_STS_OK ; +return 0 ; }if (WARN_ON_ONCE (found_start != eb->start)) -return BLK_STS_IOERR ; +return -EIO ;if (WARN_ON (!btrfs_meta_folio_test_uptodate (eb->folios[0 ], eb))) -return BLK_STS_IOERR ; +return -EIO ; ASSERT(memcmp_extent_buffer(eb, fs_info->fs_devices->metadata_uuid, offsetof(struct btrfs_header, fsid),
@@ -312,7 +312,7 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) goto error; }write_extent_buffer (eb, result,0 , fs_info->csum_size); -return BLK_STS_OK ; +return 0 ; error:btrfs_print_tree (eb,0 );
@@ -326,7 +326,7 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)*/ WARN_ON (IS_ENABLED (CONFIG_BTRFS_DEBUG ) ||btrfs_header_owner (eb) ==BTRFS_TREE_LOG_OBJECTID ); -return errno_to_blk_status (ret); +return ret; }static bool check_tree_block_fsid (struct extent_buffer *eb)
fs/btrfs/disk-io.h +1 -1
@@ -114,7 +114,7 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,int btrfs_read_extent_buffer (struct extent_buffer *buf,const struct btrfs_tree_parent_check *check); -blk_status_t btree_csum_one_bio (struct btrfs_bio *bbio); +int btree_csum_one_bio (struct btrfs_bio *bbio);int btrfs_alloc_log_tree_node (struct btrfs_trans_handle *trans,struct btrfs_root *root); int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 6/12 btrfs: rename ret to status in btrfs_submit_chunk()
In reply to David SterbaWe're using 'status' for the blk_status_t variables, rename 'ret' so we can use it for proper return type.
--- fs/btrfs/bio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
fs/btrfs/bio.c +11 -11
@@ -674,7 +674,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)bool use_append =btrfs_use_zone_append (bbio);struct btrfs_io_context *bioc =NULL ;struct btrfs_io_stripe smap; -blk_status_t ret; +blk_status_t status;int error;if (!bbio->inode ||btrfs_is_data_reloc_root (inode->root))
@@ -686,7 +686,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) error =btrfs_map_block (fs_info,btrfs_op (bio), logical, &map_length, &bioc, &smap, &mirror_num);if (error) { - ret =errno_to_blk_status (error); + status =errno_to_blk_status (error);btrfs_bio_counter_dec (fs_info); goto end_bbio; }
@@ -700,7 +700,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) split =btrfs_split_bio (fs_info, bbio, map_length);if (IS_ERR (split)) { - ret =errno_to_blk_status (PTR_ERR (split)); + status =errno_to_blk_status (PTR_ERR (split));btrfs_bio_counter_dec (fs_info); goto end_bbio; }
@@ -715,8 +715,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)if (bio_op (bio) ==REQ_OP_READ &&is_data_bbio (bbio)) { bbio->saved_iter = bio->bi_iter; error =btrfs_lookup_bio_sums (bbio); - ret =errno_to_blk_status (error); -if (ret) + status =errno_to_blk_status (error); +if (status) goto fail; }
@@ -749,14 +749,14 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) goto done; error =btrfs_bio_csum (bbio); - ret =errno_to_blk_status (error); -if (ret) + status =errno_to_blk_status (error); +if (status) goto fail; }else if (use_append || (btrfs_is_zoned (fs_info) && inode && inode->flags &BTRFS_INODE_NODATASUM )) { - ret =btrfs_alloc_dummy_sum (bbio); -if (ret) + status =btrfs_alloc_dummy_sum (bbio); +if (status) goto fail; } }
@@ -777,10 +777,10 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)ASSERT (bbio->bio.bi_pool == &btrfs_clone_bioset);ASSERT (remaining); -btrfs_bio_end_io (remaining, ret); +btrfs_bio_end_io (remaining, status); } end_bbio: -btrfs_bio_end_io (bbio, ret); +btrfs_bio_end_io (bbio, status);/* Do not submit another chunk */ return true; }
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 7/12 btrfs: rename error to ret in btrfs_submit_chunk()
In reply to David SterbaWe can now rename 'error' to 'ret' and use it for generic errors.
--- fs/btrfs/bio.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/btrfs/bio.c +9 -9
@@ -675,7 +675,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)struct btrfs_io_context *bioc =NULL ;struct btrfs_io_stripe smap;blk_status_t status; -int error; +int ret;if (!bbio->inode ||btrfs_is_data_reloc_root (inode->root)) smap.rst_search_commit_root = true;
@@ -683,10 +683,10 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) smap.rst_search_commit_root = false;btrfs_bio_counter_inc_blocked (fs_info); - error =btrfs_map_block (fs_info,btrfs_op (bio), logical, &map_length, - &bioc, &smap, &mirror_num); -if (error) { - status =errno_to_blk_status (error); + ret =btrfs_map_block (fs_info,btrfs_op (bio), logical, &map_length, + &bioc, &smap, &mirror_num); +if (ret) { + status =errno_to_blk_status (ret);btrfs_bio_counter_dec (fs_info); goto end_bbio; }
@@ -714,8 +714,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)*/ if (bio_op (bio) ==REQ_OP_READ &&is_data_bbio (bbio)) { bbio->saved_iter = bio->bi_iter; - error =btrfs_lookup_bio_sums (bbio); - status =errno_to_blk_status (error); + ret =btrfs_lookup_bio_sums (bbio); + status =errno_to_blk_status (ret);if (status) goto fail; }
@@ -748,8 +748,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) btrfs_wq_submit_bio(bbio, bioc, &smap, mirror_num)) goto done; - error =btrfs_bio_csum (bbio); - status =errno_to_blk_status (error); + ret =btrfs_bio_csum (bbio); + status =errno_to_blk_status (ret);if (status) goto fail; } else if (use_append ||
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 8/12 btrfs: simplify reading bio status in end_compressed_writeback()
In reply to David SterbaWe don't need to have a separate variable to read the bio status, 'ret' works for that just fine so remove 'error'.
--- fs/btrfs/compression.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/compression.c +3 -3
@@ -285,12 +285,12 @@ static noinline void end_compressed_writeback(const struct compressed_bio *cb)unsigned long index = cb->start >>PAGE_SHIFT ;unsigned long end_index = (cb->start + cb->len -1 ) >>PAGE_SHIFT ;struct folio_batch fbatch; -const int error =blk_status_to_errno (cb->bbio.bio.bi_status);int i;int ret; -if (error) -mapping_set_error (inode->i_mapping, error); + ret =blk_status_to_errno (cb->bbio.bio.bi_status); +if (ret) +mapping_set_error (inode->i_mapping, ret);folio_batch_init (&fbatch);while (index <= end_index) {
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 9/12 btrfs: rename ret to status in btrfs_submit_compressed_read()
In reply to David SterbaWe're using 'status' for the blk_status_t variables, rename 'ret' so we can use it for generic errors.
--- fs/btrfs/compression.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/compression.c +5 -5
@@ -576,7 +576,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio)struct extent_map *em;unsigned long pflags;int memstall =0 ; -blk_status_t ret; +blk_status_t status;int ret2;/* we need the actual starting offset of this extent in the file */
@@ -584,7 +584,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio) em =btrfs_lookup_extent_mapping (em_tree, file_offset, fs_info->sectorsize);read_unlock (&em_tree->lock);if (!em) { - ret =BLK_STS_IOERR ; + status =BLK_STS_IOERR ; goto out; }
@@ -608,13 +608,13 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio) cb->nr_folios =DIV_ROUND_UP (compressed_len,PAGE_SIZE ); cb->compressed_folios =kcalloc (cb->nr_folios,sizeof (struct page *),GFP_NOFS );if (!cb->compressed_folios) { - ret =BLK_STS_RESOURCE ; + status =BLK_STS_RESOURCE ; goto out_free_bio; } ret2 =btrfs_alloc_folio_array (cb->nr_folios, cb->compressed_folios);if (ret2) { - ret =BLK_STS_RESOURCE ; + status =BLK_STS_RESOURCE ; goto out_free_compressed_pages; }
@@ -637,7 +637,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio) out_free_bio:bio_put (&cb->bbio.bio); out: -btrfs_bio_end_io (bbio, ret); +btrfs_bio_end_io (bbio, status); }/*
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 10/12 btrfs: rename ret2 to ret in btrfs_submit_compressed_read()
In reply to David SterbaWe can now rename 'ret2' to 'ret' and use it for generic errors.
--- fs/btrfs/compression.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/compression.c +3 -3
@@ -577,7 +577,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio)unsigned long pflags;int memstall =0 ;blk_status_t status; -int ret2; +int ret;/* we need the actual starting offset of this extent in the file */ read_lock (&em_tree->lock);
@@ -612,8 +612,8 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio) goto out_free_bio; } - ret2 =btrfs_alloc_folio_array (cb->nr_folios, cb->compressed_folios); -if (ret2) { + ret =btrfs_alloc_folio_array (cb->nr_folios, cb->compressed_folios); +if (ret) { status =BLK_STS_RESOURCE ; goto out_free_compressed_pages; }
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 11/12 btrfs: change return type of btrfs_alloc_dummy_sum() to int
In reply to David SterbaThe type blk_status_t is from block layer and not related to checksums in our context. Use int internally and do the conversions to blk_status_t as needed in btrfs_submit_chunk().
--- fs/btrfs/bio.c | 3 ++- fs/btrfs/file-item.c | 4 ++-- fs/btrfs/file-item.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/bio.c +2 -1
@@ -755,7 +755,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) }else if (use_append || (btrfs_is_zoned (fs_info) && inode && inode->flags &BTRFS_INODE_NODATASUM )) { - status =btrfs_alloc_dummy_sum (bbio); + ret =btrfs_alloc_dummy_sum (bbio); + status =errno_to_blk_status (ret);if (status) goto fail; }
fs/btrfs/file-item.c +2 -2
@@ -794,11 +794,11 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio)* record the updated logical address on Zone Append completion. * Allocate just the structure with an empty sums array here for that case. */ -blk_status_t btrfs_alloc_dummy_sum (struct btrfs_bio *bbio) +int btrfs_alloc_dummy_sum (struct btrfs_bio *bbio) { bbio->sums =kmalloc (sizeof (*bbio->sums),GFP_NOFS );if (!bbio->sums) -return BLK_STS_RESOURCE ; +return -ENOMEM ; bbio->sums->len = bbio->bio.bi_iter.bi_size; bbio->sums->logical = bbio->bio.bi_iter.bi_sector <<SECTOR_SHIFT ;btrfs_add_ordered_sum (bbio->ordered, bbio->sums);
fs/btrfs/file-item.h +1 -1
@@ -65,7 +65,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,struct btrfs_root *root, struct btrfs_ordered_sum *sums);int btrfs_csum_one_bio (struct btrfs_bio *bbio); -blk_status_t btrfs_alloc_dummy_sum (struct btrfs_bio *bbio); +int btrfs_alloc_dummy_sum (struct btrfs_bio *bbio);int btrfs_lookup_csums_range (struct btrfs_root *root,u64 start,u64 end,struct list_head *list,int search_commit,bool nowait);
Signature · 1 line
2.49.0
David Sterba
maintainerPATCH 12/12 btrfs: raid56: rename parameter err to status in endio helpers
In reply to David SterbaTrivial renames to unify the naming of blk_status_t variables/parameters.
--- fs/btrfs/raid56.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/raid56.c +5 -5
@@ -892,14 +892,14 @@ static noinline void unlock_stripe(struct btrfs_raid_bio *rbio)remove_rbio_from_cache (rbio); } -static void rbio_endio_bio_list (struct bio *cur,blk_status_t err) +static void rbio_endio_bio_list (struct bio *cur,blk_status_t status) {struct bio *next;while (cur) { next = cur->bi_next; cur->bi_next =NULL ; - cur->bi_status = err; + cur->bi_status = status;bio_endio (cur); cur = next; }
@@ -909,7 +909,7 @@ static void rbio_endio_bio_list(struct bio *cur, blk_status_t err)* this frees the rbio and runs through all the bios in the * bio_list and calls end_io on them */ -static void rbio_orig_end_io (struct btrfs_raid_bio *rbio,blk_status_t err) +static void rbio_orig_end_io (struct btrfs_raid_bio *rbio,blk_status_t status) {struct bio *cur =bio_list_get (&rbio->bio_list);struct bio *extra;
@@ -938,9 +938,9 @@ static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, blk_status_t err) extra =bio_list_get (&rbio->bio_list);free_raid_bio (rbio); -rbio_endio_bio_list (cur, err); +rbio_endio_bio_list (cur, status);if (extra) -rbio_endio_bio_list (extra, err); +rbio_endio_bio_list (extra, status); }/*
Signature · 1 line
2.49.0
Quoted 3 lines · David Sterba
Use the
blk_status_tonly for interaction with block layer API and remove it from our functions. Do some naming unifications and minor cleanups.
Although I'm wondering if it's even possible to require a forced compiler warning when using blk_status_t as other types and vice verse?
Thanks,
Qu
Quoted 24 lines
David Sterba (12):
btrfs: drop redundant local variable inraid_wait_write_end_io()
btrfs: change return type ofbtrfs_lookup_bio_sums()to int
btrfs: change return type ofbtrfs_csum_one_bio()to int
btrfs: change return type ofbtree_csum_one_bio()to int
btrfs: change return type ofbtrfs_bio_csum()to int
btrfs: rename ret to status inbtrfs_submit_chunk()
btrfs: rename error to ret inbtrfs_submit_chunk()
btrfs: simplify reading bio status inend_compressed_writeback()
btrfs: rename ret to status inbtrfs_submit_compressed_read()
btrfs: rename ret2 to ret inbtrfs_submit_compressed_read()
btrfs: change return type ofbtrfs_alloc_dummy_sum()to int
btrfs: raid56: rename parameter err to status in endio helpersfs/btrfs/bio.c | 33 ++++++++++++++++++--------------- fs/btrfs/compression.c | 22 +++++++++++----------- fs/btrfs/disk-io.c | 16 ++++++++-------- fs/btrfs/disk-io.h | 2 +- fs/btrfs/file-item.c | 20 ++++++++++---------- fs/btrfs/file-item.h | 6 +++--- fs/btrfs/raid56.c | 13 ++++++------- 7 files changed, 57 insertions(+), 55 deletions(-)
Quoted 9 lines · Qu Wenruo
Quoted 3 lines · David Sterba
Use the
blk_status_tonly for interaction with block layer API and remove it from our functions. Do some naming unifications and minor cleanups.Reviewed-by Qu Wenruo <[email protected]>Although I'm wondering if it's even possible to require a forced compiler warning when using
blk_status_tas other types and vice verse?
There already is forced type for the non-zero values
https://elixir.bootlin.com/linux/v6.14.3/source/include/linux/blk_types.h#L96
typedef u8 __bitwise blk_status_t;
typedef u16 blk_short_t;
#define BLK_STS_OK 0
#define BLK_STS_NOTSUPP ((__force blk_status_t)1)
#define BLK_STS_TIMEOUT ((__force blk_status_t)2)
#define BLK_STS_NOSPC ((__force blk_status_t)3)
...
and from what I've seen there were no type mismatches.
Quoted 11 lines · David Sterba
There already is forced type for the non-zero values
https://elixir.bootlin.com/linux/v6.14.3/source/include/linux/blk_types.h#L96
typedef u8__bitwiseblk_status_t;
typedef u16blk_short_t;
#defineBLK_STS_OK0
#defineBLK_STS_NOTSUPP((__forceblk_status_t)1)
#defineBLK_STS_TIMEOUT((__forceblk_status_t)2)
#defineBLK_STS_NOSPC((__forceblk_status_t)3)
...
Quoted 1 line
and from what I've seen there were no type mismatches.
Note that you'll need to run sparse to perform __bitwise checking, it is not supported by gcc or clang.