From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
Denis Lunev <den@virtuozzo.com>,
"armbru@redhat.com" <armbru@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Denis Plotnikov <dplotnikov@virtuozzo.com>,
"mreitz@redhat.com" <mreitz@redhat.com>
Subject: Re: [PATCH v7 1/2] docs: improve qcow2 spec about extending image header
Date: Fri, 18 Oct 2019 13:54:18 +0000 [thread overview]
Message-ID: <8a039893-93df-aef2-3223-b5f9829c2047@virtuozzo.com> (raw)
In-Reply-To: <37a0d4f3-6967-1115-fbea-43d5ce5c6973@redhat.com>
18.10.2019 16:39, Eric Blake wrote:
> On 10/18/19 4:27 AM, Vladimir Sementsov-Ogievskiy wrote:
>
>>>>> I would suggest a stronger requirement:
>>>>>
>>>>> header_length must be a multiple of 4, and must not land in the middle of any optional 8-byte field.
>>>>>
>>>>> Or maybe even add our compression type extension with 4 bytes of padding, so that we could go even stronger:
>>>>>
>>>>> header_length must be a multiple of 8.
>>>>
>>>> Hmm, if we imply that software will have to add some padding, than requirement above about zero === feature-absence
>>>> becomes necessary. [*]
>>>>
>>>> Still I have two questions:
>>>> 1. Do we really need all fields to be 4 or 8 bytes? Why not use 1 byte for compression?
>
> No, fields can be smaller if that makes sense; but I still think it's important that fields don't straddle natural alignment boundaries. When adding just one field at a time, it's easier to add a wide field and less padding than a narrow field and lots of padding, if we're still striving for alignment.
>
>>>> 2. What is the benefit of padding, which you propose?
>
> The biggest benefit to keeping large fields from straddling alignment boundaries is that you can mmap() a qcow2 file and do naturally-aligned reads of those large fields, rather than byte-by-byte reads, without risking SIGBUS on some architectures. (You still have to worry about endianness, but that's true regardless of alignment)
>
>
>>> So, it looks inconsistent, if we pad all header extensions to 8 bytes except for the start of the first extension.
>>>
>>> I'll resend with padding soon.
>>
>>
>> Still, we have to make an exception at least for header_length = 104, which is not a multiply of 8.
>
> Huh? 104 == 8 * 13, so our current v3 header size is 8-byte aligned. Likewise for 72 == 8 * 9 for v2 header size.
Ahahahaha, shame on my head:) I should go to school again.
>
>>
>> Also, is requiring alignment is an incompatible change of specification?
>
> No. I think it is just clarifying what was implicitly already the case. Remember, immediately after the header comes header extensions, and THOSE are explicitly required to be multiple-of-8 in size. That requirement makes no sense unless the header itself ends on an 8-byte alignment (which it does for all existing v2 and v3 images prior to our first official v3 header extension).
>
OK, let's go with it, I'll resend again.
--
Best regards,
Vladimir
next prev parent reply other threads:[~2019-10-18 14:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 16:04 [PATCH v7 0/2] qcow2: add zstd cluster compression Vladimir Sementsov-Ogievskiy
2019-10-07 16:04 ` [PATCH v7 1/2] docs: improve qcow2 spec about extending image header Vladimir Sementsov-Ogievskiy
2019-10-07 20:21 ` Eric Blake
2019-10-08 9:05 ` Vladimir Sementsov-Ogievskiy
2019-10-18 8:29 ` Vladimir Sementsov-Ogievskiy
2019-10-18 9:27 ` Vladimir Sementsov-Ogievskiy
2019-10-18 13:39 ` Eric Blake
2019-10-18 13:54 ` Vladimir Sementsov-Ogievskiy [this message]
2019-10-07 16:04 ` [PATCH v7 2/2] docs: qcow2: introduce compression type feature Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a039893-93df-aef2-3223-b5f9829c2047@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).