-
Notifications
You must be signed in to change notification settings - Fork 565
block: qcow: Cluster Leak Fixes #7537
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: Cluster Leak Fixes #7537
Conversation
db8285f to
0dc0367
Compare
|
Great! Is there some way to test this? |
|
Right! There was still #7527 I've been preparing separately. I was just checking that one once again and it seems the refcount leaks is what is only remaining now (rebased to include the previous data corruption fix). I can actually pull those integration test changes over here. Most of the Thanks |
|
I don't have a strong opinion - I'm slightly in favor of having the tests in the same PR. |
34b63ea to
ebbcb2e
Compare
Usually it's the norm. This deviation has been just because the initial extent of the issue was unknown, so a patch set might have become quite unwieldy. Thanks |
|
@weltling Yeh - if the tests in your other PR are now passing do please pull those into this PR and close that one. |
Yup, for what it matters the test changes are passing now, covering the actual bugfixes. I just closed the other PR. Thanks |
rbradford
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to rebase for the actions change in #7544.
When a refcount block is evicted from cache and replaced with a new one, the old refcount block cluster was added to unref_clusters but its refcount was never decremented to 0 on disk. This left the cluster with refcount=1 while no metadata referenced it, causing errors in qemu-img check `Leaked cluster X refcount=1 reference=0` This fix recursively calls set_cluster_refcount(freed_cluster, 0) to properly decrement the freed refcount block's refcount on disk. The recursion handles cascading replacements where freeing one refcount block may trigger the replacement of another. Signed-off-by: Anatol Belski <[email protected]>
When converting a compressed cluster to standard during write operations, the old compressed cluster's refcount was never decremented, causing leak warnings by `qemu-img check ..` `Leaked cluster X refcount=N reference=M` Additionally, compressed data can span multiple physical clusters, not just one. The compressed cluster address and size are encoded in the L2 entry, and the data may cross cluster boundaries. The proper handling is implemented as follows: - Extract compressed cluster address and size before overwriting L2 entry - Identify all clusters occupied by the compressed data - Decrement refcount for each cluster in the range Signed-off-by: Anatol Belski <[email protected]>
Freed clusters correctly have refcount=0. Remove the assertion that expected no clusters with zero refcount, as it was validating the buggy behavior. Signed-off-by: Anatol Belski <[email protected]>
Signed-off-by: Anatol Belski <[email protected]>
Signed-off-by: Anatol Belski <[email protected]>
The image passed for the guest construction is copied. Previously, check-img has been checking the unchanged image from the workspace dir, which is supposed to be error free. Signed-off-by: Anatol Belski <[email protected]>
ebbcb2e to
4e1aef9
Compare
Done, thanks. |
phip1611
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very great contribution, thank you!
This PR addresses cluster leaks in QCOW2 format handling through:
These fixes prevent disk space leaks when working with compressed clusters and during refcount table operations.