Commit 1e87770c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: use btrfs_bio_for_each_sector in btrfs_check_read_dio_bio

Use the new btrfs_bio_for_each_sector iterator to simplify
btrfs_check_read_dio_bio.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@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 261d812b
...@@ -7899,47 +7899,35 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip, ...@@ -7899,47 +7899,35 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
{ {
struct inode *inode = dip->inode; struct inode *inode = dip->inode;
struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
const u32 sectorsize = fs_info->sectorsize;
struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree; struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM); const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
struct bio_vec bvec;
struct bvec_iter iter;
u32 bio_offset = 0;
blk_status_t err = BLK_STS_OK; blk_status_t err = BLK_STS_OK;
struct bvec_iter iter;
struct bio_vec bv;
u32 offset;
__bio_for_each_segment(bvec, &bbio->bio, iter, bbio->iter) { btrfs_bio_for_each_sector(fs_info, bv, bbio, iter, offset) {
unsigned int i, nr_sectors, pgoff; u64 start = bbio->file_offset + offset;
nr_sectors = BTRFS_BYTES_TO_BLKS(fs_info, bvec.bv_len);
pgoff = bvec.bv_offset;
for (i = 0; i < nr_sectors; i++) {
u64 start = bbio->file_offset + bio_offset;
ASSERT(pgoff < PAGE_SIZE);
if (uptodate && if (uptodate &&
(!csum || !check_data_csum(inode, bbio, (!csum || !check_data_csum(inode, bbio, offset, bv.bv_page,
bio_offset, bvec.bv_page, bv.bv_offset, start))) {
pgoff, start))) { clean_io_failure(fs_info, failure_tree, io_tree, start,
clean_io_failure(fs_info, failure_tree, io_tree, bv.bv_page, btrfs_ino(BTRFS_I(inode)),
start, bvec.bv_page, bv.bv_offset);
btrfs_ino(BTRFS_I(inode)),
pgoff);
} else { } else {
int ret; int ret;
ret = btrfs_repair_one_sector(inode, &bbio->bio, ret = btrfs_repair_one_sector(inode, &bbio->bio, offset,
bio_offset, bvec.bv_page, pgoff, bv.bv_page, bv.bv_offset, start,
start, bbio->mirror_num, bbio->mirror_num,
submit_dio_repair_bio); submit_dio_repair_bio);
if (ret) if (ret)
err = errno_to_blk_status(ret); err = errno_to_blk_status(ret);
} }
ASSERT(bio_offset + sectorsize > bio_offset);
bio_offset += sectorsize;
pgoff += sectorsize;
}
} }
return err; return err;
} }
......
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