Skip to contentSkip to conversation

bcache fixes for Linux v5.18-rc3

PATCH Applied Coly Li 3 participants 5 messages Apr 19, 2022 – Apr 20, 2022

Subsystems (2)
lore
Share & tools
lore

Coly Li

author
#0 lore raw

cover bcache fixes for Linux v5.18-rc3

Hi Jens,

There are two regressions introduced in the generic block layer changes from Linux v5.18-rc1. Both of them may panic the kernel, please take them for -rc4.

Thanks in advance.

Coly Li
---
Coly Li (2):
bcache: put bch_bio_map() back to correct location in
journal_write_unlocked()
bcache: fix wrong bdev parameter when calling bio_alloc_clone() in

    do_bio_hook()
 drivers/md/bcache/journal.c | 2 +-
 drivers/md/bcache/request.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 bcache: put bch_bio_map() back to correct location in journal_write_unlocked()

Commit a7c50c940477 ("block: pass a block_device and opf to bio_reset") moves bch_bio_map() inside journal_write_unlocked() next to the location where the modified bio_reset() was called.

This change is wrong because calling bch_bio_map() immediately after bio_reset(), a BUG_ON(!bio->bi_iter.bi_size) inside bch_bio_map() will be triggered and panic the kernel.

This patch puts bch_bio_map() back to its original correct location in journal_write_unlocked() and avoid the BUG_ON().

Fixes a7c50c940477 ("block: pass a block_device and opf to bio_reset")
Cc Christoph Hellwig <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
---
 drivers/md/bcache/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/journal.c +1 -1
index 7c2ca52ca3e4..df5347ea450b 100644
@@ -771,12 +771,12 @@ static void journal_write_unlocked(struct closure *cl)
 
 		bio_reset(bio, ca->bdev, REQ_OP_WRITE | 
 			  REQ_SYNC | REQ_META | REQ_PREFLUSH | REQ_FUA);
-		bch_bio_map(bio, w->data);
 		bio->bi_iter.bi_sector	= PTR_OFFSET(k, i);
 		bio->bi_iter.bi_size = sectors << 9;
 
 		bio->bi_end_io	= journal_write_endio;
 		bio->bi_private = w;
+		bch_bio_map(bio, w->data);
 
 		trace_bcache_journal_write(bio, w->data->keys);
 		bio_list_add(&list, bio);
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/2 bcache: fix wrong bdev parameter when calling bio_alloc_clone() in do_bio_hook()

In reply to Coly Li

Commit abfc426d1b2f ("block: pass a block_device to bio_clone_fast") calls the modified bio_alloc_clone() in bcache code as:

	bio_init_clone(bio->bi_bdev, bio, orig_bio, GFP_NOIO);

But the first parameter is wrong, where bio->bi_bdev should be orig_bio->bi_bdev. The wrong bi_bdev panics the kernel when submitting cache bio.

This patch fixes the wrong bdev parameter usage and avoid the panic.

Fixes abfc426d1b2f ("block: pass a block_device to bio_clone_fast")
Cc Christoph Hellwig <[email protected]>
Cc Mike Snitzer <[email protected]>
---
 drivers/md/bcache/request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/request.c +1 -1
index fdd0194f84dd..320fcdfef48e 100644
@@ -685,7 +685,7 @@ static void do_bio_hook(struct search *s,
 {
 	struct bio *bio = &s->bio.bio;
 
-	bio_init_clone(bio->bi_bdev, bio, orig_bio, GFP_NOIO);
+	bio_init_clone(orig_bio->bi_bdev, bio, orig_bio, GFP_NOIO);
 	/*
 	 * bi_end_io can be set separately somewhere else, e.g. the
 	 * variants in,
Signature · 1 line
2.34.1
maintainer Applied
#3 lore raw
In reply to Coly Li
Quoted 9 lines · Coly Li

There are two regressions introduced in the generic block layer changes from Linux v5.18-rc1. Both of them may panic the kernel, please take them for -rc4.

Thanks in advance.

Coly Li

[...]

Applied, thanks!

[1/2] bcache: put bch_bio_map() back to correct location in journal_write_unlocked()

      commit: ff2695e52c9936febf65aa36a1769881da71bec5
[2/2] bcache: fix wrong bdev parameter when calling bio_alloc_clone() in do_bio_hook()
      commit: 9dca4168a37c9cfe182f077f0d2289292e9e3656

Best regards,

Signature · 1 line
Jens Axboe