Skip to contentSkip to conversation

Patch "bcache: fix improper use of bi_end_io" has been added to the 6.6-stable tree

DISCUSSION Kent Overstreet 3 participants 7 messages Jan 12 – Jan 15 1 message not in the archive Stable branch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Sasha Levin

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

Quoted 6 lines

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 <[email protected]> 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.

Quoted 51 lines

commit 81e7e43a810e8f40e163928d441de02d2816b073

Author: Shida Zhang <[email protected]>
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.

drivers/md/bcache/request.c +3 -3
index a9b1f3896249b..b4059d2daa326 100644
@@ -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);
 }
#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Sasha Levin

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

Quoted 6 lines

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 <[email protected]> know about it.

Yeah, this is broken.

Coly, please revert this.

Quoted 51 lines

commit 81e7e43a810e8f40e163928d441de02d2816b073

Author: Shida Zhang <[email protected]>
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.

drivers/md/bcache/request.c +3 -3
index a9b1f3896249b..b4059d2daa326 100644
@@ -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);
 }
#3 lore raw
Quoted 12 lines · Kent Overstreet
Quoted 11 lines · Sasha Levin

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.

Quoted 7 lines
Quoted 2 lines

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> 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

Quoted 51 lines
Quoted 51 lines

commit 81e7e43a810e8f40e163928d441de02d2816b073

Author: Shida Zhang <[email protected]>
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.

drivers/md/bcache/request.c +3 -3
index a9b1f3896249b..b4059d2daa326 100644
@@ -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);
 }
#4 lore raw
Quoted 21 lines · Coly Li
Quoted 12 lines · Kent Overstreet
Quoted 11 lines · Sasha Levin

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.

Quoted 7 lines
Quoted 2 lines

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Yeah, this is broken.

Coly, please revert this.

Quoted 8 lines

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.

#5 lore raw
In reply to a message not in the archive
Quoted 7 lines · Sasha Levin

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

Quoted 6 lines

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 <[email protected]> know about it.

Sasha, has this been dropped?

Quoted 51 lines

commit 81e7e43a810e8f40e163928d441de02d2816b073

Author: Shida Zhang <[email protected]>
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.

drivers/md/bcache/request.c +3 -3
index a9b1f3896249b..b4059d2daa326 100644
@@ -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);
 }
maintainer
#6 lore raw
Quoted 8 lines · Kent Overstreet
Quoted 7 lines · Sasha Levin

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

Quoted 8 lines
Quoted 6 lines

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 <[email protected]> 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

maintainer
#7 lore raw
Quoted 13 lines · Greg KH
Quoted 12 lines · Kent Overstreet
Quoted 11 lines · Sasha Levin

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.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> 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