From patchwork Sun Jun 12 01:18:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9171269 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 407C76048C for ; Sun, 12 Jun 2016 01:19:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30F8A26490 for ; Sun, 12 Jun 2016 01:19:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 250B62665D; Sun, 12 Jun 2016 01:19:25 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9284A26490 for ; Sun, 12 Jun 2016 01:19:23 +0000 (UTC) Received: from localhost ([::1]:49226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBu3d-0003lV-Le for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Jun 2016 21:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBu3M-0003kT-VY for qemu-devel@nongnu.org; Sat, 11 Jun 2016 21:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBu3D-0005kf-2o for qemu-devel@nongnu.org; Sat, 11 Jun 2016 21:19:04 -0400 Received: from resqmta-po-02v.sys.comcast.net ([2001:558:fe16:19:96:114:154:161]:59844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBu3C-0005kI-U0 for qemu-devel@nongnu.org; Sat, 11 Jun 2016 21:18:55 -0400 Received: from resomta-po-09v.sys.comcast.net ([96.114.154.233]) by resqmta-po-02v.sys.comcast.net with SMTP id Bu2vbyqEeBAXOBu3Abp1Aj; Sun, 12 Jun 2016 01:18:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1465694332; bh=4hJJ39f5cv4VUJq/I1b9+XF22lNpriz1BXeVOpynHU0=; h=Received:Received:From:To:Subject:Date:Message-Id; b=E+88b3+1BknfT/NUU9yW5/2tG1p9iem9sOv9ThuEuY0XzrO12it/wzYd+YQHnNNED 2yS7UYaedwC7jvo7aMEcJxLplBYKD7EpW5FDqguNRYh8ruvk3pQJ8uOdbYDkWmvsWO /VDDbGu+tAcJPKa+O749YonSfXT0BmmU9velzpqNe0MGWFXZVmFkhoQZgZKG6+gQoX OEGiVbaabz8MIQhpgA8JkuKSIQuKj+glMr7STA8/NkktOTpGDJEbl1XW0Cs78Nz3ST JCivmrpWvIGZNEIg/umyHAtUb3UM9+4qcn0A6D9WisqWs5yN5gJ+iJqmRhIgPzq2o/ w9QNbY3r93tww== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-09v.sys.comcast.net with comcast id 5dJp1t0012fD5rL01dJrG0; Sun, 12 Jun 2016 01:18:52 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Sat, 11 Jun 2016 19:18:40 -0600 Message-Id: <1465694320-13500-1-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:161 Subject: [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring 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, Jeff Cody , 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 Commit e253f4b8 converted mirroring from sector-based bdrv_aio_* to byte-based blk_aio_*, but failed to account for the subtle difference in signatures (the former takes a semi-redundant length, the latter takes a flags parameter). Since all of our flags are currently smaller in size than BDRV_SECTOR_SIZE, it has no ill effects until we either perform sub-sector mirroring, or we start asserting that no unexpected flags are set. I found it while testing new asserts when qemu-iotests 132 started warning about an unknown flag 0x200000. Add an assert to help us catch any other improper flags. Signed-off-by: Eric Blake --- block/block-backend.c | 2 ++ block/mirror.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 34500e6..a5dc6e3 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -945,6 +945,8 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, acb->bh = NULL; acb->has_returned = false; + assert(flags <= 0x1f); + co = qemu_coroutine_create(co_entry); qemu_coroutine_enter(co, acb); diff --git a/block/mirror.c b/block/mirror.c index fbbc496..41848b2 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -157,8 +157,7 @@ static void mirror_read_complete(void *opaque, int ret) return; } blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov, - op->nb_sectors * BDRV_SECTOR_SIZE, - mirror_write_complete, op); + 0, mirror_write_complete, op); } static inline void mirror_clip_sectors(MirrorBlockJob *s, @@ -275,8 +274,7 @@ static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num, s->sectors_in_flight += nb_sectors; trace_mirror_one_iteration(s, sector_num, nb_sectors); - blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov, - nb_sectors * BDRV_SECTOR_SIZE, + blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov, 0, mirror_read_complete, op); return ret; }