From patchwork Thu May 12 21:39:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9086321 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 916849F372 for ; Thu, 12 May 2016 21:41:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B59FC20225 for ; Thu, 12 May 2016 21:41:10 +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 E0A602021A for ; Thu, 12 May 2016 21:41:09 +0000 (UTC) Received: from localhost ([::1]:59909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0yM1-0005R5-3U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 17:41:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0yKb-0003Hi-5A for qemu-devel@nongnu.org; Thu, 12 May 2016 17:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0yKZ-0003Lu-Of for qemu-devel@nongnu.org; Thu, 12 May 2016 17:39:41 -0400 Received: from resqmta-po-09v.sys.comcast.net ([2001:558:fe16:19:96:114:154:168]:50930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0yKZ-0003Ld-HS for qemu-devel@nongnu.org; Thu, 12 May 2016 17:39:39 -0400 Received: from resomta-po-09v.sys.comcast.net ([96.114.154.233]) by comcast with SMTP id 0yKGbb82od8260yKYbYosO; Thu, 12 May 2016 21:39:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1463089178; bh=WsR9m4vW+ls8O1f7rsIDNWezn373f0Y99xA/7uzVPJI=; h=Received:Received:From:To:Subject:Date:Message-Id; b=W9FI1amsSidpl02+qWxdORnjwuWvQHkavY6z3///9FiJCrpNIpjVym+u38SAkVuvB 0TKUx6ts7F7dBogzWq/SYde+FbcevZPQjJ1EwimHGmdwH5g4fcNWu5GMsFz00z2XWf CiQWH6vwnJ39+5RXIkNs47Heqk/PnGwZwg0EoiGqomiTAmqM+6mvfyX96/fuVLIkrL Neb+kVSiKI4bfWbyst0ch2IRJle5eBsZLr2L0WVrnjQMGXH3X6aWuAQ4jxi4qw2ILu nsI4wMLYG2HLDv6HLBA7vBvfpKN8LO+HYrqV3ozGn9bnStLub+OfUWxJ7m7PSaiotu olFz8yhKAUjNg== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-09v.sys.comcast.net with comcast id tZfX1s0042fD5rL01ZfeCz; Thu, 12 May 2016 21:39:38 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 15:39:30 -0600 Message-Id: <1463089170-30550-4-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463089170-30550-1-git-send-email-eblake@redhat.com> References: <1463089170-30550-1-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:168 Subject: [Qemu-devel] [PATCH 3/3] 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-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 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 --- qemu-io-cmds.c | 20 ++++++++++++++++---- tests/qemu-iotests/136 | 18 +++++++----------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 415be25..059b8ee 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1476,6 +1476,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"); @@ -1488,7 +1489,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, }; @@ -1499,7 +1500,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; @@ -1512,6 +1513,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; @@ -1569,6 +1575,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" @@ -1582,7 +1589,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, }; @@ -1595,7 +1602,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; @@ -1616,6 +1623,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 e8c6937..5e92c4b 100644 --- a/tests/qemu-iotests/136 +++ b/tests/qemu-iotests/136 @@ -226,18 +226,14 @@ 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") + # Block layer abstracts away unaligned length and offset, so we + # can't trigger an invalid op with any addresses; use qemu-io's + # invalid injection feature instead + 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)