Commit f77dcc0d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

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: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f3b8a7f3
...@@ -1538,7 +1538,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad, ...@@ -1538,7 +1538,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
BUG_ON(sector_good->page == NULL); BUG_ON(sector_good->page == NULL);
if (force_write || sblock_bad->header_error || if (force_write || sblock_bad->header_error ||
sblock_bad->checksum_error || sector_bad->io_error) { sblock_bad->checksum_error || sector_bad->io_error) {
struct bio *bio; struct bio bio;
struct bio_vec bvec;
int ret; int ret;
if (!sector_bad->dev->bdev) { if (!sector_bad->dev->bdev) {
...@@ -1547,26 +1548,20 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad, ...@@ -1547,26 +1548,20 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
return -EIO; return -EIO;
} }
bio = btrfs_bio_alloc(1); bio_init(&bio, sector_bad->dev->bdev, &bvec, 1, REQ_OP_WRITE);
bio_set_dev(bio, sector_bad->dev->bdev); bio.bi_iter.bi_sector = sector_bad->physical >> 9;
bio->bi_iter.bi_sector = sector_bad->physical >> 9; __bio_add_page(&bio, sector_good->page, sectorsize, 0);
bio->bi_opf = REQ_OP_WRITE;
ret = bio_add_page(bio, sector_good->page, sectorsize, 0); btrfsic_check_bio(&bio);
if (ret != sectorsize) { ret = submit_bio_wait(&bio);
bio_put(bio); bio_uninit(&bio);
return -EIO;
}
btrfsic_check_bio(bio); if (ret) {
if (submit_bio_wait(bio)) {
btrfs_dev_stat_inc_and_print(sector_bad->dev, btrfs_dev_stat_inc_and_print(sector_bad->dev,
BTRFS_DEV_STAT_WRITE_ERRS); BTRFS_DEV_STAT_WRITE_ERRS);
atomic64_inc(&fs_info->dev_replace.num_write_errors); atomic64_inc(&fs_info->dev_replace.num_write_errors);
bio_put(bio);
return -EIO; return -EIO;
} }
bio_put(bio);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment