]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: inherit BIO_REMAPPED when cloning bios
authorChristoph Hellwig <hch@lst.de>
Tue, 26 Jan 2021 14:33:08 +0000 (15:33 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 Jan 2021 15:50:01 +0000 (08:50 -0700)
Cloned bios are can be used to on the same device, in which case we need
to inherit the BIO_REMAPPED flag to avoid a double partition remap.  When
the cloned bios are used on another device, bio_set_dev will clear the flag.

Fixes: 85774780ef96 ("block: store a block_device pointer in struct bio")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
block/blk-crypto-fallback.c
block/bounce.c

index 99040a7e6656a1b884aaccf6c5838550d85acb16..dfd7740a32300a6a34d7955717d5541d4c849712 100644 (file)
@@ -666,6 +666,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
        bio_set_flag(bio, BIO_CLONED);
        if (bio_flagged(bio_src, BIO_THROTTLED))
                bio_set_flag(bio, BIO_THROTTLED);
+       if (bio_flagged(bio_src, BIO_REMAPPED))
+               bio_set_flag(bio, BIO_REMAPPED);
        bio->bi_opf = bio_src->bi_opf;
        bio->bi_ioprio = bio_src->bi_ioprio;
        bio->bi_write_hint = bio_src->bi_write_hint;
index 8f1e1817673115252895b0c557654bb74b0297d1..50c225398e4d60a92ca168ed756b05067f4a73d1 100644 (file)
@@ -168,6 +168,8 @@ static struct bio *blk_crypto_clone_bio(struct bio *bio_src)
        if (!bio)
                return NULL;
        bio->bi_bdev            = bio_src->bi_bdev;
+       if (bio_flagged(bio_src, BIO_REMAPPED))
+               bio_set_flag(bio, BIO_REMAPPED);
        bio->bi_opf             = bio_src->bi_opf;
        bio->bi_ioprio          = bio_src->bi_ioprio;
        bio->bi_write_hint      = bio_src->bi_write_hint;
index a22a8a1942b24f7b1a3360bdaf60f9fb34302ce9..fc55314aa4269ab41fefa0928413011e7932d87a 100644 (file)
@@ -247,6 +247,8 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
        if (!bio)
                return NULL;
        bio->bi_bdev            = bio_src->bi_bdev;
+       if (bio_flagged(bio_src, BIO_REMAPPED))
+               bio_set_flag(bio, BIO_REMAPPED);
        bio->bi_opf             = bio_src->bi_opf;
        bio->bi_ioprio          = bio_src->bi_ioprio;
        bio->bi_write_hint      = bio_src->bi_write_hint;