Skip to content

Commit 67d995e

Browse files
YuKuai-huaweiaxboe
authored andcommitted
block: warn once for each partition in bio_check_ro()
Commit 1b0a151 ("blk-core: use pr_warn_ratelimited() in bio_check_ro()") fix message storm by limit the rate, however, there will still be lots of message in the long term. Fix it better by warn once for each partition. Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent fad907c commit 67d995e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

block/blk-core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,17 @@ static inline void bio_check_ro(struct bio *bio)
501501
if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) {
502502
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
503503
return;
504-
pr_warn_ratelimited("Trying to write to read-only block-device %pg\n",
505-
bio->bi_bdev);
506-
/* Older lvm-tools actually trigger this */
504+
505+
if (bio->bi_bdev->bd_ro_warned)
506+
return;
507+
508+
bio->bi_bdev->bd_ro_warned = true;
509+
/*
510+
* Use ioctl to set underlying disk of raid/dm to read-only
511+
* will trigger this.
512+
*/
513+
pr_warn("Trying to write to read-only block-device %pg\n",
514+
bio->bi_bdev);
507515
}
508516
}
509517

include/linux/blk_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct block_device {
7070
#ifdef CONFIG_FAIL_MAKE_REQUEST
7171
bool bd_make_it_fail;
7272
#endif
73+
bool bd_ro_warned;
7374
/*
7475
* keep this out-of-line as it's both big and not needed in the fast
7576
* path

0 commit comments

Comments
 (0)