btrfs: check-integrity: split submit_bio from btrfsic checking
authorChristoph Hellwig <hch@lst.de>
Mon, 4 Apr 2022 04:45:18 +0000 (06:45 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:12 +0000 (17:03 +0200)
Require a separate call to the integrity checking helpers from the
actual bio submission.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/check-integrity.c
fs/btrfs/check-integrity.h
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/scrub.c
fs/btrfs/volumes.c

index 89cdf6e..ab27b2c 100644 (file)
@@ -2700,7 +2700,7 @@ static void btrfsic_check_flush_bio(struct bio *bio, struct btrfsic_dev_state *d
        }
 }
 
-static void __btrfsic_submit_bio(struct bio *bio)
+void btrfsic_check_bio(struct bio *bio)
 {
        struct btrfsic_dev_state *dev_state;
 
@@ -2722,18 +2722,6 @@ static void __btrfsic_submit_bio(struct bio *bio)
        mutex_unlock(&btrfsic_mutex);
 }
 
-void btrfsic_submit_bio(struct bio *bio)
-{
-       __btrfsic_submit_bio(bio);
-       submit_bio(bio);
-}
-
-int btrfsic_submit_bio_wait(struct bio *bio)
-{
-       __btrfsic_submit_bio(bio);
-       return submit_bio_wait(bio);
-}
-
 int btrfsic_mount(struct btrfs_fs_info *fs_info,
                  struct btrfs_fs_devices *fs_devices,
                  int including_extent_data, u32 print_mask)
index bcc730a..e4c8aed 100644 (file)
@@ -7,11 +7,9 @@
 #define BTRFS_CHECK_INTEGRITY_H
 
 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
-void btrfsic_submit_bio(struct bio *bio);
-int btrfsic_submit_bio_wait(struct bio *bio);
+void btrfsic_check_bio(struct bio *bio);
 #else
-#define btrfsic_submit_bio submit_bio
-#define btrfsic_submit_bio_wait submit_bio_wait
+static inline void btrfsic_check_bio(struct bio *bio) { }
 #endif
 
 int btrfsic_mount(struct btrfs_fs_info *fs_info,
index f6eef78..c866170 100644 (file)
@@ -4179,7 +4179,8 @@ static int write_dev_supers(struct btrfs_device *device,
                if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
                        bio->bi_opf |= REQ_FUA;
 
-               btrfsic_submit_bio(bio);
+               btrfsic_check_bio(bio);
+               submit_bio(bio);
 
                if (btrfs_advance_sb_log(device, i))
                        errors++;
@@ -4292,7 +4293,8 @@ static void write_dev_flush(struct btrfs_device *device)
        init_completion(&device->flush_wait);
        bio->bi_private = &device->flush_wait;
 
-       btrfsic_submit_bio(bio);
+       btrfsic_check_bio(bio);
+       submit_bio(bio);
        set_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state);
 }
 
index 50626f4..a26290a 100644 (file)
@@ -2368,7 +2368,8 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
        bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
        bio_add_page(bio, page, length, pg_offset);
 
-       if (btrfsic_submit_bio_wait(bio)) {
+       btrfsic_check_bio(bio);
+       if (submit_bio_wait(bio)) {
                /* try to remap that extent elsewhere? */
                btrfs_bio_counter_dec(fs_info);
                bio_put(bio);
index d07059a..d78dbe5 100644 (file)
@@ -1475,7 +1475,8 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
                bio->bi_iter.bi_sector = sector->physical >> 9;
                bio->bi_opf = REQ_OP_READ;
 
-               if (btrfsic_submit_bio_wait(bio)) {
+               btrfsic_check_bio(bio);
+               if (submit_bio_wait(bio)) {
                        sector->io_error = 1;
                        sblock->no_io_error_seen = 0;
                }
@@ -1559,7 +1560,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
                        return -EIO;
                }
 
-               if (btrfsic_submit_bio_wait(bio)) {
+               btrfsic_check_bio(bio);
+               if (submit_bio_wait(bio)) {
                        btrfs_dev_stat_inc_and_print(sector_bad->dev,
                                BTRFS_DEV_STAT_WRITE_ERRS);
                        atomic64_inc(&fs_info->dev_replace.num_write_errors);
@@ -1715,7 +1717,8 @@ static void scrub_wr_submit(struct scrub_ctx *sctx)
         * orders the requests before sending them to the driver which
         * doubled the write performance on spinning disks when measured
         * with Linux 3.5 */
-       btrfsic_submit_bio(sbio->bio);
+       btrfsic_check_bio(sbio->bio);
+       submit_bio(sbio->bio);
 
        if (btrfs_is_zoned(sctx->fs_info))
                sctx->write_pointer = sbio->physical + sbio->sector_count *
@@ -2049,7 +2052,8 @@ static void scrub_submit(struct scrub_ctx *sctx)
        sbio = sctx->bios[sctx->curr];
        sctx->curr = -1;
        scrub_pending_bio_inc(sctx);
-       btrfsic_submit_bio(sbio->bio);
+       btrfsic_check_bio(sbio->bio);
+       submit_bio(sbio->bio);
 }
 
 static int scrub_add_sector_to_rd_bio(struct scrub_ctx *sctx,
index 8a3f1bd..c000e39 100644 (file)
@@ -6742,7 +6742,8 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, struct bio *bio,
 
        btrfs_bio_counter_inc_noblocked(fs_info);
 
-       btrfsic_submit_bio(bio);
+       btrfsic_check_bio(bio);
+       submit_bio(bio);
 }
 
 static void bioc_error(struct btrfs_io_context *bioc, struct bio *bio, u64 logical)