From patchwork Tue Mar 22 15:33:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8643771 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9C1E9F44D for ; Tue, 22 Mar 2016 15:36:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E7FD2037F for ; Tue, 22 Mar 2016 15:36:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61A56201FA for ; Tue, 22 Mar 2016 15:36:20 +0000 (UTC) Received: from localhost ([::1]:37835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiOLz-0002Mv-QZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Mar 2016 11:36:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiOJh-0006yh-Ar for qemu-devel@nongnu.org; Tue, 22 Mar 2016 11:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiOJb-0003nO-Gh for qemu-devel@nongnu.org; Tue, 22 Mar 2016 11:33:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiOJT-0003ku-Fd; Tue, 22 Mar 2016 11:33:43 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 2507D90E51; Tue, 22 Mar 2016 15:33:43 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2MFXNXu020137; Tue, 22 Mar 2016 11:33:41 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 22 Mar 2016 16:33:12 +0100 Message-Id: <1458660792-3035-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1458660792-3035-1-git-send-email-kwolf@redhat.com> References: <1458660792-3035-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/12] block: Don't check throttled reqs in bdrv_requests_pending() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Checking whether there are throttled requests requires going to the associated BlockBackend, which we want to avoid. All users of bdrv_requests_pending() already call bdrv_flush_io_queue() first, which restarts throttled requests. We just have to use the return value of that callback (which tells us whether any requests have been restarted) instead of ignoring it. Signed-off-by: Kevin Wolf --- block/io.c | 22 ++++++++++------------ include/block/block.h | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/block/io.c b/block/io.c index f6edab8..24bdd6c 100644 --- a/block/io.c +++ b/block/io.c @@ -153,17 +153,10 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs) bool bdrv_requests_pending(BlockDriverState *bs) { BdrvChild *child; - BlockBackendPublic *blkp = bs->blk ? blk_get_public(bs->blk) : NULL; if (!QLIST_EMPTY(&bs->tracked_requests)) { return true; } - if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[0])) { - return true; - } - if (blkp && !qemu_co_queue_empty(&blkp->throttled_reqs[1])) { - return true; - } QLIST_FOREACH(child, &bs->children, next) { if (bdrv_requests_pending(child->bs)) { @@ -204,8 +197,8 @@ void bdrv_drain(BlockDriverState *bs) bdrv_drain_recurse(bs); while (busy) { /* Keep iterating */ - bdrv_flush_io_queue(bs); - busy = bdrv_requests_pending(bs); + busy = bdrv_flush_io_queue(bs); + busy |= bdrv_requests_pending(bs); busy |= aio_poll(bdrv_get_aio_context(bs), busy); } } @@ -254,7 +247,9 @@ void bdrv_drain_all(void) aio_context_acquire(aio_context); while ((bs = bdrv_next(bs))) { if (aio_context == bdrv_get_aio_context(bs)) { - bdrv_flush_io_queue(bs); + if (bdrv_flush_io_queue(bs)) { + busy = true; + } if (bdrv_requests_pending(bs)) { busy = true; aio_poll(aio_context, busy); @@ -2639,10 +2634,11 @@ void bdrv_io_unplug(BlockDriverState *bs) } } -void bdrv_flush_io_queue(BlockDriverState *bs) +bool bdrv_flush_io_queue(BlockDriverState *bs) { BlockDriver *drv = bs->drv; BdrvChild *c; + bool new_request = false; if (drv && drv->bdrv_flush_io_queue) { drv->bdrv_flush_io_queue(bs); @@ -2652,9 +2648,11 @@ void bdrv_flush_io_queue(BlockDriverState *bs) QLIST_FOREACH(c, &bs->parents, next_parent) { if (c->role->drain_queue) { - c->role->drain_queue(c); + new_request |= c->role->drain_queue(c); } } + + return new_request; } void bdrv_drained_begin(BlockDriverState *bs) diff --git a/include/block/block.h b/include/block/block.h index 80ece12..46cee8e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -513,7 +513,7 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); -void bdrv_flush_io_queue(BlockDriverState *bs); +bool bdrv_flush_io_queue(BlockDriverState *bs); /** * bdrv_drained_begin: