On 04/25/2018 09:44 AM, Max Reitz wrote: > Here's what you do: > (1) Create a 513 TB image with cluster_size=2M,refcount_bits=1 > (2) Take a hex editor and enter 16 refblocks into the reftable > (3) Fill all of those refblocks with 1s > > (Funny side note: qemu-img check thinks that image is clean because it > doesn't check refcounts beyond the image end...) > > I've attached a compressed test image (unsurprisingly, it compresses > really well). > > Before this series: > $ ./qemu-io -c 'write -c 0 2M' test.qcow2 > qcow2: Marking image as corrupt: Preventing invalid write on metadata > (overlaps with refcount block); further corruption events will be suppressed > write failed: Input/output error > > Aw. > > After this series: > $ ./qemu-io -c 'write -c 0 2M' test.qcow2 > write failed: Input/output error
Hmm, I wonder if ENOSPC is a better failure than EIO if the reason we can't write a compressed cluster is because the image has grown too large. > > (Normal writes just work fine.) I also wonder if there should be a knob to control whether attempts to write a compressed cluster should fail vs. silently fall back to a normal write when encountering this too-large situation (that is, a trade-off between keeping guest writes working no matter what, even if we lose out on compression savings, vs. learning as soon as possible when compression is no longer possible). Then again, other than carefully-crafted super-sparse files, it's much harder to argue that you'll hit this in real usage scenarios, so it may not be worth the effort. > > > Maybe you want to add a test still -- creating the image is rather quick > (well, you have to write 64 MB of 1s, but other than that). The only > thing that takes a bit of time is qemu figuring out where the first free > cluster is... That takes like 15 seconds here. > > And another issue of course is... > > $ ls -lhs test.qcow2 > 42M -rw-r--r--. 1 maxx maxx 513T 25. Apr 16:42 test.qcow2 > > Yeah, that. Depends on the host file system, of course, whether that is > a real issue. O:-) Well, I'm writing the iotest now, and thus will post a v6 of this series. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature