[PATCH RFC] nvme-multipath: fix diskstats for partitions
Keith Busch
kbusch at kernel.org
Fri Jul 24 08:37:42 PDT 2026
On Fri, Jul 24, 2026 at 04:29:08PM +0100, John Garry wrote:
> On 7/24/26 13:45, Keith Busch wrote:
> > Can we just thread through partitions for the bio's block_device instead
> > of assuming part0? I know the hidden path devices skip partition
> > scanning, but maybe if we let it happen, then those will have the same
> > partition setup as the head gendisk. Then we can go right to the
> > disk->part_tbl for what we provide to bio_set_dev() for both submission
> > and failover, and everything should work out from there.
>
> I guess that we would just scan through the per-path gendisk->part_tbl and
> match somehow to lookup the partition. Maybe vs start address of
> bio->bi_bdev. Or is there a simpler (and quicker) way?
>
This is the idea, assuming we can get the partition tables of the head
and path disks to be aligned:
---
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -543,7 +543,10 @@ static void nvme_ns_head_submit_bio(struct bio *bio)
srcu_idx = srcu_read_lock(&head->srcu);
ns = nvme_find_path(head);
if (likely(ns)) {
- bio_set_dev(bio, ns->disk->part0);
+ struct block_device *bdev;
+
+ bdev = xa_load(&ns->disk->part_tbl, bdev_partno(bio->bi_bdev));
+ bio_set_dev(bio, bdev);
/*
* Use BIO_REMAPPED to skip bio_check_eod() when this bio
* enters submit_bio_noacct() for the per-path device. The EOD
--
More information about the Linux-nvme
mailing list