From f3b8a7f3fbc8e1ab27dfc5c47ebe3327b92fe2ed Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 4 Apr 2022 06:45:21 +0200 Subject: [PATCH] btrfs: use on-stack bio in scrub_recheck_block The I/O in repair_io_failue is synchronous and doesn't need a btrfs_bio, so just use an on-stack bio. Reviewed-by: Qu Wenruo Signed-off-by: Christoph Hellwig Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/scrub.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index d78dbe540978..5560231c0897 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1458,8 +1458,9 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info, return scrub_recheck_block_on_raid56(fs_info, sblock); for (i = 0; i < sblock->sector_count; i++) { - struct bio *bio; struct scrub_sector *sector = sblock->sectors[i]; + struct bio bio; + struct bio_vec bvec; if (sector->dev->bdev == NULL) { sector->io_error = 1; @@ -1468,20 +1469,17 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info, } WARN_ON(!sector->page); - bio = btrfs_bio_alloc(1); - bio_set_dev(bio, sector->dev->bdev); + bio_init(&bio, sector->dev->bdev, &bvec, 1, REQ_OP_READ); + bio_add_page(&bio, sector->page, fs_info->sectorsize, 0); + bio.bi_iter.bi_sector = sector->physical >> 9; - bio_add_page(bio, sector->page, fs_info->sectorsize, 0); - bio->bi_iter.bi_sector = sector->physical >> 9; - bio->bi_opf = REQ_OP_READ; - - btrfsic_check_bio(bio); - if (submit_bio_wait(bio)) { + btrfsic_check_bio(&bio); + if (submit_bio_wait(&bio)) { sector->io_error = 1; sblock->no_io_error_seen = 0; } - bio_put(bio); + bio_uninit(&bio); } if (sblock->no_io_error_seen)