On Wed, Nov 27, 2019 at 9:46 PM Eric Blake <[email protected]> wrote:
>
> On 11/27/19 1:35 PM, Eric Blake wrote:
>
> >> Changing this to:
> >>
> >>          extents = []
> >>          pos = 0
> >>
> >>          while pos < size:
> >>              res = c.extents(pos, size - pos)["base:allocation"]
> >>              for ext in res:
> >>                  pos += ext.length
> >>                  extents.append(ext)
> >>
> >> Solves the issue:
> >> https://travis-ci.org/nirs/ovirt-imageio/jobs/617846324
> >>
> >> So I guess I answered my question but I would like to get
> >> your opinion anyway.
> >
> > Correct, the behavior is spec-compliant, even if annoying that it
> > doesn't make as much forward progress as is possible.  Writing a loop in
> > the client is the correct behavior (the spec guarantees forward progress
> > on success, so at least that aspect of writing a loop is easier).
>
> Oh, one other thing - your loop happens to work for your test case, but
> will be thrown off if you ever get the same status in successive calls.
> A more robust loop will coalesce consecutive ranges with the same status
> before doing any comparison of whether the overall array matches an
> expected pattern.

Yes, I found this issue when querying qcow2 images, partly allocated
cluster returns consecutive extents with same flags.

Currently writing 64k to avoid this issue for this test. I hope to keep the
test simple.

We will have to handle this in the code reporting the extents to the user so
users do not have to deal with these issues.

Nir


Reply via email to