[PATCH v2] nvme-multipath: set BIO_REMAPPED on bios remapped to per-path namespace disks

Achkinazi, Igor Igor.Achkinazi at dell.com
Sat May 30 07:34:36 PDT 2026


Hannes Reinecke wrote:
> ... or you could introduce __bio_set_dev():
>
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 97d747320b35..5a2709adeea7 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -518,15 +518,20 @@ static inline void blkcg_punt_bio_submit(struct
> bio *bio)
>   }
>   #endif /* CONFIG_BLK_CGROUP */
>
> -static inline void bio_set_dev(struct bio *bio, struct block_device *bdev)
> +static inline void __bio_set_dev(struct bio *bio, struct block_device
> *bdev)
>   {
> -       bio_clear_flag(bio, BIO_REMAPPED);
>          if (bio->bi_bdev != bdev)
>                  bio_clear_flag(bio, BIO_BPS_THROTTLED);
>          bio->bi_bdev = bdev;
>          bio_associate_blkg(bio);
>   }
>
> +static inline void bio_set_dev(struct bio *bio, struct block_device *bdev)
> +{
> +       bio_clear_flag(bio, BIO_REMAPPED);
> +       __bio_set_dev(bio, bdev);
> +}
> +
>   /*
>    * BIO list management for use by remapping drivers (e.g. DM or MD)
> and loop.
>    *
>
> to avoid all this clear-and-set-flag dance.


Thanks Hannes. It is a cleaner approach and avoids the clear-and-set
dance. However it touches the block layer (bio.h) and would need
wider review and testing across all bio_set_dev callers.

I'd prefer to keep this patch as a minimal, nvme multipath fix that
Is easy to backport to stable kernels where this race is hitting us
today. The __bio_set_dev() approach (or Keith's patch that is
removing set_capacity(0) entirely) could follow as the proper
long-term solution.

Thanks, Igor


Internal Use - Confidential


More information about the Linux-nvme mailing list