From: Yu Kuai yukuai3@huawei.com
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8HQ3W
--------------------------------
If underlying disk of raid/dm is set to read only, then each write will trigger a warn in bio_check_ro(), cause message storm.
Fix it by generating such warn only once for each partition.
Signed-off-by: Yu Kuai yukuai3@huawei.com --- block/blk-core.c | 5 +++++ include/linux/genhd.h | 1 + 2 files changed, 6 insertions(+)
diff --git a/block/blk-core.c b/block/blk-core.c index 01f0782668ce..71546ea13ecc 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -713,6 +713,11 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio)) return false; + + if (part->ro_warned) + return false; + + part->ro_warned = true; pr_warn("Trying to write to read-only block-device %s (partno %d)\n", bio_devname(bio, b), part->partno); /* Older lvm-tools actually trigger this */ diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 1d7d5aa73760..de4ec8798e64 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -69,6 +69,7 @@ struct hd_struct { struct device __dev; struct kobject *holder_dir; bool read_only; + bool ro_warned; int partno; struct partition_meta_info *info; #ifdef CONFIG_FAIL_MAKE_REQUEST