[Libguestfs] [PATCH nbdkit 6/7] cache: Add cache-min-block-size parameter

Martin Kletzander mkletzan at redhat.com
Wed Aug 4 13:27:59 UTC 2021


On Wed, Aug 04, 2021 at 11:07:32AM +0100, Richard W.M. Jones wrote:
>On Wed, Aug 04, 2021 at 10:47:34AM +0200, Martin Kletzander wrote:
>> >+# Run nbdkit with the caching filter.
>> >+start_nbdkit -P cache-block-size.pid -U $sock --filter=cache \
>> >+             file cache-block-size.img cache-min-block-size=64K
>> >+
>> >+nbdsh --connect "nbd+unix://?socket=$sock" \
>> >+      -c '
>> >+# Write some pattern data to the overlay and check it reads back OK.
>> >+buf = b"abcd" * 16384
>> >+h.pwrite(buf, 32768)
>> >+zero = h.pread(32768, 0)
>> >+assert zero == bytearray(32768)
>> >+buf2 = h.pread(65536, 32768)
>> >+assert buf == buf2
>> >+
>> >+# Flushing should write through to the underlying file.
>> >+h.flush()
>> >+
>> >+with open("cache-block-size.img", "rb") as file:
>> >+    zero = file.read(32768)
>> >+    assert zero == bytearray(32768)
>> >+    buf2 = file.read(65536)
>> >+    assert buf == buf2
>> >+'
>>
>>
>> I do not see how this checks that the min block size is respected.  I
>> would expect something along the lines of:
>>
>> 1) read 32k
>> 2) write to the underlying file past those 32k
>> 3) read another 32k (from offset == 32k)
>> 4) check that the last read returned original data and not those written
>>    in step 2)
>
>Yes this test is not great.  I think it was basically copied from this
>one:
>
>https://gitlab.com/nbdkit/nbdkit/-/blob/master/tests/test-cache.sh
>
>I'll see if I can rethink this once I've got the v2v stuff out of the
>way unless someone else comes up with a fix.
>

I think I have a patch that tests exactly, but it fails for another
reason (together with other patches) and I do not know what the reason
for that is.  I'll try to figure that out or test it on fedora 34 and
will send the patch later.

>Rich.
>
>-- 
>Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
>Read my programming and virtualization blog: http://rwmj.wordpress.com
>virt-top is 'top' for virtual machines.  Tiny program with many
>powerful monitoring features, net stats, disk stats, logging, etc.
>http://people.redhat.com/~rjones/virt-top
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20210804/b5348bc6/attachment.sig>


More information about the Libguestfs mailing list