Received: from eggs.gnu.org ([2001:4830:134:3::10]:35222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1extHP-0004It-TZ for qemu-devel@nongnu.org; Mon, 19 Mar 2018 07:48:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1extHN-0003XS-BV for qemu-devel@nongnu.org; Mon, 19 Mar 2018 07:48:43 -0400 From: Alberto Garcia In-Reply-To: <1520849818-6915-6-git-send-email-anton.nefedov@virtuozzo.com> References: <1520849818-6915-1-git-send-email-anton.nefedov@virtuozzo.com> <1520849818-6915-6-git-send-email-anton.nefedov@virtuozzo.com> Date: Mon, 19 Mar 2018 12:02:24 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v8 5/9] block: treat BDRV_REQ_ALLOCATE as serialising List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anton Nefedov , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com, den@virtuozzo.com 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 Reviewed-by: Alberto Garcia > @@ -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