[Devel] [PATCH hci-8.1 2/3] drivers/md/dm-qcow2: fail writes to a read-only table

Alexander Ivanov alexander.ivanov at virtuozzo.com
Fri Oct 23 16:20:07 MSK 2026


bio_check_ro() only warns about a write to a read-only disk and lets it
through. dm-qcow2 then allocates clusters in the top image although
the table is read-only. The header is not updated for a read-only
table, so enabled persistent bitmaps stay marked consistent while the
image data changes under them.

Kill write requests in .clone_and_map when the table is read-only.

https://virtuozzo.atlassian.net/browse/VSTOR-138887
Feature: dm-qcow2: block device over QCOW2 files driver

Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
 drivers/md/dm-qcow2-map.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 54b3a345f927..26fdfce09aa7 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4506,6 +4506,11 @@ int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
 	struct qcow2_rq *qrq;
 	struct qio *qio;
 
+	/* The block layer only warns about writes to a read-only disk */
+	if (op_is_write(req_op(rq)) &&
+	    !(dm_table_get_mode(ti->table) & BLK_OPEN_WRITE))
+		return DM_MAPIO_KILL;
+
 	qrq = mempool_alloc(tgt->qrq_pool, GFP_ATOMIC);
 	if (!qrq)
 		return DM_MAPIO_KILL;
-- 
2.53.0



More information about the Devel mailing list