Re: [PATCH 05/10] block: do not reassig ->bi_bdev when partition remapping

Christoph Hellwig
2021-01-25T18:22:34Z

On Mon, Jan 25, 2021 at 11:19:23AM -0700, Jens Axboe wrote:
> On 1/25/21 11:18 AM, Christoph Hellwig wrote:
> > On Mon, Jan 25, 2021 at 11:15:04AM -0700, Jens Axboe wrote:
> >> On 1/25/21 11:13 AM, Christoph Hellwig wrote:
> >>> On Mon, Jan 25, 2021 at 11:03:24AM -0700, Jens Axboe wrote:
> >>>> Partition table entries are not in disk order.
> >>>
> >>> And the issue shows up with the series just up to the this patch,
> >>> without any later patches?
> >>
> >> At that patch specifically. I bisected it, and then I double checked
> >> by running the previous commit (boots fine), then apply this one, and
> >> then I run into that error. So it should be 100% reliable.
> >
> > Ok, I have an idea. With EOD message you mean this printk, right:
> >
> > pr_info_ratelimited("attempt to access beyond end of device\n"
> > "%s: rw=%d, want=%llu, limit=%llu\n",
> > ...
> >
> > right?
>
> Yep

Can you give this untested patch a spin? This should fix the
case where we check the eod for the original partition with the
remapped bi_sectors. Looking into a local reproducer now.

diff --git a/block/blk-core.c b/block/blk-core.c
index 88f60890443264..6253a2f9a1c08f 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -813,13 +813,16 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)

if (should_fail_bio(bio))
goto end_io;
+
if (unlikely(bio_check_ro(bio)))
goto end_io;
- if (unlikely(bio_check_eod(bio)))
- goto end_io;
- if (bio->bi_bdev->bd_partno && !bio_flagged(bio, BIO_REMAPPED) &&
- unlikely(blk_partition_remap(bio)))
- goto end_io;
+ if (!bio_flagged(bio, BIO_REMAPPED)) {
+ if (unlikely(bio_check_eod(bio)))
+ goto end_io;
+ if (bio->bi_bdev->bd_partno &&
+ unlikely(blk_partition_remap(bio)))
+ goto end_io;
+ }

/*
* Filter flush bio's early so that bio based drivers without flush