-
Notifications
You must be signed in to change notification settings - Fork 565
block: qcow: Set OFLAG_COPIED bit in L1 entries for QCOW2 spec compli… #7526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
block: qcow: Set OFLAG_COPIED bit in L1 entries for QCOW2 spec compli… #7526
Conversation
|
Thanks for your contribution! @ all: Shouldn't #7506 help us to discover such issues? |
11079a0 to
c478e3e
Compare
The OFLAG_COPIED bit (bit 63) indicates a cluster's refcount is exactly 1 and doesn't need copy-on-write. This bit must be set in L1 entries when their referenced L2 clusters have refcount=1. Previously, L1 entries were always written as raw addresses without the OFLAG_COPIED bit, violating the QCOW2 specification and causing qemu-img check to report errors like `ERROR OFLAG_COPIED L2 cluster: l1_index=X .... refcount=1` The implementation queries each L2 cluster's refcount in sync_caches() and sets OFLAG_COPIED appropriately when writing the L1 table. This ensures QCOW2 images are specification compliant and maintain correct COW semantics to avoid data corruption. Signed-off-by: Anatol Belski <[email protected]>
Absolutely. There is yet one issue I'm tracking. I'll plan to extend the tests with the corresponding test cases to cover the mentioned issue. Thanks |
c478e3e to
5b6c14b
Compare
Yes, please extend the test in the same PR if possible. |
Here's the actual output from There are actually 2 distinct issues here:
Adding tests in this PR would still fail because
This way the tests will pass cleanly once both issues are resolved. Thanks |
5b6c14b to
5a0a48b
Compare
|
Strangely, I don't get a seccomp violation while running this locally :/ |
6df537d to
3c22199
Compare
Your new code calls If you want to make the write function take an iterator, why not keep most of the original code and not call the |
|
Well, it looks like the |
Thanks |
Yeah, it uses Thanks |
3c22199 to
5b6c14b
Compare
ACK. I reverted back to the previous version. It's a good experiment and I agree rewriting this part to reduce temp allocations should be a separate concerted effort. Thanks! |
|
BTW I also had some considerations about the memory impart in this case. The size of the L1 table depends on the disk and cluster size. Say, with a disk of 100GB L1 table could grow to something like 2KB. I guess, a While doing the callback solution, I also had an idea about how to make it not requiring passing the file handle. As the file handle is needed for refcounts, one colud gather refcounts and pass it to that callback. In that case, it would be a Of course, not having a temporary vector is the best for production case. In the future we colud consider to either minimize the memory usage by worknig out a iterator+callback based solution or moving to a simple solution with Thanks |
6897c2a
…ance
The OFLAG_COPIED bit (bit 63) indicates a cluster's refcount is exactly 1 and doesn't need copy-on-write. This bit must be set in L1 entries when their referenced L2 clusters have refcount=1.
Previously, L1 entries were always written as raw addresses without the OFLAG_COPIED bit, violating the QCOW2 specification and causing qemu-img check to report errors like
ERROR OFLAG_COPIED L2 cluster: l1_index=X .... refcount=1The implementation queries each L2 cluster's refcount in sync_caches() and sets OFLAG_COPIED appropriately when writing the L1 table. This ensures QCOW2 images are specification compliant and maintain correct COW semantics to avoid data corruption.