From patchwork Wed Apr 26 08:40:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 9700657 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 092DC603F4 for ; Wed, 26 Apr 2017 08:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B0928477 for ; Wed, 26 Apr 2017 08:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6529284EA; Wed, 26 Apr 2017 08:41:56 +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 4697428477 for ; Wed, 26 Apr 2017 08:41:56 +0000 (UTC) Received: from localhost ([::1]:53602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3IWJ-0004Qh-D4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Apr 2017 04:41:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3IVQ-0004Ll-NG for qemu-devel@nongnu.org; Wed, 26 Apr 2017 04:41:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3IVP-00030d-UM for qemu-devel@nongnu.org; Wed, 26 Apr 2017 04:41:00 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:20697 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3IVJ-0002x4-4m; Wed, 26 Apr 2017 04:40:53 -0400 Received: from iris.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v3Q8ekAN020793; Wed, 26 Apr 2017 11:40:47 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 11:40:46 +0300 Message-Id: <1493196046-5607-1-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 1/1] block: fix alignment calculations in bdrv_co_do_zero_pwritev 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: "Denis V. Lunev" , Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP tail_padding_bytes is calculated wrong. F.e. for offset = 0 bytes = 2048 align = 512 we will have tail_padding_bytes = 512 which is definitely wrong. The patch fixes that arithmetics. Fortunately this problem is harmless, we will have 1 extra allocation and free thus there is no need to put this into stable. The problem is here from the very beginning. Signed-off-by: Denis V. Lunev CC: Stefan Hajnoczi CC: Fam Zheng Reviewed-by: Eric Blake --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index a7142e0..1e1523b 100644 --- a/block/io.c +++ b/block/io.c @@ -1452,7 +1452,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, int ret = 0; head_padding_bytes = offset & (align - 1); - tail_padding_bytes = align - ((offset + bytes) & (align - 1)); + tail_padding_bytes = (align - (offset + bytes)) & (align - 1); assert(flags & BDRV_REQ_ZERO_WRITE);