btrfs: change return type of btree_csum_one_bio() to int
authorDavid Sterba <dsterba@suse.com>
Wed, 23 Apr 2025 15:57:16 +0000 (17:57 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:48 +0000 (14:30 +0200)
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().

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/bio.c
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h

index 4f622bf130c2aa2689b7803109462e35307d22b3..4ceb1bd511df1ef2dbda5523d95001c908a1b893 100644 (file)
@@ -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));
 }
 
index 0ae30edb0e696acfdc7c2afca4a3f5f796c33dc3..3d151d189510977051dfb1ed163542f9a775ba6d 100644 (file)
@@ -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 @@ error:
         */
        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)
index 587842991b244232a6f77f76c231f2135b70268f..f87bbb7f8e7e29c6859831c4ce29fb78b05486af 100644 (file)
@@ -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,