[Devel] [PATCH hci-8.1 1/3] drivers/md/dm-qcow2: treat images of a read-only table as read-only

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 29 14:36:55 MSK 2026


> then dm-qcow2 truncates the unaligned image tail on every .ctr and
> .preresume and considers the image writable on the I/O and discard
> paths.

then dm-qcow2 pads the unaligned image tail on .ctr and .preresume and
considers the image writable on the discard and merge paths.

qcow2_truncate_safe() extends the file to PAGE_ALIGN(file_size), it
cuts nothing, and only while the tail is unaligned. The plain write
path never consults qcow2_file_is_writable(), it goes through
qio_may_modify_image(), which is true for every non-merge qio; the
helper gates only discard, prepare_backward_merge(), the merge
read-ahead and the header/padding sites.

> -             mode = qcow2->file->f_mode;
> -             if (pos == qcow2->file_size && !(mode & FMODE_WRITE)) {
> +             if (pos == qcow2->file_size && !qcow2_file_is_writable(qcow2)) {

Optional, while you are here: the comment above, "Read near EOF? See
qcow2_attach_file()", points at the wrong function. The padding that
makes a short read possible is in qcow2_parse_header().

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team




More information about the Devel mailing list