Btrfs: check-integrity use bvec_iter
Some check-integrity code depends on bio->bi_vcnt, this changes it to use bio segments because some bios passing here may not have a reliable bi_vcnt. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
629ebf4fad
commit
11b5616516
|
@ -2816,44 +2816,47 @@ static void __btrfsic_submit_bio(struct bio *bio)
|
||||||
dev_state = btrfsic_dev_state_lookup(bio->bi_bdev);
|
dev_state = btrfsic_dev_state_lookup(bio->bi_bdev);
|
||||||
if (NULL != dev_state &&
|
if (NULL != dev_state &&
|
||||||
(bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
|
(bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
|
||||||
unsigned int i;
|
unsigned int i = 0;
|
||||||
u64 dev_bytenr;
|
u64 dev_bytenr;
|
||||||
u64 cur_bytenr;
|
u64 cur_bytenr;
|
||||||
struct bio_vec *bvec;
|
struct bio_vec bvec;
|
||||||
|
struct bvec_iter iter;
|
||||||
int bio_is_patched;
|
int bio_is_patched;
|
||||||
char **mapped_datav;
|
char **mapped_datav;
|
||||||
|
unsigned int segs = bio_segments(bio);
|
||||||
|
|
||||||
dev_bytenr = 512 * bio->bi_iter.bi_sector;
|
dev_bytenr = 512 * bio->bi_iter.bi_sector;
|
||||||
bio_is_patched = 0;
|
bio_is_patched = 0;
|
||||||
if (dev_state->state->print_mask &
|
if (dev_state->state->print_mask &
|
||||||
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
|
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
|
||||||
pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
|
pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
|
||||||
bio_op(bio), bio->bi_opf, bio->bi_vcnt,
|
bio_op(bio), bio->bi_opf, segs,
|
||||||
(unsigned long long)bio->bi_iter.bi_sector,
|
(unsigned long long)bio->bi_iter.bi_sector,
|
||||||
dev_bytenr, bio->bi_bdev);
|
dev_bytenr, bio->bi_bdev);
|
||||||
|
|
||||||
mapped_datav = kmalloc_array(bio->bi_vcnt,
|
mapped_datav = kmalloc_array(segs,
|
||||||
sizeof(*mapped_datav), GFP_NOFS);
|
sizeof(*mapped_datav), GFP_NOFS);
|
||||||
if (!mapped_datav)
|
if (!mapped_datav)
|
||||||
goto leave;
|
goto leave;
|
||||||
cur_bytenr = dev_bytenr;
|
cur_bytenr = dev_bytenr;
|
||||||
|
|
||||||
bio_for_each_segment_all(bvec, bio, i) {
|
bio_for_each_segment(bvec, bio, iter) {
|
||||||
BUG_ON(bvec->bv_len != PAGE_SIZE);
|
BUG_ON(bvec.bv_len != PAGE_SIZE);
|
||||||
mapped_datav[i] = kmap(bvec->bv_page);
|
mapped_datav[i] = kmap(bvec.bv_page);
|
||||||
|
i++;
|
||||||
|
|
||||||
if (dev_state->state->print_mask &
|
if (dev_state->state->print_mask &
|
||||||
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
|
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
|
||||||
pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
|
pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
|
||||||
i, cur_bytenr, bvec->bv_len, bvec->bv_offset);
|
i, cur_bytenr, bvec.bv_len, bvec.bv_offset);
|
||||||
cur_bytenr += bvec->bv_len;
|
cur_bytenr += bvec.bv_len;
|
||||||
}
|
}
|
||||||
btrfsic_process_written_block(dev_state, dev_bytenr,
|
btrfsic_process_written_block(dev_state, dev_bytenr,
|
||||||
mapped_datav, bio->bi_vcnt,
|
mapped_datav, segs,
|
||||||
bio, &bio_is_patched,
|
bio, &bio_is_patched,
|
||||||
NULL, bio->bi_opf);
|
NULL, bio->bi_opf);
|
||||||
bio_for_each_segment_all(bvec, bio, i)
|
bio_for_each_segment(bvec, bio, iter)
|
||||||
kunmap(bvec->bv_page);
|
kunmap(bvec.bv_page);
|
||||||
kfree(mapped_datav);
|
kfree(mapped_datav);
|
||||||
} else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) {
|
} else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) {
|
||||||
if (dev_state->state->print_mask &
|
if (dev_state->state->print_mask &
|
||||||
|
|
Loading…
Reference in New Issue