diff options
author | Christoph Hellwig <hch@lst.de> | 2022-04-04 07:45:22 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-05-16 18:03:12 +0300 |
commit | f77dcc0d64d6b2a6cca81933fec1c17241ea572b (patch) | |
tree | 11782f99810bd42573aed178c4806dbd6b5ec407 /fs/btrfs/scrub.c | |
parent | f3b8a7f3fbc8e1ab27dfc5c47ebe3327b92fe2ed (diff) | |
download | linux-f77dcc0d64d6b2a6cca81933fec1c17241ea572b.tar.xz |
btrfs: use on-stack bio in scrub_repair_page_from_good_copy
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 <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>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 5560231c0897..967749dda7c0 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1538,7 +1538,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad, BUG_ON(sector_good->page == NULL); if (force_write || sblock_bad->header_error || sblock_bad->checksum_error || sector_bad->io_error) { - struct bio *bio; + struct bio bio; + struct bio_vec bvec; int ret; if (!sector_bad->dev->bdev) { @@ -1547,26 +1548,20 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad, return -EIO; } - bio = btrfs_bio_alloc(1); - bio_set_dev(bio, sector_bad->dev->bdev); - bio->bi_iter.bi_sector = sector_bad->physical >> 9; - bio->bi_opf = REQ_OP_WRITE; + bio_init(&bio, sector_bad->dev->bdev, &bvec, 1, REQ_OP_WRITE); + bio.bi_iter.bi_sector = sector_bad->physical >> 9; + __bio_add_page(&bio, sector_good->page, sectorsize, 0); - ret = bio_add_page(bio, sector_good->page, sectorsize, 0); - if (ret != sectorsize) { - bio_put(bio); - return -EIO; - } + btrfsic_check_bio(&bio); + ret = submit_bio_wait(&bio); + bio_uninit(&bio); - btrfsic_check_bio(bio); - if (submit_bio_wait(bio)) { + if (ret) { btrfs_dev_stat_inc_and_print(sector_bad->dev, BTRFS_DEV_STAT_WRITE_ERRS); atomic64_inc(&fs_info->dev_replace.num_write_errors); - bio_put(bio); return -EIO; } - bio_put(bio); } return 0; |