On 4/6/22 2:12 PM, Christoph Hellwig wrote:
Remove the magic autofree semantics and require the callers to explicitly
call bio_init to initialize the bio.

This allows bio_free to catch accidental bio_put calls on bio_init()ed
bios as well.

Signed-off-by: Christoph Hellwig <h...@lst.de>
---
  block/bio.c                        | 47 ++++++++++++------------------
  block/blk-crypto-fallback.c        | 14 +++++----
  block/blk-map.c                    | 42 ++++++++++++++++----------
  drivers/block/pktcdvd.c            | 25 ++++++++--------
  drivers/md/bcache/debug.c          | 10 ++++---
  drivers/md/dm-bufio.c              |  9 +++---
  drivers/md/raid1.c                 | 12 +++++---
  drivers/md/raid10.c                | 21 ++++++++-----
  drivers/target/target_core_pscsi.c | 10 +++----
  fs/squashfs/block.c                | 15 +++++-----
  include/linux/bio.h                |  2 +-
  11 files changed, 112 insertions(+), 95 deletions(-)
[snipped]
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 6230dfdd9286e..7510d1c983a5e 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -107,15 +107,16 @@ void bch_btree_verify(struct btree *b)
void bch_data_verify(struct cached_dev *dc, struct bio *bio)
  {
+       unsigned int nr_segs = bio_segments(bio);
        struct bio *check;
        struct bio_vec bv, cbv;
        struct bvec_iter iter, citer = { 0 };
- check = bio_kmalloc(GFP_NOIO, bio_segments(bio));
+       check = bio_kmalloc(nr_segs, GFP_NOIO);
        if (!check)
                return;
-       bio_set_dev(check, bio->bi_bdev);
-       check->bi_opf = REQ_OP_READ;
+       bio_init(check, bio->bi_bdev, check->bi_inline_vecs, nr_segs,
+                REQ_OP_READ);
        check->bi_iter.bi_sector = bio->bi_iter.bi_sector;
        check->bi_iter.bi_size = bio->bi_iter.bi_size;
@@ -146,7 +147,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) bio_free_pages(check);
  out_put:
-       bio_put(check);
+       bio_uninit(check);
+       kfree(check);
  }
#endif

[snipped]

For bcache part,

Acked-by: Coly Li <col...@suse.de>


Coly Li



--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel

Reply via email to