diff options
author | Yu Kuai <yukuai3@huawei.com> | 2023-11-28 20:30:27 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-20 11:51:38 +0100 |
commit | da29e4012f4133a68dca8012b38970ea9212e9f0 (patch) | |
tree | 3d69c384e1df287d077dcfe9c17d8eb9ced41999 /block | |
parent | 0c7df8c241ff066b19782100f6bfc288144d7a38 (diff) | |
download | linux-stable-da29e4012f4133a68dca8012b38970ea9212e9f0.tar.gz linux-stable-da29e4012f4133a68dca8012b38970ea9212e9f0.tar.bz2 linux-stable-da29e4012f4133a68dca8012b38970ea9212e9f0.zip |
block: warn once for each partition in bio_check_ro()
[ Upstream commit 67d995e069535c32829f5d368d919063492cec6e ]
Commit 1b0a151c10a6 ("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 <yukuai3@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231128123027.971610-3-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index fdf25b8d6e78..2eca76ccf4ee 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -501,9 +501,17 @@ static inline void bio_check_ro(struct bio *bio) if (op_is_write(bio_op(bio)) && bdev_read_only(bio->bi_bdev)) { if (op_is_flush(bio->bi_opf) && !bio_sectors(bio)) return; - pr_warn_ratelimited("Trying to write to read-only block-device %pg\n", - bio->bi_bdev); - /* Older lvm-tools actually trigger this */ + + if (bio->bi_bdev->bd_ro_warned) + return; + + bio->bi_bdev->bd_ro_warned = true; + /* + * Use ioctl to set underlying disk of raid/dm to read-only + * will trigger this. + */ + pr_warn("Trying to write to read-only block-device %pg\n", + bio->bi_bdev); } } |