summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2025-05-06 20:48:56 +0800
committerYu Kuai <yukuai3@huawei.com>2025-05-10 16:06:12 +0800
commitf5482ee5edb9a7aeb020e5896efab67dc0417215 (patch)
treefe55e6b590d3e367cf143b7f1e840cbc269e4f97
parent5b8f19aee47414b4cf76b6ea0310b2937ebb97e7 (diff)
block: WARN if bdev inflight counter is negative
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. Link: https://lore.kernel.org/linux-raid/20250506124903.2540268-3-yukuai1@huaweicloud.com Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: John Garry <john.g.garry@oracle.com>
-rw-r--r--block/genhd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 1df776e4ef92..6d133061ea3d 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;
}