From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389739; cv=none; d=zohomail.com; s=zohoarc; b=k4Sp6gnTsZzRrKMLydQxiQ8DQxKz4RzXqvJk2rft8+owCjmTyvtZFtDSK5Z8yI0F1n7SGKBQ60XknO5gPy2V0PDN/HcVopoI5kJ1czS+MP0S8lrMe1lL82DENcWOSb8RGvhVBKQ92Q4zrrZtNo7HD+6VSVDW75QNtZ1djDIRl9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389739; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rvjO91yCQ2xfSgsgj2ncqvKKayX0egqjShcGsP3u1I8=; b=BSnC0InIg6fUKkB4paR38UVGda5ySjeohfDAMHfAmPepeVn0UWp5aPFdQNJJgluUUmfMIP1piVUtrEgE5j8JNmrL9NN6Y0dfJk80QLz15RByvfvmrtzQeCg3IkkcfzUel7V367nbDfFMB8kuXgug92eKgBNuNVi3wat+hJ6g3Y0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389739559332.91938370090827; Mon, 20 Apr 2020 06:35:39 -0700 (PDT) Received: from localhost ([::1]:35728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWaI-0007IT-HV for importer@patchew.org; Mon, 20 Apr 2020 09:35:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60812 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXY-0004JT-CA for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:57 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXU-0004Y4-7c for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:48 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34081 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXT-0004Vx-7w for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-DhiPiOhdMRacXJ9d7La6OA-1; Mon, 20 Apr 2020 09:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27111149F4; Mon, 20 Apr 2020 13:32:35 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73DB1116D8B; Mon, 20 Apr 2020 13:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rvjO91yCQ2xfSgsgj2ncqvKKayX0egqjShcGsP3u1I8=; b=hUHp1SbbRlDZu/RyybmQZhmp+Qtl9MPw92C5PuGEfH7LQQZp5h1h4XRzONvz7TploB+6J+ gx/caLhWBuLqagri4omXQSHvPYscZ2tKjGUxp4aii2q3uWKv/9FogV5EWaHqDhYk+/rG20 wieG/H81QKnjvt+jKyDU8iMdT5DTRzI= X-MC-Unique: DhiPiOhdMRacXJ9d7La6OA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 1/9] block: Add flags to BlockDriver.bdrv_co_truncate() Date: Mon, 20 Apr 2020 15:32:06 +0200 Message-Id: <20200420133214.28921-2-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 01:47:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This adds a new BdrvRequestFlags parameter to the .bdrv_co_truncate() driver callbacks, and a supported_truncate_flags field in BlockDriverState that allows drivers to advertise support for request flags in the context of truncate. For now, we always pass 0 and no drivers declare support for any flag. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 10 +++++++++- block/crypto.c | 3 ++- block/file-posix.c | 2 +- block/gluster.c | 1 + block/io.c | 8 +++++++- block/iscsi.c | 2 +- block/nfs.c | 3 ++- block/qcow2.c | 2 +- block/qed.c | 1 + block/raw-format.c | 2 +- block/rbd.c | 1 + block/sheepdog.c | 4 ++-- block/ssh.c | 2 +- tests/test-block-iothread.c | 3 ++- 14 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 4c3587ea19..92335f33c7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -355,7 +355,7 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_truncate)(BlockDriverState *bs, int64_t off= set, bool exact, PreallocMode prealloc, - Error **errp); + BdrvRequestFlags flags, Error **e= rrp); =20 int64_t (*bdrv_getlength)(BlockDriverState *bs); bool has_variable_length; @@ -847,6 +847,14 @@ struct BlockDriverState { /* Flags honored during pwrite_zeroes (so far: BDRV_REQ_FUA, * BDRV_REQ_MAY_UNMAP, BDRV_REQ_WRITE_UNCHANGED) */ unsigned int supported_zero_flags; + /* + * Flags honoured during truncate (so far: BDRV_REQ_ZERO_WRITE). + * + * If BDRV_REQ_ZERO_WRITE is given, the truncate operation must make s= ure + * that any added space reads as all zeros. If this can't be guarantee= d, + * the operation must fail. + */ + unsigned int supported_truncate_flags; =20 /* the following member gives a name to every node on the bs graph. */ char node_name[32]; diff --git a/block/crypto.c b/block/crypto.c index d577f89659..3721a8495c 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -299,7 +299,8 @@ static int block_crypto_co_create_generic(BlockDriverSt= ate *bs, =20 static int coroutine_fn block_crypto_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags flags, + Error **errp) { BlockCrypto *crypto =3D bs->opaque; uint64_t payload_offset =3D diff --git a/block/file-posix.c b/block/file-posix.c index 7e19bbff5f..53f475ed61 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2080,7 +2080,7 @@ raw_regular_truncate(BlockDriverState *bs, int fd, in= t64_t offset, =20 static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offs= et, bool exact, PreallocMode prealloc, - Error **errp) + BdrvRequestFlags flags, Error **er= rp) { BDRVRawState *s =3D bs->opaque; struct stat st; diff --git a/block/gluster.c b/block/gluster.c index 0aa1f2cda4..d06df900f6 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1228,6 +1228,7 @@ static coroutine_fn int qemu_gluster_co_truncate(Bloc= kDriverState *bs, int64_t offset, bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) { BDRVGlusterState *s =3D bs->opaque; diff --git a/block/io.c b/block/io.c index aba67f66b9..04ac5cf023 100644 --- a/block/io.c +++ b/block/io.c @@ -3344,6 +3344,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, BlockDriverState *bs =3D child->bs; BlockDriver *drv =3D bs->drv; BdrvTrackedRequest req; + BdrvRequestFlags flags =3D 0; int64_t old_size, new_bytes; int ret; =20 @@ -3394,7 +3395,12 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, = int64_t offset, bool exact, } =20 if (drv->bdrv_co_truncate) { - ret =3D drv->bdrv_co_truncate(bs, offset, exact, prealloc, errp); + if (flags & ~bs->supported_truncate_flags) { + error_setg(errp, "Block driver does not support requested flag= s"); + ret =3D -ENOTSUP; + goto out; + } + ret =3D drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, = errp); } else if (bs->file && drv->is_filter) { ret =3D bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); } else { diff --git a/block/iscsi.c b/block/iscsi.c index 4e216bd8aa..2b877a377b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2125,7 +2125,7 @@ static void iscsi_reopen_commit(BDRVReopenState *reop= en_state) =20 static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t of= fset, bool exact, PreallocMode preallo= c, - Error **errp) + BdrvRequestFlags flags, Error **= errp) { IscsiLun *iscsilun =3D bs->opaque; int64_t cur_length; diff --git a/block/nfs.c b/block/nfs.c index cc2413d5ab..2393fbfe6b 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -755,7 +755,8 @@ static int64_t nfs_get_allocated_file_size(BlockDriverS= tate *bs) =20 static int coroutine_fn nfs_file_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags flags, + Error **errp) { NFSClient *client =3D bs->opaque; int ret; diff --git a/block/qcow2.c b/block/qcow2.c index b524b0c53f..0b406b22fb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3964,7 +3964,7 @@ fail: =20 static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t of= fset, bool exact, PreallocMode preallo= c, - Error **errp) + BdrvRequestFlags flags, Error **= errp) { BDRVQcow2State *s =3D bs->opaque; uint64_t old_length; diff --git a/block/qed.c b/block/qed.c index 1af9b3cb1d..fb6100bd20 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1467,6 +1467,7 @@ static int coroutine_fn bdrv_qed_co_truncate(BlockDri= verState *bs, int64_t offset, bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) { BDRVQEDState *s =3D bs->opaque; diff --git a/block/raw-format.c b/block/raw-format.c index 93b25e1b6b..9331368f43 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -371,7 +371,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Er= ror **errp) =20 static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offs= et, bool exact, PreallocMode prealloc, - Error **errp) + BdrvRequestFlags flags, Error **er= rp) { BDRVRawState *s =3D bs->opaque; =20 diff --git a/block/rbd.c b/block/rbd.c index e637639a07..f2d52091c7 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1108,6 +1108,7 @@ static int coroutine_fn qemu_rbd_co_truncate(BlockDri= verState *bs, int64_t offset, bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) { int r; diff --git a/block/sheepdog.c b/block/sheepdog.c index 59f7ebb171..ef0a6e743e 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2288,7 +2288,7 @@ static int64_t sd_getlength(BlockDriverState *bs) =20 static int coroutine_fn sd_co_truncate(BlockDriverState *bs, int64_t offse= t, bool exact, PreallocMode prealloc, - Error **errp) + BdrvRequestFlags flags, Error **err= p) { BDRVSheepdogState *s =3D bs->opaque; int ret, fd; @@ -2604,7 +2604,7 @@ static coroutine_fn int sd_co_writev(BlockDriverState= *bs, int64_t sector_num, =20 assert(!flags); if (offset > s->inode.vdi_size) { - ret =3D sd_co_truncate(bs, offset, false, PREALLOC_MODE_OFF, NULL); + ret =3D sd_co_truncate(bs, offset, false, PREALLOC_MODE_OFF, 0, NU= LL); if (ret < 0) { return ret; } diff --git a/block/ssh.c b/block/ssh.c index 84e92821c0..9eb33df859 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -1298,7 +1298,7 @@ static int64_t ssh_getlength(BlockDriverState *bs) =20 static int coroutine_fn ssh_co_truncate(BlockDriverState *bs, int64_t offs= et, bool exact, PreallocMode prealloc, - Error **errp) + BdrvRequestFlags flags, Error **er= rp) { BDRVSSHState *s =3D bs->opaque; =20 diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index 0c861809f0..2f3b76323d 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -46,7 +46,8 @@ static int coroutine_fn bdrv_test_co_pdiscard(BlockDriver= State *bs, =20 static int coroutine_fn bdrv_test_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags flags, + Error **errp) { return 0; } --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389874; cv=none; d=zohomail.com; s=zohoarc; b=WJRk3rRygk1AKR7qniyj6d/vEVm172KfSAUf7jwQgDmzIWAi2nUzVjMdPteUkKhKLMbK0jeDpaC48MsixZR6ccDs9f43ItiWNapXEb12WSoCuu8fq1ChKmNCq12KRxz+qvPzdQMrh4ba+P4aFLaAKven5ngz32nZvcsKboUp1+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389874; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cuZjG6mxw9xXEzzI1sxnctqWTZEf+rzij04ancbis1g=; b=SZanUZk7QYcLdYLcut9kj9e6BT65S5CZsZZY8d7y6YweN6EFsmAMYyVHjr+HlmfEGbR//baoMhyv0RCoXa2XTomi3lRRftBeByfMFlUw4pNT2iRG1zuLlPZTnBf/YsM3l9ui+tESvHu0xPGrrst6PP8VprS3t88WGq78+Ask1V8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389874378734.3557211505538; Mon, 20 Apr 2020 06:37:54 -0700 (PDT) Received: from localhost ([::1]:35786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWcT-0002mA-HU for importer@patchew.org; Mon, 20 Apr 2020 09:37:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60836 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXb-0004L4-87 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:57 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXS-0004VI-N3 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51203 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXS-0004S5-9k for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-CMWvYWt4NJy2oUridxGEnw-1; Mon, 20 Apr 2020 09:32:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E803C801E70; Mon, 20 Apr 2020 13:32:36 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DEDC11E7E7; Mon, 20 Apr 2020 13:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cuZjG6mxw9xXEzzI1sxnctqWTZEf+rzij04ancbis1g=; b=h+y/cyZYlKLwToDXZ4hzSELs7QQY7nXF0GI1cgkR9djbWAIPiprl9n/Ddiqq1jahsXwOEo GsnDk40AjZDF+3fKBJNvxMEIDcDYQbOeYPS7kifFIMtfOvxIlFuK99rF8Ne8YjLmXKqZGD MqM0vpbZuHcpOeTfaLZSPLPQlvJ/MEE= X-MC-Unique: CMWvYWt4NJy2oUridxGEnw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 2/9] block: Add flags to bdrv(_co)_truncate() Date: Mon, 20 Apr 2020 15:32:07 +0200 Message-Id: <20200420133214.28921-3-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 04:32:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that block drivers can support flags for .bdrv_co_truncate, expose the parameter in the node level interfaces bdrv_co_truncate() and bdrv_truncate(). Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 5 +++-- block/block-backend.c | 2 +- block/crypto.c | 2 +- block/io.c | 12 +++++++----- block/parallels.c | 6 +++--- block/qcow.c | 4 ++-- block/qcow2-refcount.c | 2 +- block/qcow2.c | 13 +++++++------ block/raw-format.c | 2 +- block/vhdx-log.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 2 +- tests/test-block-iothread.c | 6 +++--- 13 files changed, 32 insertions(+), 28 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index b05995fe9c..8b62429aa4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -339,9 +339,10 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverS= tate *bs, void bdrv_refresh_filename(BlockDriverState *bs); =20 int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool e= xact, - PreallocMode prealloc, Error **errp); + PreallocMode prealloc, BdrvRequestFlags = flags, + Error **errp); int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp); + PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp); =20 int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); diff --git a/block/block-backend.c b/block/block-backend.c index 38ae413826..8be20060d3 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2144,7 +2144,7 @@ int blk_truncate(BlockBackend *blk, int64_t offset, b= ool exact, return -ENOMEDIUM; } =20 - return bdrv_truncate(blk->root, offset, exact, prealloc, errp); + return bdrv_truncate(blk->root, offset, exact, prealloc, 0, errp); } =20 int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, diff --git a/block/crypto.c b/block/crypto.c index 3721a8495c..ab33545c92 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -313,7 +313,7 @@ block_crypto_co_truncate(BlockDriverState *bs, int64_t = offset, bool exact, =20 offset +=3D payload_offset; =20 - return bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); + return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); } =20 static void block_crypto_close(BlockDriverState *bs) diff --git a/block/io.c b/block/io.c index 04ac5cf023..795075954e 100644 --- a/block/io.c +++ b/block/io.c @@ -3339,12 +3339,12 @@ static void bdrv_parent_cb_resize(BlockDriverState = *bs) * 'offset' bytes in length. */ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool e= xact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags = flags, + Error **errp) { BlockDriverState *bs =3D child->bs; BlockDriver *drv =3D bs->drv; BdrvTrackedRequest req; - BdrvRequestFlags flags =3D 0; int64_t old_size, new_bytes; int ret; =20 @@ -3402,7 +3402,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, } ret =3D drv->bdrv_co_truncate(bs, offset, exact, prealloc, flags, = errp); } else if (bs->file && drv->is_filter) { - ret =3D bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); + ret =3D bdrv_co_truncate(bs->file, offset, exact, prealloc, flags,= errp); } else { error_setg(errp, "Image format driver does not support resize"); ret =3D -ENOTSUP; @@ -3435,6 +3435,7 @@ typedef struct TruncateCo { int64_t offset; bool exact; PreallocMode prealloc; + BdrvRequestFlags flags; Error **errp; int ret; } TruncateCo; @@ -3443,12 +3444,12 @@ static void coroutine_fn bdrv_truncate_co_entry(voi= d *opaque) { TruncateCo *tco =3D opaque; tco->ret =3D bdrv_co_truncate(tco->child, tco->offset, tco->exact, - tco->prealloc, tco->errp); + tco->prealloc, tco->flags, tco->errp); aio_wait_kick(); } =20 int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp) { Coroutine *co; TruncateCo tco =3D { @@ -3456,6 +3457,7 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, b= ool exact, .offset =3D offset, .exact =3D exact, .prealloc =3D prealloc, + .flags =3D flags, .errp =3D errp, .ret =3D NOT_DONE, }; diff --git a/block/parallels.c b/block/parallels.c index 6d4ed77f16..2be92cf417 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -203,7 +203,7 @@ static int64_t allocate_clusters(BlockDriverState *bs, = int64_t sector_num, } else { ret =3D bdrv_truncate(bs->file, (s->data_end + space) << BDRV_SECTOR_BITS, - false, PREALLOC_MODE_OFF, NULL); + false, PREALLOC_MODE_OFF, 0, NULL); } if (ret < 0) { return ret; @@ -493,7 +493,7 @@ static int coroutine_fn parallels_co_check(BlockDriverS= tate *bs, * That means we have to pass exact=3Dtrue. */ ret =3D bdrv_truncate(bs->file, res->image_end_offset, true, - PREALLOC_MODE_OFF, &local_err); + PREALLOC_MODE_OFF, 0, &local_err); if (ret < 0) { error_report_err(local_err); res->check_errors++; @@ -889,7 +889,7 @@ static void parallels_close(BlockDriverState *bs) =20 /* errors are ignored, so we might as well pass exact=3Dtrue */ bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); } =20 g_free(s->bat_dirty_bmap); diff --git a/block/qcow.c b/block/qcow.c index 8973e4e565..6b5f2269f0 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -480,7 +480,7 @@ static int get_cluster_offset(BlockDriverState *bs, return -E2BIG; } ret =3D bdrv_truncate(bs->file, cluster_offset + s->cluste= r_size, - false, PREALLOC_MODE_OFF, NULL); + false, PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) { return ret; } @@ -1035,7 +1035,7 @@ static int qcow_make_empty(BlockDriverState *bs) l1_length) < 0) return -1; ret =3D bdrv_truncate(bs->file, s->l1_table_offset + l1_length, false, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) return ret; =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 7ef1c0e42a..d9650b9b6c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2018,7 +2018,7 @@ static int check_refblocks(BlockDriverState *bs, Bdrv= CheckResult *res, } =20 ret =3D bdrv_truncate(bs->file, offset + s->cluster_size, = false, - PREALLOC_MODE_OFF, &local_err); + PREALLOC_MODE_OFF, 0, &local_err); if (ret < 0) { error_report_err(local_err); goto resize_fail; diff --git a/block/qcow2.c b/block/qcow2.c index 0b406b22fb..c2f060b670 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3095,7 +3095,7 @@ static int coroutine_fn preallocate_co(BlockDriverSta= te *bs, uint64_t offset, mode =3D PREALLOC_MODE_OFF; } ret =3D bdrv_co_truncate(s->data_file, host_offset + cur_bytes, fa= lse, - mode, errp); + mode, 0, errp); if (ret < 0) { return ret; } @@ -4061,7 +4061,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, * always fulfilled, so there is no need to pass it on.) */ bdrv_co_truncate(bs->file, (last_cluster + 1) * s->cluster_siz= e, - false, PREALLOC_MODE_OFF, &local_err); + false, PREALLOC_MODE_OFF, 0, &local_err); if (local_err) { warn_reportf_err(local_err, "Failed to truncate the tail of the image= : "); @@ -4083,7 +4083,8 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, * file should be resized to the exact target size, too, * so we pass @exact here. */ - ret =3D bdrv_co_truncate(s->data_file, offset, exact, prealloc= , errp); + ret =3D bdrv_co_truncate(s->data_file, offset, exact, prealloc= , 0, + errp); if (ret < 0) { goto fail; } @@ -4169,7 +4170,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, new_file_size =3D allocation_start + nb_new_data_clusters * s->cluster_size; /* Image file grows, so @exact does not matter */ - ret =3D bdrv_co_truncate(bs->file, new_file_size, false, prealloc,= errp); + ret =3D bdrv_co_truncate(bs->file, new_file_size, false, prealloc,= 0, errp); if (ret < 0) { error_prepend(errp, "Failed to resize underlying file: "); qcow2_free_clusters(bs, allocation_start, @@ -4348,7 +4349,7 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, if (len < 0) { return len; } - return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, N= ULL); + return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, 0= , NULL); } =20 if (offset_into_cluster(s, offset)) { @@ -4563,7 +4564,7 @@ static int make_completely_empty(BlockDriverState *bs) } =20 ret =3D bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size, f= alse, - PREALLOC_MODE_OFF, &local_err); + PREALLOC_MODE_OFF, 0, &local_err); if (ret < 0) { error_report_err(local_err); goto fail; diff --git a/block/raw-format.c b/block/raw-format.c index 9331368f43..3465c9a865 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -387,7 +387,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverStat= e *bs, int64_t offset, =20 s->size =3D offset; offset +=3D s->offset; - return bdrv_co_truncate(bs->file, offset, exact, prealloc, errp); + return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); } =20 static void raw_eject(BlockDriverState *bs, bool eject_flag) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 13a49c2a33..404fb5f3cb 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -558,7 +558,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHD= XState *s, goto exit; } ret =3D bdrv_truncate(bs->file, new_file_size, false, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) { goto exit; } diff --git a/block/vhdx.c b/block/vhdx.c index 33e57cd656..5dfbb2029a 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1264,7 +1264,7 @@ static int vhdx_allocate_block(BlockDriverState *bs, = BDRVVHDXState *s, } =20 return bdrv_truncate(bs->file, *new_offset + s->block_size, false, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); } =20 /* diff --git a/block/vmdk.c b/block/vmdk.c index 218d9c9800..5de99fe813 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2077,7 +2077,7 @@ vmdk_co_pwritev_compressed(BlockDriverState *bs, uint= 64_t offset, } length =3D QEMU_ALIGN_UP(length, BDRV_SECTOR_SIZE); ret =3D bdrv_truncate(s->extents[i].file, length, false, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) { return ret; } diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index 2f3b76323d..71e9bce3b1 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -186,18 +186,18 @@ static void test_sync_op_truncate(BdrvChild *c) int ret; =20 /* Normal success path */ - ret =3D bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, NULL); + ret =3D bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, 0, NULL); g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ - ret =3D bdrv_truncate(c, -2, false, PREALLOC_MODE_OFF, NULL); + ret =3D bdrv_truncate(c, -2, false, PREALLOC_MODE_OFF, 0, NULL); g_assert_cmpint(ret, =3D=3D, -EINVAL); =20 /* Error: Read-only image */ c->bs->read_only =3D true; c->bs->open_flags &=3D ~BDRV_O_RDWR; =20 - ret =3D bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, NULL); + ret =3D bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, 0, NULL); g_assert_cmpint(ret, =3D=3D, -EACCES); =20 c->bs->read_only =3D false; --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389838; cv=none; d=zohomail.com; s=zohoarc; b=EIhje6rJX693RDxkwbVCdDM1rf3w0+28IheMvvOcp9mHZZn3jtpDhgZxZJ8oIGKyVYR5cwncDrngHT7UKwPSxGeIy42r3LJXYzR3BLoCQdSRv14T4cWfzKJtUOLHprqYkh1beK2ryKrt8Zx7ZeFPTfbA8j3uMFmuB3mw97BLOkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389838; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QJj864E9p0xkklZiEnuehfB6TMtfUvFKgNYmz5HtNv0=; b=ca9uqOGWA1ViVsrxVYUyfeBoiK2NDHIGscmLNr64+Ny6nrw9VHV2Tce/Gs1Lg3XFLWl8Nu0yvVghpbbs6fcHkcksImuo/Ta5Wz7LBYpuScZWg7AnvDZD1dAtjrC+Tjt5EiXUog2N9GCyW4iKQaTc3Q2K5Megr3yM3TWeTGlnt+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389838734286.05280928930165; Mon, 20 Apr 2020 06:37:18 -0700 (PDT) Received: from localhost ([::1]:35772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWbt-0001b7-Sp for importer@patchew.org; Mon, 20 Apr 2020 09:37:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60796 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXX-0004JA-Dj for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:52 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXS-0004Vd-PI for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:46 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23086 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXS-0004TW-Cy for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-i2JZosT3O6ya7R36UTIM-w-1; Mon, 20 Apr 2020 09:32:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAA5F8018CB; Mon, 20 Apr 2020 13:32:38 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D91711E7F8; Mon, 20 Apr 2020 13:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QJj864E9p0xkklZiEnuehfB6TMtfUvFKgNYmz5HtNv0=; b=d58TaOMA5XRXMOT6mLYWt2F05Tmnk1k1Cl1OLkTEtEY10eiJHH0pwXtFObBooKrfx9WeCz JKTnrCp++MGRK60Y3n4tR4G0pcvj/BGag41PTQP0ojghWQ2ShGbqiQIj2Oapa+GibuDd84 Ae/cc1XEZUQoc/q2xLcfJ52Lik0+kF0= X-MC-Unique: i2JZosT3O6ya7R36UTIM-w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 3/9] block-backend: Add flags to blk_truncate() Date: Mon, 20 Apr 2020 15:32:08 +0200 Message-Id: <20200420133214.28921-4-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 03:29:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that node level interface bdrv_truncate() supports passing request flags to the block driver, expose this on the BlockBackend level, too. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 2 +- block.c | 3 ++- block/block-backend.c | 4 ++-- block/commit.c | 4 ++-- block/crypto.c | 2 +- block/mirror.c | 2 +- block/qcow2.c | 4 ++-- block/qed.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 4 ++-- block/vmdk.c | 6 +++--- block/vpc.c | 2 +- blockdev.c | 2 +- qemu-img.c | 2 +- qemu-io-cmds.c | 2 +- 15 files changed, 22 insertions(+), 21 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 9bbdbd63d7..34de7faa81 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -237,7 +237,7 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk= , int64_t offset, int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *b= uf, int bytes); int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp); + PreallocMode prealloc, BdrvRequestFlags flags, Error **er= rp); int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes); int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size); diff --git a/block.c b/block.c index 2e3905c99e..03cc5813a2 100644 --- a/block.c +++ b/block.c @@ -548,7 +548,8 @@ static int64_t create_file_fallback_truncate(BlockBacke= nd *blk, int64_t size; int ret; =20 - ret =3D blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, &loc= al_err); + ret =3D blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0, + &local_err); if (ret < 0 && ret !=3D -ENOTSUP) { error_propagate(errp, local_err); return ret; diff --git a/block/block-backend.c b/block/block-backend.c index 8be20060d3..17ed6d8c5b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2137,14 +2137,14 @@ int blk_pwrite_compressed(BlockBackend *blk, int64_= t offset, const void *buf, } =20 int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, - PreallocMode prealloc, Error **errp) + PreallocMode prealloc, BdrvRequestFlags flags, Error **er= rp) { if (!blk_is_available(blk)) { error_setg(errp, "No medium inserted"); return -ENOMEDIUM; } =20 - return bdrv_truncate(blk->root, offset, exact, prealloc, 0, errp); + return bdrv_truncate(blk->root, offset, exact, prealloc, flags, errp); } =20 int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, diff --git a/block/commit.c b/block/commit.c index 8e672799af..87f6096d90 100644 --- a/block/commit.c +++ b/block/commit.c @@ -133,7 +133,7 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) } =20 if (base_len < len) { - ret =3D blk_truncate(s->base, len, false, PREALLOC_MODE_OFF, NULL); + ret =3D blk_truncate(s->base, len, false, PREALLOC_MODE_OFF, 0, NU= LL); if (ret) { goto out; } @@ -458,7 +458,7 @@ int bdrv_commit(BlockDriverState *bs) * grow the backing file image if possible. If not possible, * we must return an error */ if (length > backing_length) { - ret =3D blk_truncate(backing, length, false, PREALLOC_MODE_OFF, + ret =3D blk_truncate(backing, length, false, PREALLOC_MODE_OFF, 0, &local_err); if (ret < 0) { error_report_err(local_err); diff --git a/block/crypto.c b/block/crypto.c index ab33545c92..e02f343590 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -115,7 +115,7 @@ static ssize_t block_crypto_init_func(QCryptoBlock *blo= ck, * which will be used by the crypto header */ return blk_truncate(data->blk, data->size + headerlen, false, - data->prealloc, errp); + data->prealloc, 0, errp); } =20 =20 diff --git a/block/mirror.c b/block/mirror.c index c26fd9260d..aca95c9bc9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -900,7 +900,7 @@ static int coroutine_fn mirror_run(Job *job, Error **er= rp) =20 if (s->bdev_length > base_length) { ret =3D blk_truncate(s->target, s->bdev_length, false, - PREALLOC_MODE_OFF, NULL); + PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) { goto immediate_exit; } diff --git a/block/qcow2.c b/block/qcow2.c index c2f060b670..6c6d6101ce 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3511,7 +3511,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) =20 /* Okay, now that we have a valid image, let's give it the right size = */ ret =3D blk_truncate(blk, qcow2_opts->size, false, qcow2_opts->preallo= cation, - errp); + 0, errp); if (ret < 0) { error_prepend(errp, "Could not resize image: "); goto out; @@ -5372,7 +5372,7 @@ static int qcow2_amend_options(BlockDriverState *bs, = QemuOpts *opts, * Amending image options should ensure that the image has * exactly the given new values, so pass exact=3Dtrue here. */ - ret =3D blk_truncate(blk, new_size, true, PREALLOC_MODE_OFF, errp); + ret =3D blk_truncate(blk, new_size, true, PREALLOC_MODE_OFF, 0, er= rp); blk_unref(blk); if (ret < 0) { return ret; diff --git a/block/qed.c b/block/qed.c index fb6100bd20..b0fdb8f565 100644 --- a/block/qed.c +++ b/block/qed.c @@ -677,7 +677,7 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCrea= teOptions *opts, * The QED format associates file length with allocation status, * so a new file (which is empty) must have a length of 0. */ - ret =3D blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, errp); + ret =3D blk_truncate(blk, 0, true, PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { goto out; } diff --git a/block/vdi.c b/block/vdi.c index e1a11f2aa0..0c7835ae70 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -875,7 +875,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreate= Options *create_options, =20 if (image_type =3D=3D VDI_TYPE_STATIC) { ret =3D blk_truncate(blk, offset + blocks * block_size, false, - PREALLOC_MODE_OFF, errp); + PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { error_prepend(errp, "Failed to statically allocate file"); goto exit; diff --git a/block/vhdx.c b/block/vhdx.c index 5dfbb2029a..21497f7318 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1703,13 +1703,13 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVV= HDXState *s, /* All zeroes, so we can just extend the file - the end of the BAT * is the furthest thing we have written yet */ ret =3D blk_truncate(blk, data_file_offset, false, PREALLOC_MODE_O= FF, - errp); + 0, errp); if (ret < 0) { goto exit; } } else if (type =3D=3D VHDX_TYPE_FIXED) { ret =3D blk_truncate(blk, data_file_offset + image_size, false, - PREALLOC_MODE_OFF, errp); + PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { goto exit; } diff --git a/block/vmdk.c b/block/vmdk.c index 5de99fe813..8ec18f35a5 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2118,7 +2118,7 @@ static int vmdk_init_extent(BlockBackend *blk, int gd_buf_size; =20 if (flat) { - ret =3D blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, errp= ); + ret =3D blk_truncate(blk, filesize, false, PREALLOC_MODE_OFF, 0, e= rrp); goto exit; } magic =3D cpu_to_be32(VMDK4_MAGIC); @@ -2182,7 +2182,7 @@ static int vmdk_init_extent(BlockBackend *blk, } =20 ret =3D blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, - PREALLOC_MODE_OFF, errp); + PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { goto exit; } @@ -2523,7 +2523,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t siz= e, /* bdrv_pwrite write padding zeros to align to sector, we don't need t= hat * for description file */ if (desc_offset =3D=3D 0) { - ret =3D blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, errp= ); + ret =3D blk_truncate(blk, desc_len, false, PREALLOC_MODE_OFF, 0, e= rrp); if (ret < 0) { goto exit; } diff --git a/block/vpc.c b/block/vpc.c index d8141b52da..2d1eade146 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -898,7 +898,7 @@ static int create_fixed_disk(BlockBackend *blk, uint8_t= *buf, /* Add footer to total size */ total_size +=3D HEADER_SIZE; =20 - ret =3D blk_truncate(blk, total_size, false, PREALLOC_MODE_OFF, errp); + ret =3D blk_truncate(blk, total_size, false, PREALLOC_MODE_OFF, 0, err= p); if (ret < 0) { return ret; } diff --git a/blockdev.c b/blockdev.c index 5faddaa705..fbe3a06dbf 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2741,7 +2741,7 @@ void qmp_block_resize(bool has_device, const char *de= vice, } =20 bdrv_drained_begin(bs); - ret =3D blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp); + ret =3D blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp); bdrv_drained_end(bs); =20 out: diff --git a/qemu-img.c b/qemu-img.c index 821cbf610e..7f52742ef2 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3866,7 +3866,7 @@ static int img_resize(int argc, char **argv) * resizing, so pass @exact=3Dtrue. It is of no use to report * success when the image has not actually been resized. */ - ret =3D blk_truncate(blk, total_size, true, prealloc, &err); + ret =3D blk_truncate(blk, total_size, true, prealloc, 0, &err); if (!ret) { qprintf(quiet, "Image resized.\n"); } else { diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 1b7e700020..851f07e8f8 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1715,7 +1715,7 @@ static int truncate_f(BlockBackend *blk, int argc, ch= ar **argv) * exact=3Dtrue. It is better to err on the "emit more errors" side * than to be overly permissive. */ - ret =3D blk_truncate(blk, offset, true, PREALLOC_MODE_OFF, &local_err); + ret =3D blk_truncate(blk, offset, true, PREALLOC_MODE_OFF, 0, &local_e= rr); if (ret < 0) { error_report_err(local_err); return ret; --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389980; cv=none; d=zohomail.com; s=zohoarc; b=QK1A5DElLkMJ1nYR+kzNsUDpCdcGko1cW7lmj8OmpnfdyTalJEyzI2E8h0ubTf/s3KUWtWBTIc3ZizSs8vTXtJWCrdhExtj4EDf5aN8M4aTNjiT8iH9QfYuW/vmCVrkq/4nWRDeMnUZbY0xRvZfNQHLgUQVN5mtrzfc5jgTAEis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bap6ceJwml4SlZOkLptyTKbBRJeROgfUbVXe4M3j/2M=; b=eyT3SUlUv528c8XbkuMqEQCAoJiPUJPUpTeL8mgszw4kNzgBKoepj/anZXTxfH4qieFmUm8mPaQYQvLaF3lLHCUQC8KxHqKhj+ZWIRKmobdJYoPFIuSvFhj3I3ju1ISzi4zgrXL+lTlWqEjS95T2NiwKh1EeMWZ62ItwUoXxwFQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389980030468.8982730241447; Mon, 20 Apr 2020 06:39:40 -0700 (PDT) Received: from localhost ([::1]:35820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWeB-0005k1-7U for importer@patchew.org; Mon, 20 Apr 2020 09:39:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60874 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXh-0004M4-MV for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:03 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXY-0004ce-J5 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31653 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXY-0004a2-37 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-8RwFn6zMNruHnpLlZUF5YA-1; Mon, 20 Apr 2020 09:32:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88511DB23; Mon, 20 Apr 2020 13:32:40 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FAF511E7E7; Mon, 20 Apr 2020 13:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bap6ceJwml4SlZOkLptyTKbBRJeROgfUbVXe4M3j/2M=; b=PqJ3n89BceV1Hi2ja2jK2V1GgnWY3rl9M2pX4qem3ZcnThsUkigCfLbYR4tJvsWfhimBu7 eb+vFBgCEknaiSYG+gvpYkEH2uT9zlM9xB0cPFS4ZCzGRn1o9M2BJuMURDE/AKZJoSjdks RpyW726bVPICP2pduv8TMlQLmW/E/tE= X-MC-Unique: 8RwFn6zMNruHnpLlZUF5YA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 4/9] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate Date: Mon, 20 Apr 2020 15:32:09 +0200 Message-Id: <20200420133214.28921-5-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 03:29:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If BDRV_REQ_ZERO_WRITE is set and we're extending the image, calling qcow2_cluster_zeroize() with flags=3D0 does the right thing: It doesn't undo any previous preallocation, but just adds the zero flag to all relevant L2 entries. If an external data file is in use, a write_zeroes request to the data file is made instead. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia --- block/qcow2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 6c6d6101ce..7a70c1c090 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1726,6 +1726,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, =20 bs->supported_zero_flags =3D header.version >=3D 3 ? BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK := 0; + bs->supported_truncate_flags =3D BDRV_REQ_ZERO_WRITE; =20 /* Repair image if dirty */ if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && @@ -4213,6 +4214,14 @@ static int coroutine_fn qcow2_co_truncate(BlockDrive= rState *bs, int64_t offset, g_assert_not_reached(); } =20 + if ((flags & BDRV_REQ_ZERO_WRITE) && offset > old_length) { + ret =3D qcow2_cluster_zeroize(bs, old_length, offset - old_length,= 0); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to zero out the new area"= ); + goto fail; + } + } + if (prealloc !=3D PREALLOC_MODE_OFF) { /* Flush metadata before actually changing the image size */ ret =3D qcow2_write_caches(bs); --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389822; cv=none; d=zohomail.com; s=zohoarc; b=T2A575zDMY1XSqx7JtUNTgvo05XUPLwARQx/OnvdhWWTNZG8Hzgd9DcfjoyoSa/AinbfcRma2yl1hyoUuTg8K8XI+sOZS+4suo+CV5XcFHDeWIxCLY+/LA9lHXpACfLxaZKu/aDHvP0Pk6hlbXSizWQ9KX5ZfNBsZVpm6Svh4ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389822; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mL7UBIhvoG/wLPQSUq9KSKO3TPT+U79RqGcRCCVcc7g=; b=JM8Fia0ady6JLcdo5wYoRMhnUrm9rcns78+trxMLsLrosEIWEMRAWdevB2uKq9HGW1iXHpWM8QDhJrkl7a5tPpUrrFcgXzEUtIxql5mvbq0YsIitqhqbrG9qWKPujYA5iZ/tkEPO2W3Rt/xgkqDIRGC6mtGHYe9ms2cl2OeelnQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389822658686.8031454361846; Mon, 20 Apr 2020 06:37:02 -0700 (PDT) Received: from localhost ([::1]:35770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWbd-00019E-RH for importer@patchew.org; Mon, 20 Apr 2020 09:37:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60844 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004LW-Lg for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:57 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXY-0004cH-G3 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:52 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20498 helo=us-smtp-delivery-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXW-0004ZE-R2 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-rxm_UCPHPYycpYcbGqtobg-1; Mon, 20 Apr 2020 09:32:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5343A801F9B; Mon, 20 Apr 2020 13:32:42 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0F79118DF5; Mon, 20 Apr 2020 13:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mL7UBIhvoG/wLPQSUq9KSKO3TPT+U79RqGcRCCVcc7g=; b=INhNHaIUTj0fiB2ImK6btfKzZqQLi6kUmHLRCKXiqqco2miB3vMrxijj0+W24y1t7zrCLU vk+D4y0Uu3cwqOv9JHgwkbl7tWqZ2wKjQKMduJhPKkl961wDu3LCRwzOYzoppEBb4qNYwe cMlX/H8JL8Z3Knpl1yy8aRLFSg7rd1g= X-MC-Unique: rxm_UCPHPYycpYcbGqtobg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 5/9] raw-format: Support BDRV_REQ_ZERO_WRITE for truncate Date: Mon, 20 Apr 2020 15:32:10 +0200 Message-Id: <20200420133214.28921-6-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 01:47:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The raw format driver can simply forward the flag and let its bs->file child take care of actually providing the zeros. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia --- block/raw-format.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/raw-format.c b/block/raw-format.c index 3465c9a865..ab69ac46d3 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -387,7 +387,7 @@ static int coroutine_fn raw_co_truncate(BlockDriverStat= e *bs, int64_t offset, =20 s->size =3D offset; offset +=3D s->offset; - return bdrv_co_truncate(bs->file, offset, exact, prealloc, 0, errp); + return bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp= ); } =20 static void raw_eject(BlockDriverState *bs, bool eject_flag) @@ -445,6 +445,7 @@ static int raw_open(BlockDriverState *bs, QDict *option= s, int flags, bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED | ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); + bs->supported_truncate_flags =3D BDRV_REQ_ZERO_WRITE; =20 if (bs->probed && !bdrv_is_read_only(bs)) { bdrv_refresh_filename(bs->file->bs); --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389974; cv=none; d=zohomail.com; s=zohoarc; b=NMcQYm0khqbYiPWDbKT2/Gv92/M9qCCNWAoDT6GscByw3SOZIJ11oveIdlVaAeBdlhtQultReaG70Hw92lhSmvKramFuvUoBQk0Ylj90I8V5kpcYK4WX/kZaO/3O991B2Rr9Q3mYBP7Fl6Kp4o5mxo51zmMhUkaVr6md5OTp3Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389974; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qKXUZmlru6pmYggmL/tjU9HOqkL962sW3qnltYaDw5U=; b=C3+olMgecSsJwojZPjWS+1vsU7p0hvFW9s42s3RciJuRsZSAttFKbf3hrB1f3RNfgOJt1l53WYpfClfZQqxcMTG+AihqVZcrXjHIUFtuxwLfp19PY7R3CtEdYASP3wL1B6ifKLJb2OuBgcAGxYQc/RJIoLrz/rcHx9eeHonMmjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389974778475.42354802100385; Mon, 20 Apr 2020 06:39:34 -0700 (PDT) Received: from localhost ([::1]:35818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWe3-0005Yz-O9 for importer@patchew.org; Mon, 20 Apr 2020 09:39:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60934 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXn-0004Ny-5K for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:06 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004hv-Uy for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60206 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004en-F7 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-JdqBXKGvNvyj_4wADwKdxQ-1; Mon, 20 Apr 2020 09:32:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32FC88024E5; Mon, 20 Apr 2020 13:32:44 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E117116D9F; Mon, 20 Apr 2020 13:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qKXUZmlru6pmYggmL/tjU9HOqkL962sW3qnltYaDw5U=; b=FHSF/nxSPHNu/klvUb3yLqN+rmXNrhHjW2rbPFXBxepie/h5Nb9eFYCksoY2sCqZGnHoRE JwDUfFXmISKhHkFA/z63Gdtd/uBLESR3a53cdGc9iiv91NtO7WWsnoTr8MUKsYLgYEDLNu 92qU+hWmznFxpbSjOsetV2oUSjtXkw0= X-MC-Unique: JdqBXKGvNvyj_4wADwKdxQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 6/9] file-posix: Support BDRV_REQ_ZERO_WRITE for truncate Date: Mon, 20 Apr 2020 15:32:11 +0200 Message-Id: <20200420133214.28921-7-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 04:32:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For regular files, we always get BDRV_REQ_ZERO_WRITE behaviour from the OS, so we can advertise the flag and just ignore it. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/file-posix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 53f475ed61..1dca220a81 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -702,6 +702,10 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, #endif =20 bs->supported_zero_flags =3D BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK; + if (S_ISREG(st.st_mode)) { + /* When extending regular files, we get zeros from the OS */ + bs->supported_truncate_flags =3D BDRV_REQ_ZERO_WRITE; + } ret =3D 0; fail: if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) { --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389690; cv=none; d=zohomail.com; s=zohoarc; b=DX6KOoo+AR4/FCCcZg4vmODg0ntJgV5NtkOiTAXTIKUfAaTIi0Nig+IjggV3WFqrLTH6HKY+U4dmvcY6Ay1GNGm4E6oBcv9imQI3m+eY/zrG+oX/jqfDXaeH8jAbQk02ghXJpJapuubWY+TiTB3S4I1RdM8VAYVkChHycUhlPxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389690; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jcer1LVMtRqjIwUaiSpHPGpJOhvpyU4IPvZZtPti7wU=; b=A5sfK/m/NdcUZn1rX71+Eqlf402q/tOEGVM/f4zmdTex9YzkoRjltBVQ3mZdFXQxEThjnVbxHjHnNWGd4qxYmBk9rARJapnwhjhizFx84FKs9tMSCU8JGjV/x07XvR93cLEzg+SqK2JlhEI3CvuMQQeQIM99Jzun80GgTBFhEwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389690131566.3313040956076; Mon, 20 Apr 2020 06:34:50 -0700 (PDT) Received: from localhost ([::1]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWZV-0006TB-4V for importer@patchew.org; Mon, 20 Apr 2020 09:34:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60900 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXl-0004Mq-3s for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:06 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004he-Uf for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:59 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60680 helo=us-smtp-delivery-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004de-D6 for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285--Ky8TvMcN5OXy8lUZS39mg-1; Mon, 20 Apr 2020 09:32:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00CAA802570; Mon, 20 Apr 2020 13:32:46 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A8CF116D9F; Mon, 20 Apr 2020 13:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jcer1LVMtRqjIwUaiSpHPGpJOhvpyU4IPvZZtPti7wU=; b=bl4i68jiOLrp0/5CnKKCZrRGdChYkeIwPXxbo+1PrzWTfuGdtMigSm0+o3JQlWLeh8RWV8 xtPcFYliAYXYThNTYt5A7dABCdlfbcxeOIlc7eca9d9Tr4ConhVdaE39JykQAVUndT/qRq VsgfEK9HY72CtRYWfkWjNJtEO30KWSc= X-MC-Unique: -Ky8TvMcN5OXy8lUZS39mg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 7/9] block: truncate: Don't make backing file data visible Date: Mon, 20 Apr 2020 15:32:12 +0200 Message-Id: <20200420133214.28921-8-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 01:47:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" When extending the size of an image that has a backing file larger than its old size, make sure that the backing file data doesn't become visible in the guest, but the added area is properly zeroed out. Consider the following scenario where the overlay is shorter than its backing file: base.qcow2: AAAAAAAA overlay.qcow2: BBBB When resizing (extending) overlay.qcow2, the new blocks should not stay unallocated and make the additional As from base.qcow2 visible like before this patch, but zeros should be read. A similar case happens with the various variants of a commit job when an intermediate file is short (- for unallocated): base.qcow2: A-A-AAAA mid.qcow2: BB-B top.qcow2: C--C--C- After commit top.qcow2 to mid.qcow2, the following happens: mid.qcow2: CB-C00C0 (correct result) mid.qcow2: CB-C--C- (before this fix) Without the fix, blocks that previously read as zeros on top.qcow2 suddenly turn into A. Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia --- block/io.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/io.c b/block/io.c index 795075954e..f149dff3ba 100644 --- a/block/io.c +++ b/block/io.c @@ -3394,6 +3394,20 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, = int64_t offset, bool exact, goto out; } =20 + /* + * If the image has a backing file that is large enough that it would + * provide data for the new area, we cannot leave it unallocated becau= se + * then the backing file content would become visible. Instead, zero-f= ill + * the area where backing file and new area overlap. + * + * Note that if the image has a backing file, but was opened without t= he + * backing file, taking care of keeping things consistent with that ba= cking + * file is the user's responsibility. + */ + if (new_bytes && bs->backing) { + flags |=3D BDRV_REQ_ZERO_WRITE; + } + if (drv->bdrv_co_truncate) { if (flags & ~bs->supported_truncate_flags) { error_setg(errp, "Block driver does not support requested flag= s"); --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587389839; cv=none; d=zohomail.com; s=zohoarc; b=WomF2ugdaH49GT3mhAeqbNIYEJCFqVI/eOxQsVweoIjcKtSLWOoxOCxtmFyX+YKFr32TEbIWTHKWAk0E7AQECrn7cDpL2lzdF16C3XcufAvjfwkrIYFQ7iSPLedmbGwyZ3oHm6Q16SMSyzph+HZC9ExV22DLivcJA5VjsPmKmYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587389839; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2XnrMwGu/xHrxu+4elEdDQvksopg+zhKpBMUt0ExzpQ=; b=YUzuFeEHzLB9Cemqi3Vp4wGWBxMn8FOhQkDjPiJpljC+cKQ9HvbbtrLJIPegiUq3utCnrWHRKjiKneSHpnfIzw58ohuHBgyx1cWjALdsOaGKUMm33hiMyEv4jj4dSQe5VDZFUMyoHVzBYkiWQen0GqvelLmMXBMBJ2AY5Nu8yJ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587389839964842.0273692287548; Mon, 20 Apr 2020 06:37:19 -0700 (PDT) Received: from localhost ([::1]:35776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWbv-0001fe-6K for importer@patchew.org; Mon, 20 Apr 2020 09:37:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60918 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXl-0004N8-FL for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:06 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXd-0004iI-1H for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52509 helo=us-smtp-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXc-0004dw-Fv for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-9U83nwtZMpGQUB-bF50CLA-1; Mon, 20 Apr 2020 09:32:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C376DDBA9; Mon, 20 Apr 2020 13:32:47 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B1ED118DF5; Mon, 20 Apr 2020 13:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2XnrMwGu/xHrxu+4elEdDQvksopg+zhKpBMUt0ExzpQ=; b=IfpkXb8GGxFxILKvrDsCYM3qVtNem1FU2deZe7jY0KTr5ozHRhvbM5FwRB2EeYkWfMpq2u KjUi3ShMMPj+FoNjtzp7Q3fHz1YMIUAy8mzwViQEDPr6O9uMHhOvwCz6y1b3dDwKd9gA86 4cIgv1mKZAXeWhmidYGSqge2CN5o8Bw= X-MC-Unique: 9U83nwtZMpGQUB-bF50CLA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 8/9] iotests: Filter testfiles out in img_info_log() Date: Mon, 20 Apr 2020 15:32:13 +0200 Message-Id: <20200420133214.28921-9-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 04:32:42 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This changes the output of some files where instead of filter_img_info() now filter_testfiles() takes precedence, so update the reference output. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 5 ++++- tests/qemu-iotests/206.out | 12 ++++++------ tests/qemu-iotests/242.out | 12 ++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7bc4934cd2..3eaf29411b 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -152,7 +152,10 @@ def img_info_log(filename, filter_path=3DNone, imgopts= =3DFalse, extra_args=3D[]): output =3D qemu_img_pipe(*args) if not filter_path: filter_path =3D filename - log(filter_img_info(output, filter_path)) + + output =3D filter_testfiles(output) + output =3D filter_img_info(output, filter_path) + log(output) =20 def qemu_io(*args): '''Run qemu-io and return the stdout data''' diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index 61e7241e0b..adde82f9b8 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -12,7 +12,7 @@ {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: TEST_IMG +image: TEST_DIR/PID-t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) cluster_size: 65536 @@ -34,7 +34,7 @@ Format specific information: {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: TEST_IMG +image: TEST_DIR/PID-t.IMGFMT file format: IMGFMT virtual size: 64 MiB (67108864 bytes) cluster_size: 65536 @@ -56,7 +56,7 @@ Format specific information: {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: TEST_IMG +image: TEST_DIR/PID-t.IMGFMT file format: IMGFMT virtual size: 32 MiB (33554432 bytes) cluster_size: 2097152 @@ -78,11 +78,11 @@ Format specific information: {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: TEST_IMG +image: TEST_DIR/PID-t.IMGFMT file format: IMGFMT virtual size: 32 MiB (33554432 bytes) cluster_size: 512 -backing file: TEST_IMG.base +backing file: TEST_DIR/PID-t.IMGFMT.base backing file format: IMGFMT Format specific information: compat: 0.10 @@ -95,7 +95,7 @@ Format specific information: {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -image: TEST_IMG +image: TEST_DIR/PID-t.IMGFMT file format: IMGFMT virtual size: 32 MiB (33554432 bytes) encrypted: yes diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out index 7ac8404d11..0cc3a78bb2 100644 --- a/tests/qemu-iotests/242.out +++ b/tests/qemu-iotests/242.out @@ -6,7 +6,7 @@ wrote 262144/262144 bytes at offset 0 =20 qemu-img info dump: =20 -image: TEST_IMG +image: TEST_DIR/PID-disk file format: IMGFMT virtual size: 1 MiB (1048576 bytes) cluster_size: 65536 @@ -26,7 +26,7 @@ wrote 262144/262144 bytes at offset 262144 =20 qemu-img info dump: =20 -image: TEST_IMG +image: TEST_DIR/PID-disk file format: IMGFMT virtual size: 1 MiB (1048576 bytes) cluster_size: 65536 @@ -58,7 +58,7 @@ wrote 262144/262144 bytes at offset 524288 =20 qemu-img info dump: =20 -image: TEST_IMG +image: TEST_DIR/PID-disk file format: IMGFMT virtual size: 1 MiB (1048576 bytes) cluster_size: 65536 @@ -98,7 +98,7 @@ Test 4 Checking "in-use" flag... qemu-img info dump: =20 -image: TEST_IMG +image: TEST_DIR/PID-disk file format: IMGFMT virtual size: 1 MiB (1048576 bytes) cluster_size: 65536 @@ -143,11 +143,11 @@ Test 5 {"execute": "block-dirty-bitmap-add", "arguments": {"disabled": false, "gr= anularity": 16384, "name": "bitmap-0", "node": "drive0", "persistent": true= }} {"return": {}} Write an unknown bitmap flag '0x4' into a new QCOW2 image at offset 327695 -qemu-img: Could not open 'TEST_IMG': Bitmap 'bitmap-0' doesn't satisfy the= constraints +qemu-img: Could not open 'TEST_DIR/PID-disk': Bitmap 'bitmap-0' doesn't sa= tisfy the constraints =20 Unset the unknown bitmap flag '0x4' in the bitmap directory entry: =20 -image: TEST_IMG +image: TEST_DIR/PID-disk file format: IMGFMT virtual size: 1 MiB (1048576 bytes) cluster_size: 65536 --=20 2.20.1 From nobody Fri May 17 11:05:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587390095; cv=none; d=zohomail.com; s=zohoarc; b=ZIMcR7tf0ER0tO9nl8iUR2plM8mo6PNagFX9T+tOneZFB8szi+Fj0yC1382R+rk6Dv5kMtQdCCKaacPnIm7fy5wxjqXNKgQ2OFcxWNDY093rSOWGQpMxbo2kEcaJGAzrK/VYsogfNvxhnu0TJ6gtpK+fBML6KtvEmYJzc5dikxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587390095; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TKgSYL+n34pyRoNUSwIA3YPeiaGgpSG5KHzV8/c4x7U=; b=aAAptOxzcjWi3IVkHFFTs/ONMNUiKF744nRT2Hd6I4/1N7R2mNI8+IaBp76NVUr/1JQ5YJD8XbfcgUO9M9MAOtZaogdDeiT9NWNVykDbDfh4/InFPSx/gnUbcNZwOT14auTW5KDGHOn0rwRxghN/lI2L623JHanuz7ehGUNJ0YQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1587390095749724.5050639374715; Mon, 20 Apr 2020 06:41:35 -0700 (PDT) Received: from localhost ([::1]:35882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWg2-00016a-Tt for importer@patchew.org; Mon, 20 Apr 2020 09:41:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60958 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQWXp-0004Pi-3K for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:16 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQWXl-0004y3-7c for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:33:04 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48369 helo=us-smtp-delivery-1.mimecast.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jQWXj-0004lu-4d for qemu-devel@nongnu.org; Mon, 20 Apr 2020 09:32:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-252-aoaIP0VRPVmVStry10J41g-1; Mon, 20 Apr 2020 09:32:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B729ADBA6; Mon, 20 Apr 2020 13:32:49 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-38.ams2.redhat.com [10.36.114.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19851116D8B; Mon, 20 Apr 2020 13:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587389575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TKgSYL+n34pyRoNUSwIA3YPeiaGgpSG5KHzV8/c4x7U=; b=GhWeUVcI/FuxCAgw5/uUblCdAmPY1pQChngpVzRKqxh44rRQdJjGQZDD57zN4eZLNAr2WE VXmAyU57jImpOkx/Xf7bUToCcpBQjG7/8d457ck26J9gnrMWsqkgcZyn+oimJ3qrt73i2x ZJUYexzV+1kjR3GT9tgPh7sIzZ2Bpuk= X-MC-Unique: aoaIP0VRPVmVStry10J41g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v4 9/9] iotests: Test committing to short backing file Date: Mon, 20 Apr 2020 15:32:14 +0200 Message-Id: <20200420133214.28921-10-kwolf@redhat.com> In-Reply-To: <20200420133214.28921-1-kwolf@redhat.com> References: <20200420133214.28921-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/20 09:01:45 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Tested-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/274 | 152 ++++++++++++++++++++++++++++ tests/qemu-iotests/274.out | 202 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 355 insertions(+) create mode 100755 tests/qemu-iotests/274 create mode 100644 tests/qemu-iotests/274.out diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274 new file mode 100755 index 0000000000..30463e54e7 --- /dev/null +++ b/tests/qemu-iotests/274 @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Creator/Owner: Kevin Wolf +# +# Some tests for short backing files and short overlays + +import iotests +import os + +iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.verify_platform(['linux']) + +size_short =3D 1 * 1024 * 1024 +size_long =3D 2 * 1024 * 1024 +size_diff =3D size_long - size_short + +def create_chain(): + iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, + str(size_long)) + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, mid, + str(size_short)) + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid, top, + str(size_long)) + + iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base) + +def create_vm(): + vm =3D iotests.VM() + vm.add_blockdev('file,filename=3D%s,node-name=3Dbase-file' % (base)) + vm.add_blockdev('%s,file=3Dbase-file,node-name=3Dbase' % (iotests.imgf= mt)) + vm.add_blockdev('file,filename=3D%s,node-name=3Dmid-file' % (mid)) + vm.add_blockdev('%s,file=3Dmid-file,node-name=3Dmid,backing=3Dbase' % = (iotests.imgfmt)) + vm.add_drive(top, 'backing=3Dmid,node-name=3Dtop') + return vm + +with iotests.FilePath('base') as base, \ + iotests.FilePath('mid') as mid, \ + iotests.FilePath('top') as top: + + iotests.log('=3D=3D Commit tests =3D=3D') + + create_chain() + + iotests.log('=3D=3D=3D Check visible data =3D=3D=3D') + + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, top) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff),= top) + + iotests.log('=3D=3D=3D Checking allocation status =3D=3D=3D') + + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, + '-c', 'alloc %d %d' % (size_short, size_diff), + base) + + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, + '-c', 'alloc %d %d' % (size_short, size_diff), + mid) + + iotests.qemu_io_log('-c', 'alloc 0 %d' % size_short, + '-c', 'alloc %d %d' % (size_short, size_diff), + top) + + iotests.log('=3D=3D=3D Checking map =3D=3D=3D') + + iotests.qemu_img_log('map', '--output=3Djson', base) + iotests.qemu_img_log('map', '--output=3Dhuman', base) + iotests.qemu_img_log('map', '--output=3Djson', mid) + iotests.qemu_img_log('map', '--output=3Dhuman', mid) + iotests.qemu_img_log('map', '--output=3Djson', top) + iotests.qemu_img_log('map', '--output=3Dhuman', top) + + iotests.log('=3D=3D=3D Testing qemu-img commit (top -> mid) =3D=3D=3D') + + iotests.qemu_img_log('commit', top) + iotests.img_info_log(mid) + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff),= mid) + + iotests.log('=3D=3D=3D Testing HMP commit (top -> mid) =3D=3D=3D') + + create_chain() + with create_vm() as vm: + vm.launch() + vm.qmp_log('human-monitor-command', command_line=3D'commit drive0') + + iotests.img_info_log(mid) + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff),= mid) + + iotests.log('=3D=3D=3D Testing QMP active commit (top -> mid) =3D=3D= =3D') + + create_chain() + with create_vm() as vm: + vm.launch() + vm.qmp_log('block-commit', device=3D'top', base_node=3D'mid', + job_id=3D'job0', auto_dismiss=3DFalse) + vm.run_job('job0', wait=3D5) + + iotests.img_info_log(mid) + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff),= mid) + + + iotests.log('=3D=3D Resize tests =3D=3D') + + # Use different sizes for different allocation modes: + # + # We want to have at least one test where 32 bit truncation in the siz= e of + # the overlapping area becomes visible. This is covered by the + # prealloc=3D'off' case (1G to 6G is an overlap of 5G). + # + # However, we can only do this for modes that don't preallocate data + # because otherwise we might run out of space on the test host. + for (prealloc, base_size, top_size_old, top_size_new, off) in [ + ('off', '6G', '1G', '8G', '5G'), + ('metadata', '32G', '30G', '33G', '31G'), + ('falloc', '10M', '5M', '15M', '9M'), + ('full', '16M', '8M', '12M', '11M')]: + + iotests.log('=3D=3D=3D preallocation=3D%s =3D=3D=3D' % prealloc) + iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_si= ze) + iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base, t= op, + top_size_old) + iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base) + + # After this, 0 to base_size should be allocated/zeroed + # base_size to top_size_new should be unallocated with + # preallocation=3Doff and allocated with preallocation enabled + iotests.qemu_img_log('resize', '-f', iotests.imgfmt, + '--preallocation', prealloc, top, top_size_ne= w) + iotests.qemu_io_log('-c', 'read -P 0 %s 64k' % off, top) + + # Metadata preallocation doesn't have a defined result on the file + # system level with respect to holes, so skip it here + iotests.qemu_io_log('-c', 'map', top) + if prealloc !=3D 'metadata': + iotests.qemu_img_log('map', '--output=3Djson', top) diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out new file mode 100644 index 0000000000..b11f8ad680 --- /dev/null +++ b/tests/qemu-iotests/274.out @@ -0,0 +1,202 @@ +=3D=3D Commit tests =3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +wrote 2097152/2097152 bytes at offset 0 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Check visible data =3D=3D=3D +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Checking allocation status =3D=3D=3D +1048576/1048576 bytes allocated at offset 0 bytes +1048576/1048576 bytes allocated at offset 1 MiB + +0/1048576 bytes allocated at offset 0 bytes +0/0 bytes allocated at offset 1 MiB + +0/1048576 bytes allocated at offset 0 bytes +0/1048576 bytes allocated at offset 1 MiB + +=3D=3D=3D Checking map =3D=3D=3D +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true,= "offset": 327680}] + +Offset Length Mapped to File +0 0x200000 0x50000 TEST_DIR/PID-base + +[{ "start": 0, "length": 1048576, "depth": 1, "zero": false, "data": true,= "offset": 327680}] + +Offset Length Mapped to File +0 0x100000 0x50000 TEST_DIR/PID-base + +[{ "start": 0, "length": 1048576, "depth": 2, "zero": false, "data": true,= "offset": 327680}, +{ "start": 1048576, "length": 1048576, "depth": 0, "zero": true, "data": f= alse}] + +Offset Length Mapped to File +0 0x100000 0x50000 TEST_DIR/PID-base + +=3D=3D=3D Testing qemu-img commit (top -> mid) =3D=3D=3D +Image committed. + +image: TEST_DIR/PID-mid +file format: IMGFMT +virtual size: 2 MiB (2097152 bytes) +cluster_size: 65536 +backing file: TEST_DIR/PID-base +Format specific information: + compat: 1.1 + lazy refcounts: false + refcount bits: 16 + corrupt: false + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Testing HMP commit (top -> mid) =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +wrote 2097152/2097152 bytes at offset 0 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +{"execute": "human-monitor-command", "arguments": {"command-line": "commit= drive0"}} +{"return": ""} +image: TEST_DIR/PID-mid +file format: IMGFMT +virtual size: 2 MiB (2097152 bytes) +cluster_size: 65536 +backing file: TEST_DIR/PID-base +Format specific information: + compat: 1.1 + lazy refcounts: false + refcount bits: 16 + corrupt: false + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Testing QMP active commit (top -> mid) =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +wrote 2097152/2097152 bytes at offset 0 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +{"execute": "block-commit", "arguments": {"auto-dismiss": false, "base-nod= e": "mid", "device": "top", "job-id": "job0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "job0"}} +{"return": {}} +{"data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "co= mmit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": "USECS", = "seconds": "SECS"}} +{"data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "co= mmit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USEC= S", "seconds": "SECS"}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +image: TEST_DIR/PID-mid +file format: IMGFMT +virtual size: 2 MiB (2097152 bytes) +cluster_size: 65536 +backing file: TEST_DIR/PID-base +Format specific information: + compat: 1.1 + lazy refcounts: false + refcount bits: 16 + corrupt: false + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D Resize tests =3D=3D +=3D=3D=3D preallocation=3Doff =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D6442450944 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D1073741824 backing_file= =3DTEST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bit= s=3D16 + +wrote 65536/65536 bytes at offset 5368709120 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Image resized. + +read 65536/65536 bytes at offset 5368709120 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +1 GiB (0x40000000) bytes not allocated at offset 0 bytes (0x0) +7 GiB (0x1c0000000) bytes allocated at offset 1 GiB (0x40000000) + +[{ "start": 0, "length": 1073741824, "depth": 1, "zero": true, "data": fal= se}, +{ "start": 1073741824, "length": 7516192768, "depth": 0, "zero": true, "da= ta": false}] + +=3D=3D=3D preallocation=3Dmetadata =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D34359738368 cluster_siz= e=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D32212254720 backing_file= =3DTEST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bit= s=3D16 + +wrote 65536/65536 bytes at offset 33285996544 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Image resized. + +read 65536/65536 bytes at offset 33285996544 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +30 GiB (0x780000000) bytes not allocated at offset 0 bytes (0x0) +3 GiB (0xc0000000) bytes allocated at offset 30 GiB (0x780000000) + +=3D=3D=3D preallocation=3Dfalloc =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D10485760 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D5242880 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 + +wrote 65536/65536 bytes at offset 9437184 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Image resized. + +read 65536/65536 bytes at offset 9437184 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +5 MiB (0x500000) bytes not allocated at offset 0 bytes (0x0) +10 MiB (0xa00000) bytes allocated at offset 5 MiB (0x500000) + +[{ "start": 0, "length": 5242880, "depth": 1, "zero": true, "data": false}, +{ "start": 5242880, "length": 10485760, "depth": 0, "zero": true, "data": = false, "offset": 327680}] + +=3D=3D=3D preallocation=3Dfull =3D=3D=3D +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D16777216 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 + +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D8388608 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 + +wrote 65536/65536 bytes at offset 11534336 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Image resized. + +read 65536/65536 bytes at offset 11534336 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +8 MiB (0x800000) bytes not allocated at offset 0 bytes (0x0) +4 MiB (0x400000) bytes allocated at offset 8 MiB (0x800000) + +[{ "start": 0, "length": 8388608, "depth": 1, "zero": true, "data": false}, +{ "start": 8388608, "length": 4194304, "depth": 0, "zero": true, "data": f= alse, "offset": 327680}] + diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 435dccd5af..1710470e70 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -286,6 +286,7 @@ 270 rw backing quick 272 rw 273 backing quick +274 rw backing 277 rw quick 279 rw backing quick 280 rw migration quick --=20 2.20.1