mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 15:22:21 -04:00
nvdimm: pmem: guard data loop for dataless bios
pmem_submit_bio() handles flush-only bios before and after the data loop. Keep dataless bios out of bio_for_each_segment() so the data path only walks bios that actually carry bvec data. Signed-off-by: Li Chen <me@linux.beauty> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260630092338.2094628-4-me@linux.beauty>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
c644a2f8fe
commit
009e18ca5e
@@ -217,23 +217,29 @@ static void pmem_submit_bio(struct bio *bio)
|
||||
}
|
||||
}
|
||||
|
||||
do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue);
|
||||
if (do_acct)
|
||||
start = bio_start_io_acct(bio);
|
||||
bio_for_each_segment(bvec, bio, iter) {
|
||||
if (op_is_write(bio_op(bio)))
|
||||
rc = pmem_do_write(pmem, bvec.bv_page, bvec.bv_offset,
|
||||
iter.bi_sector, bvec.bv_len);
|
||||
else
|
||||
rc = pmem_do_read(pmem, bvec.bv_page, bvec.bv_offset,
|
||||
iter.bi_sector, bvec.bv_len);
|
||||
if (rc) {
|
||||
bio->bi_status = rc;
|
||||
break;
|
||||
if (bio_has_data(bio)) {
|
||||
do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue);
|
||||
if (do_acct)
|
||||
start = bio_start_io_acct(bio);
|
||||
bio_for_each_segment(bvec, bio, iter) {
|
||||
if (op_is_write(bio_op(bio)))
|
||||
rc = pmem_do_write(pmem, bvec.bv_page,
|
||||
bvec.bv_offset,
|
||||
iter.bi_sector,
|
||||
bvec.bv_len);
|
||||
else
|
||||
rc = pmem_do_read(pmem, bvec.bv_page,
|
||||
bvec.bv_offset,
|
||||
iter.bi_sector,
|
||||
bvec.bv_len);
|
||||
if (rc) {
|
||||
bio->bi_status = rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (do_acct)
|
||||
bio_end_io_acct(bio, start);
|
||||
}
|
||||
if (do_acct)
|
||||
bio_end_io_acct(bio, start);
|
||||
|
||||
if ((bio->bi_opf & REQ_FUA) && !bio->bi_status)
|
||||
ret = nvdimm_flush(nd_region, bio);
|
||||
|
||||
Reference in New Issue
Block a user