From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO30v-00027Y-IG for qemu-devel@nongnu.org; Fri, 05 Apr 2013 05:33:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UO30n-0007U8-4M for qemu-devel@nongnu.org; Fri, 05 Apr 2013 05:32:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO30m-0007Tt-Sy for qemu-devel@nongnu.org; Fri, 05 Apr 2013 05:32:45 -0400 From: Stefan Hajnoczi Date: Fri, 5 Apr 2013 11:32:22 +0200 Message-Id: <1365154342-10513-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1365154342-10513-1-git-send-email-stefanha@redhat.com> References: <1365154342-10513-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v2 4/4] block: clean up I/O throttling wait_time code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?Beno=C3=AEt=20Canet?= , Stefan Hajnoczi , Zhi Yong Wu 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 Tested-By: Benoit Canet --- block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index aa16fc4..602d8a4 100644 --- a/block.c +++ b/block.c @@ -3800,7 +3800,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; @@ -3841,7 +3841,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; @@ -3852,7 +3852,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; -- 1.8.1.4