[Devel] [PATCH hci-8.1 2/3] drivers/md/dm-qcow2: fail writes to a read-only table
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Wed Oct 28 13:35:47 MSK 2026
On 10/23/26 15:20, Alexander Ivanov wrote:
> 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 */
Let's not litter the code with the useless comments. Killing write
request on non-write device does not need any extra info.
> + 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;
More information about the Devel
mailing list