Re: [PATCH] bcache: fix double bio_endio completion in detached_dev_end_io
From: Christoph Hellwig
Date: Mon Jan 19 2026 - 03:04:13 EST
On Mon, Jan 19, 2026 at 02:53:53PM +0800, Stephen Zhang wrote:
> > > if (bio->bi_status) {
> > > - struct cached_dev *dc = container_of(ddip->d,
> > > - struct cached_dev, disk);
> > > + struct cached_dev *dc = bio->bi_private;
> > > +
> > > /* should count I/O error for backing device here */
> > > bch_count_backing_io_errors(dc, bio);
> > > + orig_bio->bi_status = bio->bi_status;
> > > }
> > >
>
> bio_init_clone must be paired with a bio_uninit() call before the
> memory is freed?
Yes. At least if you don't want leaks when using blk-group.
But as stated in my initial mail, as far as I can tell this path really
needs a bio_set to avoid spurious failures under memory pressure. In
which case we'd then do a bio_put in the end_io path.