From patchwork Thu Mar 21 14:49:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 229723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A234D2C00C3 for ; Fri, 22 Mar 2013 01:51:26 +1100 (EST) Received: from localhost ([::1]:52865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIgpw-0003I9-Sm for incoming@patchwork.ozlabs.org; Thu, 21 Mar 2013 10:51:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIgp6-0003AC-SY for qemu-devel@nongnu.org; Thu, 21 Mar 2013 10:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIgp2-0002Hq-AM for qemu-devel@nongnu.org; Thu, 21 Mar 2013 10:50:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIgp2-0002HQ-33 for qemu-devel@nongnu.org; Thu, 21 Mar 2013 10:50:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2LEoLBu013029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 21 Mar 2013 10:50:22 -0400 Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2LEoKRo030633; Thu, 21 Mar 2013 10:50:21 -0400 From: Stefan Hajnoczi To: Date: Thu, 21 Mar 2013 15:49:59 +0100 Message-Id: <1363877399-16339-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1363877399-16339-1-git-send-email-stefanha@redhat.com> References: <1363877399-16339-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , =?UTF-8?q?Beno=C3=AEt=20Canet?= , Stefan Hajnoczi , Zhi Yong Wu Subject: [Qemu-devel] [RFC 4/4] block: clean up I/O throttling wait_time code 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The wait_time variable is in seconds. Reflect this in a comment and use NANOSECONDS_PER_SECOND instead of BLOCK_IO_SLICE_TIME * 10 (which happens to have the right value). Signed-off-by: Stefan Hajnoczi --- block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index fed3b4d..ff862a0 100644 --- a/block.c +++ b/block.c @@ -3698,7 +3698,7 @@ static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors, BLOCK_IO_SLICE_TIME; bs->slice_end += extension; if (wait) { - *wait = wait_time * BLOCK_IO_SLICE_TIME * 10; + *wait = wait_time * NANOSECONDS_PER_SECOND; } return true; @@ -3740,7 +3740,7 @@ static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, return false; } - /* Calc approx time to dispatch */ + /* Calc approx time to dispatch, in seconds */ wait_time = (ios_base + 1) / iops_limit; if (wait_time > elapsed_time) { wait_time = wait_time - elapsed_time; @@ -3751,7 +3751,7 @@ static bool bdrv_exceed_iops_limits(BlockDriverState *bs, bool is_write, /* Exceeded current slice, extend it by another slice time */ bs->slice_end += BLOCK_IO_SLICE_TIME; if (wait) { - *wait = wait_time * BLOCK_IO_SLICE_TIME * 10; + *wait = wait_time * NANOSECONDS_PER_SECOND; } return true;