* [PATCH 00/12] Cleanups of blk_status_t use
@ 2025-04-23 15:57 David Sterba
2025-04-23 15:57 ` [PATCH 01/12] btrfs: drop redundant local variable in raid_wait_write_end_io() David Sterba
` (12 more replies)
0 siblings, 13 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
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(-)
--
2.49.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 01/12] btrfs: drop redundant local variable in raid_wait_write_end_io()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 02/12] btrfs: change return type of btrfs_lookup_bio_sums() to int David Sterba
` (11 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The bio status is read only once, no variable needed for that.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/raid56.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 955cf17f443016..5906fd44c15def 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -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))
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 02/12] btrfs: change return type of btrfs_lookup_bio_sums() to int
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
2025-04-23 15:57 ` [PATCH 01/12] btrfs: drop redundant local variable in raid_wait_write_end_io() David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 03/12] btrfs: change return type of btrfs_csum_one_bio() " David Sterba
` (10 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The 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().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 3 ++-
fs/btrfs/file-item.c | 12 ++++++------
fs/btrfs/file-item.h | 2 +-
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index a3ee9a976f6fa5..5c40035e493d92 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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;
}
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 827d156a7bd7a8..895c435314f580 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -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;
diff --git a/fs/btrfs/file-item.h b/fs/btrfs/file-item.h
index 6181a70ec3efb4..995539a68df8be 100644
--- a/fs/btrfs/file-item.h
+++ b/fs/btrfs/file-item.h
@@ -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);
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 03/12] btrfs: change return type of btrfs_csum_one_bio() to int
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
2025-04-23 15:57 ` [PATCH 01/12] btrfs: drop redundant local variable in raid_wait_write_end_io() David Sterba
2025-04-23 15:57 ` [PATCH 02/12] btrfs: change return type of btrfs_lookup_bio_sums() to int David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 04/12] btrfs: change return type of btree_csum_one_bio() " David Sterba
` (9 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The 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().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 2 +-
fs/btrfs/file-item.c | 4 ++--
fs/btrfs/file-item.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 5c40035e493d92..4f622bf130c2aa 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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));
}
/*
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 895c435314f580..293dd3298b98bb 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -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);
diff --git a/fs/btrfs/file-item.h b/fs/btrfs/file-item.h
index 995539a68df8be..323dfb84f16c1d 100644
--- a/fs/btrfs/file-item.h
+++ b/fs/btrfs/file-item.h
@@ -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,
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 04/12] btrfs: change return type of btree_csum_one_bio() to int
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (2 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 03/12] btrfs: change return type of btrfs_csum_one_bio() " David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 05/12] btrfs: change return type of btrfs_bio_csum() " David Sterba
` (8 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The 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().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 2 +-
fs/btrfs/disk-io.c | 16 ++++++++--------
fs/btrfs/disk-io.h | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 4f622bf130c2aa..4ceb1bd511df1e 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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));
}
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 3592300ae3e2e5..20fd0958f18077 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -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)
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 587842991b2442..f87bbb7f8e7e29 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -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,
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 05/12] btrfs: change return type of btrfs_bio_csum() to int
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (3 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 04/12] btrfs: change return type of btree_csum_one_bio() " David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 06/12] btrfs: rename ret to status in btrfs_submit_chunk() David Sterba
` (7 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The 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.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 4ceb1bd511df1e..a534c6793e38fa 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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 ||
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 06/12] btrfs: rename ret to status in btrfs_submit_chunk()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (4 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 05/12] btrfs: change return type of btrfs_bio_csum() " David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 07/12] btrfs: rename error to ret " David Sterba
` (6 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We're using 'status' for the blk_status_t variables, rename 'ret' so we
can use it for proper return type.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index a534c6793e38fa..7ea56856e9dedc 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 07/12] btrfs: rename error to ret in btrfs_submit_chunk()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (5 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 06/12] btrfs: rename ret to status in btrfs_submit_chunk() David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 08/12] btrfs: simplify reading bio status in end_compressed_writeback() David Sterba
` (5 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We can now rename 'error' to 'ret' and use it for generic errors.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 7ea56856e9dedc..05a1bc450c1ccf 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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 ||
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 08/12] btrfs: simplify reading bio status in end_compressed_writeback()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (6 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 07/12] btrfs: rename error to ret " David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 09/12] btrfs: rename ret to status in btrfs_submit_compressed_read() David Sterba
` (4 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We don't need to have a separate variable to read the bio status, 'ret'
works for that just fine so remove 'error'.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 79997e97f3b557..59075dd865c143 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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) {
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 09/12] btrfs: rename ret to status in btrfs_submit_compressed_read()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (7 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 08/12] btrfs: simplify reading bio status in end_compressed_writeback() David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 10/12] btrfs: rename ret2 to ret " David Sterba
` (3 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We're using 'status' for the blk_status_t variables, rename 'ret' so we can
use it for generic errors.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 59075dd865c143..a2cf97ca975f81 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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);
}
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 10/12] btrfs: rename ret2 to ret in btrfs_submit_compressed_read()
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (8 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 09/12] btrfs: rename ret to status in btrfs_submit_compressed_read() David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 11/12] btrfs: change return type of btrfs_alloc_dummy_sum() to int David Sterba
` (2 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We can now rename 'ret2' to 'ret' and use it for generic errors.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index a2cf97ca975f81..7c5ed1466caf83 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -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;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 11/12] btrfs: change return type of btrfs_alloc_dummy_sum() to int
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (9 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 10/12] btrfs: rename ret2 to ret " David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-23 15:57 ` [PATCH 12/12] btrfs: raid56: rename parameter err to status in endio helpers David Sterba
2025-04-24 5:34 ` [PATCH 00/12] Cleanups of blk_status_t use Qu Wenruo
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The 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().
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/bio.c | 3 ++-
fs/btrfs/file-item.c | 4 ++--
fs/btrfs/file-item.h | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 05a1bc450c1ccf..f7d8958b732792 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -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;
}
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 293dd3298b98bb..54d523d4f42126 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -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);
diff --git a/fs/btrfs/file-item.h b/fs/btrfs/file-item.h
index 323dfb84f16c1d..63216c43676def 100644
--- a/fs/btrfs/file-item.h
+++ b/fs/btrfs/file-item.h
@@ -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);
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 12/12] btrfs: raid56: rename parameter err to status in endio helpers
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (10 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 11/12] btrfs: change return type of btrfs_alloc_dummy_sum() to int David Sterba
@ 2025-04-23 15:57 ` David Sterba
2025-04-24 5:34 ` [PATCH 00/12] Cleanups of blk_status_t use Qu Wenruo
12 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2025-04-23 15:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Trivial renames to unify the naming of blk_status_t variables/parameters.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/raid56.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 5906fd44c15def..fd96b5040584f3 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -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);
}
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 00/12] Cleanups of blk_status_t use
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
` (11 preceding siblings ...)
2025-04-23 15:57 ` [PATCH 12/12] btrfs: raid56: rename parameter err to status in endio helpers David Sterba
@ 2025-04-24 5:34 ` Qu Wenruo
2025-04-24 6:09 ` David Sterba
12 siblings, 1 reply; 16+ messages in thread
From: Qu Wenruo @ 2025-04-24 5:34 UTC (permalink / raw)
To: David Sterba, linux-btrfs
在 2025/4/24 01:27, David Sterba 写道:
> 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.
Reviewed-by: Qu Wenruo <wqu@suse.com>
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
>
> 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(-)
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 00/12] Cleanups of blk_status_t use
2025-04-24 5:34 ` [PATCH 00/12] Cleanups of blk_status_t use Qu Wenruo
@ 2025-04-24 6:09 ` David Sterba
2025-04-25 13:38 ` Christoph Hellwig
0 siblings, 1 reply; 16+ messages in thread
From: David Sterba @ 2025-04-24 6:09 UTC (permalink / raw)
To: Qu Wenruo; +Cc: David Sterba, linux-btrfs
On Thu, Apr 24, 2025 at 03:04:21PM +0930, Qu Wenruo wrote:
> 在 2025/4/24 01:27, David Sterba 写道:
> > 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.
>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
>
> 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?
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 00/12] Cleanups of blk_status_t use
2025-04-24 6:09 ` David Sterba
@ 2025-04-25 13:38 ` Christoph Hellwig
0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2025-04-25 13:38 UTC (permalink / raw)
To: David Sterba; +Cc: Qu Wenruo, David Sterba, linux-btrfs
On Thu, Apr 24, 2025 at 08:09:59AM +0200, David Sterba wrote:
> 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.
Note that you'll need to run sparse to perform __bitwise checking, it
is not supported by gcc or clang.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-04-25 13:38 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 15:57 [PATCH 00/12] Cleanups of blk_status_t use David Sterba
2025-04-23 15:57 ` [PATCH 01/12] btrfs: drop redundant local variable in raid_wait_write_end_io() David Sterba
2025-04-23 15:57 ` [PATCH 02/12] btrfs: change return type of btrfs_lookup_bio_sums() to int David Sterba
2025-04-23 15:57 ` [PATCH 03/12] btrfs: change return type of btrfs_csum_one_bio() " David Sterba
2025-04-23 15:57 ` [PATCH 04/12] btrfs: change return type of btree_csum_one_bio() " David Sterba
2025-04-23 15:57 ` [PATCH 05/12] btrfs: change return type of btrfs_bio_csum() " David Sterba
2025-04-23 15:57 ` [PATCH 06/12] btrfs: rename ret to status in btrfs_submit_chunk() David Sterba
2025-04-23 15:57 ` [PATCH 07/12] btrfs: rename error to ret " David Sterba
2025-04-23 15:57 ` [PATCH 08/12] btrfs: simplify reading bio status in end_compressed_writeback() David Sterba
2025-04-23 15:57 ` [PATCH 09/12] btrfs: rename ret to status in btrfs_submit_compressed_read() David Sterba
2025-04-23 15:57 ` [PATCH 10/12] btrfs: rename ret2 to ret " David Sterba
2025-04-23 15:57 ` [PATCH 11/12] btrfs: change return type of btrfs_alloc_dummy_sum() to int David Sterba
2025-04-23 15:57 ` [PATCH 12/12] btrfs: raid56: rename parameter err to status in endio helpers David Sterba
2025-04-24 5:34 ` [PATCH 00/12] Cleanups of blk_status_t use Qu Wenruo
2025-04-24 6:09 ` David Sterba
2025-04-25 13:38 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox