From patchwork Fri Jun 10 16:05:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9170069 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 1E33E604DB for ; Fri, 10 Jun 2016 16:15:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12AA421BED for ; Fri, 10 Jun 2016 16:15:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0736227D07; Fri, 10 Jun 2016 16:15:24 +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 A361B21BED for ; Fri, 10 Jun 2016 16:15:23 +0000 (UTC) Received: from localhost ([::1]:43217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBP5e-00061T-DA for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Jun 2016 12:15:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBOwS-0007D8-Ef for qemu-devel@nongnu.org; Fri, 10 Jun 2016 12:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBOwP-00029N-3S for qemu-devel@nongnu.org; Fri, 10 Jun 2016 12:05:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBOwG-000276-7g; Fri, 10 Jun 2016 12:05:40 -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 C4C7212AE3; Fri, 10 Jun 2016 16:05:39 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5AG5PWB032495; Fri, 10 Jun 2016 12:05:37 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 10 Jun 2016 18:05:22 +0200 Message-Id: <1465574722-27656-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1465574722-27656-1-git-send-email-kwolf@redhat.com> References: <1465574722-27656-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.30]); Fri, 10 Jun 2016 16:05:39 +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] [PATCH 6/6] block: Remove bs->zero_beyond_eof 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, famz@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It is always true for open images now. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 2 -- block/io.c | 51 +++++++++++++++++++++-------------------------- include/block/block_int.h | 3 --- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/block.c b/block.c index 3d850a2..b350794 100644 --- a/block.c +++ b/block.c @@ -938,7 +938,6 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, } bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; - bs->zero_beyond_eof = true; bs->read_only = !(bs->open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { @@ -2192,7 +2191,6 @@ static void bdrv_close(BlockDriverState *bs) bs->encrypted = 0; bs->valid_key = 0; bs->sg = 0; - bs->zero_beyond_eof = false; QDECREF(bs->options); QDECREF(bs->explicit_options); bs->options = NULL; diff --git a/block/io.c b/block/io.c index adf2726..d504443 100644 --- a/block/io.c +++ b/block/io.c @@ -1000,40 +1000,35 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs, } /* Forward the request to the BlockDriver */ - if (!bs->zero_beyond_eof) { - ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0); - } else { - /* Read zeros after EOF */ - int64_t total_bytes, max_bytes; + int64_t total_bytes, max_bytes; - total_bytes = bdrv_getlength(bs); - if (total_bytes < 0) { - ret = total_bytes; - goto out; - } + total_bytes = bdrv_getlength(bs); + if (total_bytes < 0) { + ret = total_bytes; + goto out; + } - max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align); - if (bytes < max_bytes) { - ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0); - } else if (max_bytes > 0) { - QEMUIOVector local_qiov; + max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align); + if (bytes < max_bytes) { + ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0); + } else if (max_bytes > 0) { + QEMUIOVector local_qiov; - qemu_iovec_init(&local_qiov, qiov->niov); - qemu_iovec_concat(&local_qiov, qiov, 0, max_bytes); + qemu_iovec_init(&local_qiov, qiov->niov); + qemu_iovec_concat(&local_qiov, qiov, 0, max_bytes); - ret = bdrv_driver_preadv(bs, offset, max_bytes, &local_qiov, 0); + ret = bdrv_driver_preadv(bs, offset, max_bytes, &local_qiov, 0); - qemu_iovec_destroy(&local_qiov); - } else { - ret = 0; - } + qemu_iovec_destroy(&local_qiov); + } else { + ret = 0; + } - /* Reading beyond end of file is supposed to produce zeroes */ - if (ret == 0 && total_bytes < offset + bytes) { - uint64_t zero_offset = MAX(0, total_bytes - offset); - uint64_t zero_bytes = offset + bytes - zero_offset; - qemu_iovec_memset(qiov, zero_offset, 0, zero_bytes); - } + /* Reading beyond end of file is supposed to produce zeroes */ + if (ret == 0 && total_bytes < offset + bytes) { + uint64_t zero_offset = MAX(0, total_bytes - offset); + uint64_t zero_bytes = offset + bytes - zero_offset; + qemu_iovec_memset(qiov, zero_offset, 0, zero_bytes); } out: diff --git a/include/block/block_int.h b/include/block/block_int.h index 1fe0811..16c43e2 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -451,9 +451,6 @@ struct BlockDriverState { /* I/O Limits */ BlockLimits bl; - /* Whether produces zeros when read beyond eof */ - bool zero_beyond_eof; - /* Alignment requirement for offset/length of I/O requests */ unsigned int request_alignment; /* Flags honored during pwrite (so far: BDRV_REQ_FUA) */