From patchwork Fri May 27 10:53:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9138141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E338F6075C for ; Fri, 27 May 2016 10:55:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5CD72793B for ; Fri, 27 May 2016 10:55:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CABC928135; Fri, 27 May 2016 10:55:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 88C572793B for ; Fri, 27 May 2016 10:55:17 +0000 (UTC) Received: from localhost ([::1]:45222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FQC-0004oe-NF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 06:55:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPi-0004mf-Id for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6FPb-0002Kp-Cd for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:45 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:20733 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPb-0002KN-4u; Fri, 27 May 2016 06:54:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AnBQDmJkhX/5tjdVtcHAGDHIFTpTYBAQEBAQEFAYEPAZEOgh2BeIYRAoE7OhIBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBAQYCJYVfgkaHWYUOBZg3jiCPHI9MJwwvggYcgU06MooIAQEB X-IPAS-Result: A2AnBQDmJkhX/5tjdVtcHAGDHIFTpTYBAQEBAQEFAYEPAZEOgh2BeIYRAoE7OhIBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBAQYCJYVfgkaHWYUOBZg3jiCPHI9MJwwvggYcgU06MooIAQEB X-IronPort-AV: E=Sophos;i="5.26,373,1459807200"; d="scan'208";a="64793581" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 27 May 2016 12:53:57 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1b6FOv-00066E-9y; Fri, 27 May 2016 12:53:57 +0200 Received: from ip159.dynamic.igalia.com ([192.168.10.159] helo=perseus.local) by mail.igalia.com with esmtps (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1b6FOv-0002OE-6A; Fri, 27 May 2016 12:53:57 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1b6FOv-0002Sz-3e; Fri, 27 May 2016 13:53:57 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 12:53:38 +0200 Message-Id: <3d9011151512326b890d22bdab3530244ef349d7.1464346103.git.berto@igalia.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH 3/4] block: Prevent sleeping jobs from resuming if they have been paused X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we pause a block job and drain its BlockDriverState we want that the job remains inactive until we call block_job_resume() again. However if we pause the job while it is sleeping then it will resume when the sleep timer fires. This patch prevents that from happening by checking if the job has been paused after it comes back from sleeping. Signed-off-by: Alberto Garcia Suggested-by: Kevin Wolf Reviewed-by: Max Reitz --- blockjob.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockjob.c b/blockjob.c index c095cc5..01b896b 100644 --- a/blockjob.c +++ b/blockjob.c @@ -361,10 +361,12 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns) } job->busy = false; + if (!block_job_is_paused(job)) { + co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns); + } + /* The job can be paused while sleeping, so check this again */ if (block_job_is_paused(job)) { qemu_coroutine_yield(); - } else { - co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns); } job->busy = true; }