Skip to content

Commit 7ecc56c

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: allow passing a NULL bdev to bio_alloc_clone/bio_init_clone
Device mapper wants to allocate a bio before knowing the device it gets send to, so add explicit support for that. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Mike Snitzer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5136168 commit 7ecc56c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

block/bio.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,15 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
761761
bio_set_flag(bio, BIO_CLONED);
762762
if (bio_flagged(bio_src, BIO_THROTTLED))
763763
bio_set_flag(bio, BIO_THROTTLED);
764-
if (bio->bi_bdev == bio_src->bi_bdev &&
765-
bio_flagged(bio_src, BIO_REMAPPED))
766-
bio_set_flag(bio, BIO_REMAPPED);
767764
bio->bi_ioprio = bio_src->bi_ioprio;
768765
bio->bi_iter = bio_src->bi_iter;
769766

770-
bio_clone_blkg_association(bio, bio_src);
767+
if (bio->bi_bdev) {
768+
if (bio->bi_bdev == bio_src->bi_bdev &&
769+
bio_flagged(bio_src, BIO_REMAPPED))
770+
bio_set_flag(bio, BIO_REMAPPED);
771+
bio_clone_blkg_association(bio, bio_src);
772+
}
771773

772774
if (bio_crypt_clone(bio, bio_src, gfp) < 0)
773775
return -ENOMEM;

0 commit comments

Comments
 (0)