@@ -502,9 +502,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 (bdev_flagged(bio->bi_bdev, BD_FLAG_RO_WARNED))
+ return;
+
+ bdev_set_flag(bio->bi_bdev, BD_FLAG_RO_WARNED);
+ /*
+ * 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);
}
}
@@ -41,6 +41,7 @@ struct bio_crypt_ctx;
#define BD_FLAG_WRITE_HOLDER 1
#define BD_FLAG_HAS_SUBMIT_BIO 2
#define BD_FLAG_MAKE_IT_FAIL 3
+#define BD_FLAG_RO_WARNED 4
struct block_device {
sector_t bd_start_sect;