Commit 7276aa7d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: save the bio iter for checksum validation in common code

All callers of btrfs_submit_bio that want to validate checksums
currently have to store a copy of the iter in the btrfs_bio.  Move
the assignment into common code.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.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 9ba0004b
...@@ -63,7 +63,6 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size, ...@@ -63,7 +63,6 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size,
btrfs_bio_init(bbio, inode, end_io, private); btrfs_bio_init(bbio, inode, end_io, private);
bio_trim(bio, offset >> 9, size >> 9); bio_trim(bio, offset >> 9, size >> 9);
bbio->iter = bio->bi_iter;
return bio; return bio;
} }
...@@ -254,6 +253,10 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror ...@@ -254,6 +253,10 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
BUG(); BUG();
} }
/* Save the iter for the end_io handler for data reads. */
if (bio_op(bio) == REQ_OP_READ && !(bio->bi_opf & REQ_META))
bbio->iter = bio->bi_iter;
if (!bioc) { if (!bioc) {
/* Single mirror read/write fast path */ /* Single mirror read/write fast path */
bbio->mirror_num = mirror_num; bbio->mirror_num = mirror_num;
......
...@@ -789,10 +789,6 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -789,10 +789,6 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
submit = true; submit = true;
if (submit) { if (submit) {
/* Save the original iter for read repair */
if (bio_op(comp_bio) == REQ_OP_READ)
btrfs_bio(comp_bio)->iter = comp_bio->bi_iter;
/* /*
* Save the initial offset of this chunk, as there * Save the initial offset of this chunk, as there
* is no direct correlation between compressed pages and * is no direct correlation between compressed pages and
......
...@@ -756,7 +756,6 @@ int btrfs_repair_one_sector(struct btrfs_inode *inode, struct btrfs_bio *failed_ ...@@ -756,7 +756,6 @@ int btrfs_repair_one_sector(struct btrfs_inode *inode, struct btrfs_bio *failed_
} }
bio_add_page(repair_bio, page, failrec->len, pgoff); bio_add_page(repair_bio, page, failrec->len, pgoff);
repair_bbio->iter = repair_bio->bi_iter;
btrfs_debug(fs_info, btrfs_debug(fs_info,
"repair read error: submitting new read to mirror %d", "repair read error: submitting new read to mirror %d",
......
...@@ -2773,9 +2773,6 @@ void btrfs_submit_data_read_bio(struct btrfs_inode *inode, struct bio *bio, ...@@ -2773,9 +2773,6 @@ void btrfs_submit_data_read_bio(struct btrfs_inode *inode, struct bio *bio,
return; return;
} }
/* Save the original iter for read repair */
btrfs_bio(bio)->iter = bio->bi_iter;
/* /*
* Lookup bio sums does extra checks around whether we need to csum or * Lookup bio sums does extra checks around whether we need to csum or
* not, which is why we ignore skip_sum here. * not, which is why we ignore skip_sum here.
...@@ -7988,10 +7985,6 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode, ...@@ -7988,10 +7985,6 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode,
struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_fs_info *fs_info = inode->root->fs_info;
blk_status_t ret; blk_status_t ret;
/* Save the original iter for read repair */
if (btrfs_op(bio) == BTRFS_MAP_READ)
btrfs_bio(bio)->iter = bio->bi_iter;
if (inode->flags & BTRFS_INODE_NODATASUM) if (inode->flags & BTRFS_INODE_NODATASUM)
goto map; goto map;
......
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