From 90e2295fb565594d9c381925ce415830ba845ba5 Mon Sep 17 00:00:00 2001 From: Yu Kuai Date: Mon, 25 Dec 2023 09:30:58 +0800 Subject: [PATCH 1/2] block: warn once for each partition in bio_check_ro() 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 (cherry picked from commit 655a2be86dd3efacbc6fd88bd7c73ff1c58b5f89) --- 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 -- Gitee From 647b4ca2bbd99bfe1b584ded0c2ef9e74ac1b514 Mon Sep 17 00:00:00 2001 From: Yu Kuai Date: Mon, 25 Dec 2023 09:30:59 +0800 Subject: [PATCH 2/2] block: fix kabi broken in struct hd_part hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8HQ3W -------------------------------- A new field is added in struct hd_part, fix kabi broken by using KABI_FILL_HOLE. Signed-off-by: Yu Kuai (cherry picked from commit 062a070f912aed7df643f71200fd4a70aa5efca4) --- include/linux/genhd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/genhd.h b/include/linux/genhd.h index de4ec8798e64..47ccd88923d1 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -69,7 +69,7 @@ struct hd_struct { struct device __dev; struct kobject *holder_dir; bool read_only; - bool ro_warned; + KABI_FILL_HOLE(bool ro_warned) int partno; struct partition_meta_info *info; #ifdef CONFIG_FAIL_MAKE_REQUEST -- Gitee