From patchwork Thu May 19 15:22:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9127891 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 259D660453 for ; Thu, 19 May 2016 15:49:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18E85280BB for ; Thu, 19 May 2016 15:49:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC91281CE; Thu, 19 May 2016 15:49:39 +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 84648280BB for ; Thu, 19 May 2016 15:49:38 +0000 (UTC) Received: from localhost ([::1]:51075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3QCf-00049h-DP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 11:49:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Pmx-0005j2-W6 for qemu-devel@nongnu.org; Thu, 19 May 2016 11:23:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3Pmr-0000eX-PS for qemu-devel@nongnu.org; Thu, 19 May 2016 11:23:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Pmg-0000OG-Hm; Thu, 19 May 2016 11:22:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33BA76331B; Thu, 19 May 2016 15:22:46 +0000 (UTC) Received: from noname.str.redhat.com. (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4JFMEBK025145; Thu, 19 May 2016 11:22:45 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 19 May 2016 17:22:09 +0200 Message-Id: <1463671329-22655-32-git-send-email-kwolf@redhat.com> In-Reply-To: <1463671329-22655-1-git-send-email-kwolf@redhat.com> References: <1463671329-22655-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 19 May 2016 15:22:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 31/31] qemu-iotests: Fix regression in 136 on aio_read invalid 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake Commit 093ea232 removed the ability for aio_read and aio_write to artificially inflate the invalid statistics counters for block devices, since it no longer flags unaligned offset or length. Add 'aio_read -i' and 'aio_write -i' to restore the ability, and update test 136 to use it. Reported-by: Kevin Wolf Signed-off-by: Eric Blake Message-id: 1463416983-28318-4-git-send-email-eblake@redhat.com Signed-off-by: Max Reitz --- qemu-io-cmds.c | 20 ++++++++++++++++---- tests/qemu-iotests/136 | 15 ++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index b5dbc67..e766791 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1274,6 +1274,7 @@ static void aio_read_help(void) " used to ensure all outstanding aio requests have been completed.\n" " -C, -- report statistics in a machine parsable format\n" " -P, -- use a pattern to verify read data\n" +" -i, -- treat request as invalid, for exercising stats\n" " -v, -- dump buffer to standard output\n" " -q, -- quiet mode, do not show I/O statistics\n" "\n"); @@ -1286,7 +1287,7 @@ static const cmdinfo_t aio_read_cmd = { .cfunc = aio_read_f, .argmin = 2, .argmax = -1, - .args = "[-Cqv] [-P pattern] off len [len..]", + .args = "[-Ciqv] [-P pattern] off len [len..]", .oneline = "asynchronously reads a number of bytes", .help = aio_read_help, }; @@ -1297,7 +1298,7 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); ctx->blk = blk; - while ((c = getopt(argc, argv, "CP:qv")) != -1) { + while ((c = getopt(argc, argv, "CP:iqv")) != -1) { switch (c) { case 'C': ctx->Cflag = true; @@ -1310,6 +1311,11 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) return 0; } break; + case 'i': + printf("injecting invalid read request\n"); + block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_READ); + g_free(ctx); + return 0; case 'q': ctx->qflag = true; break; @@ -1367,6 +1373,7 @@ static void aio_write_help(void) " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" " -f, -- use Force Unit Access semantics\n" +" -i, -- treat request as invalid, for exercising stats\n" " -q, -- quiet mode, do not show I/O statistics\n" " -u, -- with -z, allow unmapping\n" " -z, -- write zeroes using blk_aio_write_zeroes\n" @@ -1380,7 +1387,7 @@ static const cmdinfo_t aio_write_cmd = { .cfunc = aio_write_f, .argmin = 2, .argmax = -1, - .args = "[-Cfquz] [-P pattern] off len [len..]", + .args = "[-Cfiquz] [-P pattern] off len [len..]", .oneline = "asynchronously writes a number of bytes", .help = aio_write_help, }; @@ -1393,7 +1400,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) int flags = 0; ctx->blk = blk; - while ((c = getopt(argc, argv, "CfqP:uz")) != -1) { + while ((c = getopt(argc, argv, "CfiqP:uz")) != -1) { switch (c) { case 'C': ctx->Cflag = true; @@ -1414,6 +1421,11 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return 0; } break; + case 'i': + printf("injecting invalid write request\n"); + block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE); + g_free(ctx); + return 0; case 'z': ctx->zflag = true; break; diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136 index 996265e..635b977 100644 --- a/tests/qemu-iotests/136 +++ b/tests/qemu-iotests/136 @@ -226,18 +226,11 @@ sector = "%d" highest_offset = wr_ops * wr_size - # Two types of invalid operations: unaligned length and unaligned offset - for i in range(invalid_rd_ops / 2): - ops.append("aio_read 0 511") + for i in range(invalid_rd_ops): + ops.append("aio_read -i 0 512") - for i in range(invalid_rd_ops / 2, invalid_rd_ops): - ops.append("aio_read 13 512") - - for i in range(invalid_wr_ops / 2): - ops.append("aio_write 0 511") - - for i in range(invalid_wr_ops / 2, invalid_wr_ops): - ops.append("aio_write 13 512") + for i in range(invalid_wr_ops): + ops.append("aio_write -i 0 512") for i in range(failed_rd_ops): ops.append("aio_read %d 512" % bad_offset)