public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
       [not found] <20260112172345.800703-1-sashal@kernel.org>
@ 2026-01-12 17:34 ` Kent Overstreet
  2026-01-12 18:01 ` Kent Overstreet
  2026-01-15  8:47 ` Kent Overstreet
  2 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2026-01-12 17:34 UTC (permalink / raw)
  To: stable; +Cc: stable-commits, zhangshida, Coly Li

On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> This is a note to let you know that I've just added the patch titled
> 
>     bcache: fix improper use of bi_end_io
> 
> to the 6.6-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      bcache-fix-improper-use-of-bi_end_io.patch
> and it can be found in the queue-6.6 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

Has this code been tested?

bio_endio() is not equivalent to calling bi_end_io; if the code is
swapping out bi_end_io to pass it down the stack, then you have two
completions on the same bio - you cannot call bio_endio() twice on the
same bio.

> 
> 
> 
> commit 81e7e43a810e8f40e163928d441de02d2816b073
> Author: Shida Zhang <zhangshida@kylinos.cn>
> Date:   Tue Dec 9 17:01:56 2025 +0800
> 
>     bcache: fix improper use of bi_end_io
>     
>     [ Upstream commit 53280e398471f0bddbb17b798a63d41264651325 ]
>     
>     Don't call bio->bi_end_io() directly. Use the bio_endio() helper
>     function instead, which handles completion more safely and uniformly.
>     
>     Suggested-by: Christoph Hellwig <hch@infradead.org>
>     Reviewed-by: Christoph Hellwig <hch@lst.de>
>     Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
>     Signed-off-by: Sasha Levin <sashal@kernel.org>
> 
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index a9b1f3896249b..b4059d2daa326 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1090,7 +1090,7 @@ static void detached_dev_end_io(struct bio *bio)
>  	}
>  
>  	kfree(ddip);
> -	bio->bi_end_io(bio);
> +	bio_endio(bio);
>  }
>  
>  static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> @@ -1107,7 +1107,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
>  	if (!ddip) {
>  		bio->bi_status = BLK_STS_RESOURCE;
> -		bio->bi_end_io(bio);
> +		bio_endio(bio);
>  		return;
>  	}
>  
> @@ -1122,7 +1122,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  
>  	if ((bio_op(bio) == REQ_OP_DISCARD) &&
>  	    !bdev_max_discard_sectors(dc->bdev))
> -		bio->bi_end_io(bio);
> +		detached_dev_end_io(bio);
>  	else
>  		submit_bio_noacct(bio);
>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
       [not found] <20260112172345.800703-1-sashal@kernel.org>
  2026-01-12 17:34 ` Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree Kent Overstreet
@ 2026-01-12 18:01 ` Kent Overstreet
  2026-01-13  6:08   ` Coly Li
  2026-01-15  8:47 ` Kent Overstreet
  2 siblings, 1 reply; 7+ messages in thread
From: Kent Overstreet @ 2026-01-12 18:01 UTC (permalink / raw)
  To: stable; +Cc: stable-commits, zhangshida, Coly Li

On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> This is a note to let you know that I've just added the patch titled
> 
>     bcache: fix improper use of bi_end_io
> 
> to the 6.6-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      bcache-fix-improper-use-of-bi_end_io.patch
> and it can be found in the queue-6.6 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

Yeah, this is broken.

Coly, please revert this.

> 
> 
> 
> commit 81e7e43a810e8f40e163928d441de02d2816b073
> Author: Shida Zhang <zhangshida@kylinos.cn>
> Date:   Tue Dec 9 17:01:56 2025 +0800
> 
>     bcache: fix improper use of bi_end_io
>     
>     [ Upstream commit 53280e398471f0bddbb17b798a63d41264651325 ]
>     
>     Don't call bio->bi_end_io() directly. Use the bio_endio() helper
>     function instead, which handles completion more safely and uniformly.
>     
>     Suggested-by: Christoph Hellwig <hch@infradead.org>
>     Reviewed-by: Christoph Hellwig <hch@lst.de>
>     Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
>     Signed-off-by: Sasha Levin <sashal@kernel.org>
> 
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index a9b1f3896249b..b4059d2daa326 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1090,7 +1090,7 @@ static void detached_dev_end_io(struct bio *bio)
>  	}
>  
>  	kfree(ddip);
> -	bio->bi_end_io(bio);
> +	bio_endio(bio);
>  }
>  
>  static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> @@ -1107,7 +1107,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
>  	if (!ddip) {
>  		bio->bi_status = BLK_STS_RESOURCE;
> -		bio->bi_end_io(bio);
> +		bio_endio(bio);
>  		return;
>  	}
>  
> @@ -1122,7 +1122,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  
>  	if ((bio_op(bio) == REQ_OP_DISCARD) &&
>  	    !bdev_max_discard_sectors(dc->bdev))
> -		bio->bi_end_io(bio);
> +		detached_dev_end_io(bio);
>  	else
>  		submit_bio_noacct(bio);
>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
  2026-01-12 18:01 ` Kent Overstreet
