Commit a0b60d72 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

btrfs: avoid access to .bi_vcnt directly

BTRFS uses bio->bi_vcnt to figure out page numbers, this approach is no
longer valid once we start enabling multipage bvecs.
correct once we start to enable multipage bvec.

Use bio_nr_pages() to do that instead.

Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 25d8be77
...@@ -2257,7 +2257,7 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, ...@@ -2257,7 +2257,7 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
return 0; return 0;
} }
bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, bool btrfs_check_repairable(struct inode *inode, unsigned failed_bio_pages,
struct io_failure_record *failrec, int failed_mirror) struct io_failure_record *failrec, int failed_mirror)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
...@@ -2281,7 +2281,7 @@ bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, ...@@ -2281,7 +2281,7 @@ bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
* a) deliver good data to the caller * a) deliver good data to the caller
* b) correct the bad sectors on disk * b) correct the bad sectors on disk
*/ */
if (failed_bio->bi_vcnt > 1) { if (failed_bio_pages > 1) {
/* /*
* to fulfill b), we need to know the exact failing sectors, as * to fulfill b), we need to know the exact failing sectors, as
* we don't want to rewrite any more than the failed ones. thus, * we don't want to rewrite any more than the failed ones. thus,
...@@ -2374,6 +2374,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, ...@@ -2374,6 +2374,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
int read_mode = 0; int read_mode = 0;
blk_status_t status; blk_status_t status;
int ret; int ret;
unsigned failed_bio_pages = bio_pages_all(failed_bio);
BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE);
...@@ -2381,13 +2382,13 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, ...@@ -2381,13 +2382,13 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
if (ret) if (ret)
return ret; return ret;
if (!btrfs_check_repairable(inode, failed_bio, failrec, if (!btrfs_check_repairable(inode, failed_bio_pages, failrec,
failed_mirror)) { failed_mirror)) {
free_io_failure(failure_tree, tree, failrec); free_io_failure(failure_tree, tree, failrec);
return -EIO; return -EIO;
} }
if (failed_bio->bi_vcnt > 1) if (failed_bio_pages > 1)
read_mode |= REQ_FAILFAST_DEV; read_mode |= REQ_FAILFAST_DEV;
phy_offset >>= inode->i_sb->s_blocksize_bits; phy_offset >>= inode->i_sb->s_blocksize_bits;
......
...@@ -540,7 +540,7 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, ...@@ -540,7 +540,7 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start,
u64 end); u64 end);
int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
struct io_failure_record **failrec_ret); struct io_failure_record **failrec_ret);
bool btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, bool btrfs_check_repairable(struct inode *inode, unsigned failed_bio_pages,
struct io_failure_record *failrec, int fail_mirror); struct io_failure_record *failrec, int fail_mirror);
struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio, struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
struct io_failure_record *failrec, struct io_failure_record *failrec,
......
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