btrfs: not a disk error if the bio_add_page fails

bio_add_page() can fail for logical reasons as from the bio_add_page()
comments:

/*
 * This will only fail if either bio->bi_vcnt == bio->bi_max_vecs or
 * it's a cloned bio.
 */

Here we have just allocated the bio, so both of those failures can't
occur. So drop the check. We can also drop the error stats for write
error.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain
2018-01-05 10:47:07 +08:00
committed by David Sterba
parent 4117f207d4
commit 7ef2d6a722

View File

@@ -4620,7 +4620,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
{ {
struct bio *bio; struct bio *bio;
struct btrfs_device *dev; struct btrfs_device *dev;
int ret;
dev = sctx->wr_tgtdev; dev = sctx->wr_tgtdev;
if (!dev) if (!dev)
@@ -4635,17 +4634,15 @@ static int write_page_nocow(struct scrub_ctx *sctx,
bio->bi_iter.bi_sector = physical_for_dev_replace >> 9; bio->bi_iter.bi_sector = physical_for_dev_replace >> 9;
bio_set_dev(bio, dev->bdev); bio_set_dev(bio, dev->bdev);
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC; bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
ret = bio_add_page(bio, page, PAGE_SIZE, 0); /* bio_add_page won't fail on a freshly allocated bio */
if (ret != PAGE_SIZE) { bio_add_page(bio, page, PAGE_SIZE, 0);
leave_with_eio:
if (btrfsic_submit_bio_wait(bio)) {
bio_put(bio); bio_put(bio);
btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
return -EIO; return -EIO;
} }
if (btrfsic_submit_bio_wait(bio))
goto leave_with_eio;
bio_put(bio); bio_put(bio);
return 0; return 0;
} }