@ 2026-01-13  6:08   ` Coly Li
  2026-01-13  6:21     ` Kent Overstreet
  0 siblings, 1 reply; 7+ messages in thread
From: Coly Li @ 2026-01-13  6:08 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: stable, stable-commits, zhangshida

On Mon, Jan 12, 2026 at 01:01:52PM +0800, Kent Overstreet wrote:
> On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> > This is a note to let you know that I've just added the patch titled
> > 
> >     bcache: fix improper use of bi_end_io
> > 
> > to the 6.6-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> > 
> > The filename of the patch is:
> >      bcache-fix-improper-use-of-bi_end_io.patch
> > and it can be found in the queue-6.6 subdirectory.
> > 
> > If you, or anyone else, feels it should not be added to the stable tree,
> > please let <stable@vger.kernel.org> know about it.
> 
> Yeah, this is broken.
> 
> Coly, please revert this.
>

Yes, let me do it.

Although I didn’t ack this patch, I read the patch and thought it was
fine, yes my fault too.

This faulty patch didn’t trigger issue on my testing machine, I guess
it was because on simple bcache setup, re-enter bio_endio() happenly
didn't actually redo things other than calling bio->bi_end_io().

I will post a revert commit to Jens.

This patch is part of the patch set to address race around bio chain
handling. Then Shida please continue to find a better version on the
fix.

Coly Li
 
> > 
> > 
> > 
> > commit 81e7e43a810e8f40e163928d441de02d2816b073
> > Author: Shida Zhang <zhangshida@kylinos.cn>
> > Date:   Tue Dec 9 17:01:56 2025 +0800
> > 
> >     bcache: fix improper use of bi_end_io
> >     
> >     [ Upstream commit 53280e398471f0bddbb17b798a63d41264651325 ]
> >     
> >     Don't call bio->bi_end_io() directly. Use the bio_endio() helper
> >     function instead, which handles completion more safely and uniformly.
> >     
> >     Suggested-by: Christoph Hellwig <hch@infradead.org>
> >     Reviewed-by: Christoph Hellwig <hch@lst.de>
> >     Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
> >     Signed-off-by: Jens Axboe <axboe@kernel.dk>
> >     Signed-off-by: Sasha Levin <sashal@kernel.org>
> > 
> > diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> > index a9b1f3896249b..b4059d2daa326 100644
> > --- a/drivers/md/bcache/request.c
> > +++ b/drivers/md/bcache/request.c
> > @@ -1090,7 +1090,7 @@ static void detached_dev_end_io(struct bio *bio)
> >  	}
> >  
> >  	kfree(ddip);
> > -	bio->bi_end_io(bio);
> > +	bio_endio(bio);
> >  }
> >  
> >  static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> > @@ -1107,7 +1107,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> >  	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
> >  	if (!ddip) {
> >  		bio->bi_status = BLK_STS_RESOURCE;
> > -		bio->bi_end_io(bio);
> > +		bio_endio(bio);
> >  		return;
> >  	}
> >  
> > @@ -1122,7 +1122,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> >  
> >  	if ((bio_op(bio) == REQ_OP_DISCARD) &&
> >  	    !bdev_max_discard_sectors(dc->bdev))
> > -		bio->bi_end_io(bio);
> > +		detached_dev_end_io(bio);
> >  	else
> >  		submit_bio_noacct(bio);
> >  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
  2026-01-13  6:08   ` Coly Li
@ 2026-01-13  6:21     ` Kent Overstreet
  0 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2026-01-13  6:21 UTC (permalink / raw)
  To: Coly Li; +Cc: stable, stable-commits, zhangshida

On Tue, Jan 13, 2026 at 02:08:27PM +0800, Coly Li wrote:
> On Mon, Jan 12, 2026 at 01:01:52PM +0800, Kent Overstreet wrote:
> > On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> > > This is a note to let you know that I've just added the patch titled
> > > 
> > >     bcache: fix improper use of bi_end_io
> > > 
> > > to the 6.6-stable tree which can be found at:
> > >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> > > 
> > > The filename of the patch is:
> > >      bcache-fix-improper-use-of-bi_end_io.patch
> > > and it can be found in the queue-6.6 subdirectory.
> > > 
> > > If you, or anyone else, feels it should not be added to the stable tree,
> > > please let <stable@vger.kernel.org> know about it.
> > 
> > Yeah, this is broken.
> > 
> > Coly, please revert this.
> >
> 
> Yes, let me do it.
> 
> Although I didn’t ack this patch, I read the patch and thought it was
> fine, yes my fault too.
> 
> This faulty patch didn’t trigger issue on my testing machine, I guess
> it was because on simple bcache setup, re-enter bio_endio() happenly
> didn't actually redo things other than calling bio->bi_end_io().

Yeah, re-entering bio_endio() will work on simple setups - but it'll
explode as soon as bio splitting starts happening.

