On Mon 12 Mar 2018 11:16:54 AM CET, Anton Nefedov wrote: > The idea is that ALLOCATE requests may overlap with other requests. > Reuse the existing block layer infrastructure for serialising requests. > Use the following approach: > - mark ALLOCATE serialising, so subsequent requests to the area wait > - ALLOCATE request itself must never wait if another request is in flight > already. Return EAGAIN, let the caller reconsider. > > Signed-off-by: Anton Nefedov <anton.nefe...@virtuozzo.com>
Reviewed-by: Alberto Garcia <be...@igalia.com> > @@ -1498,8 +1507,13 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild > *child, > max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, > INT_MAX), > align); > > - waited = wait_serialising_requests(req); > - assert(!waited || !req->serialising); > + found = find_or_wait_serialising_requests(req, > + !(flags & BDRV_REQ_ALLOCATE)); > + if (found && (flags & BDRV_REQ_ALLOCATE)) { > + return -EAGAIN; > + } > + Another alternative (perhaps a bit more readable): if (flags & BDRV_REQ_ALLOCATE) { if (find_or_wait_serialising_requests(req, false)) { return -EAGAIN; } } else { bool found = wait_serialising_requests(req); assert(!found || !req->serialising); } but yours is fine, so keep it if you prefer. Berto