From: Yu Kuai <yukuai3@huawei.com>
Which means there is a BUG for related bio-based disk driver, or blk-mq
for rq-based disk, it's better not to hide the BUG.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
block/genhd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index f671d9ee00c4..d158c25237b6 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -136,9 +136,9 @@ static void part_in_flight_rw(struct block_device *part,
inflight[0] += part_stat_local_read_cpu(part, in_flight[0], cpu);
inflight[1] += part_stat_local_read_cpu(part, in_flight[1], cpu);
}
- if ((int)inflight[0] < 0)
+ if (WARN_ON_ONCE((int)inflight[0] < 0))
inflight[0] = 0;
- if ((int)inflight[1] < 0)
+ if (WARN_ON_ONCE((int)inflight[1] < 0))
inflight[1] = 0;
}
--
2.39.2
On 4/27/25 10:29, Yu Kuai wrote: > From: Yu Kuai <yukuai3@huawei.com> > > Which means there is a BUG for related bio-based disk driver, or blk-mq > for rq-based disk, it's better not to hide the BUG. > > Signed-off-by: Yu Kuai <yukuai3@huawei.com> > --- > block/genhd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > Please make 'BUG' lowercase. Otherwise: Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
On 27/04/2025 09:29, Yu Kuai wrote: > From: Yu Kuai <yukuai3@huawei.com> > > Which means there is a BUG nit: to me, BUG means symbol BUG(), and not a software bug (which I think that you mean) > for related bio-based disk driver, or blk-mq > for rq-based disk, it's better not to hide the BUG. AFICS, this check was not present for mq, so is it really required now? I suppose that the code is simpler to always have the check. I find it an odd check to begin with... > > Signed-off-by: Yu Kuai <yukuai3@huawei.com> > --- > block/genhd.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/block/genhd.c b/block/genhd.c > index f671d9ee00c4..d158c25237b6 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -136,9 +136,9 @@ static void part_in_flight_rw(struct block_device *part, > inflight[0] += part_stat_local_read_cpu(part, in_flight[0], cpu); > inflight[1] += part_stat_local_read_cpu(part, in_flight[1], cpu); > } > - if ((int)inflight[0] < 0) > + if (WARN_ON_ONCE((int)inflight[0] < 0)) > inflight[0] = 0; > - if ((int)inflight[1] < 0) > + if (WARN_ON_ONCE((int)inflight[1] < 0)) > inflight[1] = 0; > } >
Hi, 在 2025/04/28 22:06, John Garry 写道: > On 27/04/2025 09:29, Yu Kuai wrote: >> From: Yu Kuai <yukuai3@huawei.com> >> >> Which means there is a BUG > > nit: to me, BUG means symbol BUG(), and not a software bug (which I > think that you mean) Actually, I mean the bio-based disk driver or blk-mq messed up the IO accounting, IO done is more than IO start, and this is a bug. > >> for related bio-based disk driver, or blk-mq >> for rq-based disk, it's better not to hide the BUG. > > AFICS, this check was not present for mq, so is it really required now? > I suppose that the code is simpler to always have the check. I find it > an odd check to begin with... This check do present for mq, for example, diskstats_show() and update_io_ticks(). Thanks, Kuai > >> >> Signed-off-by: Yu Kuai <yukuai3@huawei.com> >> --- >> block/genhd.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/block/genhd.c b/block/genhd.c >> index f671d9ee00c4..d158c25237b6 100644 >> --- a/block/genhd.c >> +++ b/block/genhd.c >> @@ -136,9 +136,9 @@ static void part_in_flight_rw(struct block_device >> *part, >> inflight[0] += part_stat_local_read_cpu(part, in_flight[0], >> cpu); >> inflight[1] += part_stat_local_read_cpu(part, in_flight[1], >> cpu); >> } >> - if ((int)inflight[0] < 0) >> + if (WARN_ON_ONCE((int)inflight[0] < 0)) >> inflight[0] = 0; >> - if ((int)inflight[1] < 0) >> + if (WARN_ON_ONCE((int)inflight[1] < 0)) >> inflight[1] = 0; >> } > > > . >
On 29/04/2025 02:43, Yu Kuai wrote: > accounting, IO done is more than IO start, and this is a bug. >> >>> for related bio-based disk driver, or blk-mq >>> for rq-based disk, it's better not to hide the BUG. >> >> AFICS, this check was not present for mq, so is it really required >> now? I suppose that the code is simpler to always have the check. I >> find it an odd check to begin with... > > This check do present for mq, for example, diskstats_show() and > update_io_ticks(). ok, I just noticed this in part_inflight_show() -> blk_mq_in_flight_rw(), which didn't have such a check. I think that is because we expect the tagset iter to provide a sane count value. Thanks, John
© 2016 - 2025 Red Hat, Inc.