You really want to be going over anything Christoph does with a fine
toothed comb.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
       [not found] <20260112172345.800703-1-sashal@kernel.org>
  2026-01-12 17:34 ` Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree Kent Overstreet
  2026-01-12 18:01 ` Kent Overstreet
@ 2026-01-15  8:47 ` Kent Overstreet
  2026-01-15 11:39   ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Kent Overstreet @ 2026-01-15  8:47 UTC (permalink / raw)
  To: stable; +Cc: stable-commits, zhangshida, Coly Li

On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> This is a note to let you know that I've just added the patch titled
> 
>     bcache: fix improper use of bi_end_io
> 
> to the 6.6-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      bcache-fix-improper-use-of-bi_end_io.patch
> and it can be found in the queue-6.6 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

Sasha, has this been dropped?

> 
> 
> 
> commit 81e7e43a810e8f40e163928d441de02d2816b073
> Author: Shida Zhang <zhangshida@kylinos.cn>
> Date:   Tue Dec 9 17:01:56 2025 +0800
> 
>     bcache: fix improper use of bi_end_io
>     
>     [ Upstream commit 53280e398471f0bddbb17b798a63d41264651325 ]
>     
>     Don't call bio->bi_end_io() directly. Use the bio_endio() helper
>     function instead, which handles completion more safely and uniformly.
>     
>     Suggested-by: Christoph Hellwig <hch@infradead.org>
>     Reviewed-by: Christoph Hellwig <hch@lst.de>
>     Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
>     Signed-off-by: Sasha Levin <sashal@kernel.org>
> 
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index a9b1f3896249b..b4059d2daa326 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1090,7 +1090,7 @@ static void detached_dev_end_io(struct bio *bio)
>  	}
>  
>  	kfree(ddip);
> -	bio->bi_end_io(bio);
> +	bio_endio(bio);
>  }
>  
>  static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> @@ -1107,7 +1107,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  	ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
>  	if (!ddip) {
>  		bio->bi_status = BLK_STS_RESOURCE;
> -		bio->bi_end_io(bio);
> +		bio_endio(bio);
>  		return;
>  	}
>  
> @@ -1122,7 +1122,7 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
>  
>  	if ((bio_op(bio) == REQ_OP_DISCARD) &&
>  	    !bdev_max_discard_sectors(dc->bdev))
> -		bio->bi_end_io(bio);
> +		detached_dev_end_io(bio);
>  	else
>  		submit_bio_noacct(bio);
>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
  2026-01-15  8:47 ` Kent Overstreet
@ 2026-01-15 11:39   ` Greg KH
  2026-01-15 11:40     ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2026-01-15 11:39 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: stable, stable-commits, zhangshida, Coly Li

On Thu, Jan 15, 2026 at 03:47:39AM -0500, Kent Overstreet wrote:
> On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> > This is a note to let you know that I've just added the patch titled
> > 
> >     bcache: fix improper use of bi_end_io
> > 
> > to the 6.6-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> > 
> > The filename of the patch is:
> >      bcache-fix-improper-use-of-bi_end_io.patch
> > and it can be found in the queue-6.6 subdirectory.
> > 
> > If you, or anyone else, feels it should not be added to the stable tree,
> > please let <stable@vger.kernel.org> know about it.
> 
> Sasha, has this been dropped?

Why just drop it from 6.6?  What about all other branches?  What about
Linus's tree?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree
  2026-01-15 11:39   ` Greg KH
@ 2026-01-15 11:40     ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2026-01-15 11:40 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: stable, stable-commits, zhangshida, Coly Li

On Thu, Jan 15, 2026 at 12:39:34PM +0100, Greg KH wrote:
> On Thu, Jan 15, 2026 at 03:47:39AM -0500, Kent Overstreet wrote:
> > On Mon, Jan 12, 2026 at 12:23:45PM -0500, Sasha Levin wrote:
> > > This is a note to let you know that I've just added the patch titled
> > > 
> > >     bcache: fix improper use of bi_end_io
> > > 
> > > to the 6.6-stable tree which can be found at:
> > >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> > > 
> > > The filename of the patch is:
> > >      bcache-fix-improper-use-of-bi_end_io.patch
> > > and it can be found in the queue-6.6 subdirectory.
> > > 
> > > If you, or anyone else, feels it should not be added to the stable tree,
> > > please let <stable@vger.kernel.org> know about it.
> > 
> > Sasha, has this been dropped?
> 
> Why just drop it from 6.6?  What about all other branches?  What about
> Linus's tree?

Ah, it's being reverted there, ok, I'll go drop this from all branches
now, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-15 11:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260112172345.800703-1-sashal@kernel.org>
2026-01-12 17:34 ` Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree Kent Overstreet
2026-01-12 18:01 ` Kent Overstreet
2026-01-13  6:08   ` Coly Li
2026-01-13  6:21     ` Kent Overstreet
2026-01-15  8:47 ` Kent Overstreet
2026-01-15 11:39   ` Greg KH
2026-01-15 11:40     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox