Re: [PATCH] bio: ensure __bio_clone_fast copies bi_partno

Bart Van Assche
2017-11-17T16:50:39Z

On Thu, 2017-11-16 at 23:47 -0800, Michael Lyle wrote:
> diff --git a/block/bio.c b/block/bio.c
> index 101c2a9b5481..33fa6b4af312 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -597,6 +597,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
> * so we don't set nor calculate new physical/hw segment counts here
> */
> bio->bi_disk = bio_src->bi_disk;
> + bio->bi_partno = bio_src->bi_partno;
> bio_set_flag(bio, BIO_CLONED);
> bio->bi_opf = bio_src->bi_opf;
> bio->bi_write_hint = bio_src->bi_write_hint;

Have you considered to use bio_copy_dev() instead of open-coding it?

Additionally, there is more code that copies these fields, e.g. the code in
bio_clone_bioset(). Shouldn't that code be modified such that it also copies
bi_partno?

How about the following class of assignments in drivers/md/raid1.c:

mbio->bi_disk = (void *)conf->mirrors[i].rdev;

Should these assignments perhaps be followed by a mbio->bi_partno assignment?

How about the following class of assignments in the NVMe code:

bio->bi_disk = disk;

Should these assignments perhaps be followed by a bio->bi_partno assignment?

Thanks,

Bart.