On 3/27/19 7:17 AM, Richard W.M. Jones wrote:
>> This inner loop might be long; you could add this:
>>
>> if (req_one)
>> break;
So interestingly _no_ you can't add that here, and the reason does
reveal why the REQ_ONE flag is still hard to get right even with the
simpler implementation of extents.
Because VDDK's QueryAllocatedBlocks API only works for some very large
aligned block size (64K IIRC), we round down the requested offset
before querying VDDK. So in the inner loop the first extent we get
back might lie before the offset (before extents->start). IOW
nbdkit_add_extent has succeeded but we haven't added any extents. We
could call nbdkit_extents_count here, but technically we've said
that's a filter-only API.
Indeed - if you round down, you have to iterate at least until you've
crossed back over the original offset. Tracking that takes more coding
effort than just blindly always giving the full 64k result (which is
guaranteed to overlap, because you never rounded down more than that).
Any more coding overhead should be accompanied by benchmarks showing
that they improve performance, or we just leave things as slightly
inefficient, because...
I believe the test for req_one in the outer loop is fine, although
it
relies on QueryAllocatedBlocks not being crazy. As it's VDDK and
therefore crazy by nature
...of this ;)
maybe we should consider removing that too,
but it would then be really inefficient ...
Nah, the outer loop break is easy to justify without additional bookkeeping.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org