[Devel] [PATCH hci-8.1 v2 2/3] drivers/md/dm-qcow2: fail writes to a read-only table
Alexander Ivanov
alexander.ivanov at virtuozzo.com
Thu Oct 29 17:43:57 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 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index bc317c8db3a6..1c269a78ad35 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -4506,6 +4506,10 @@ int qcow2_clone_and_map(struct dm_target *ti, struct request *rq,
struct qcow2_rq *qrq;
struct qio *qio;
+ 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