Commit 655a2be8 authored by Yu Kuai's avatar Yu Kuai
Browse files

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: default avatarYu Kuai <yukuai3@huawei.com>
parent f4801a05
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 */
+1 −0
Original line number Diff line number Diff line
@@ -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