From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542346411761.6647695846092; Tue, 13 Feb 2018 09:19:06 -0800 (PST) Received: from localhost ([::1]:56001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleET-0005ct-Ch for importer@patchew.org; Tue, 13 Feb 2018 12:19:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1X-0002jl-Qn for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1U-00058b-PJ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:43 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37800 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1R-00056C-Sn; Tue, 13 Feb 2018 12:05:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DB974022909; Tue, 13 Feb 2018 17:05:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCE1810073CD; Tue, 13 Feb 2018 17:05:36 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:35 +0100 Message-Id: <20180213170529.10858-2-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:37 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 01/55] iotests: Fix CID for VMDK afl image X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng This reverts commit 76bf133c4 which updated the reference output, and fixed the reference image, because the code path we want to exercise is actually the invalid image size. The descriptor block in the image, which includes the CID to verify, has be= en invalid since the reference image was added. Since commit 9877860e7bd we re= port this error earlier than the "file too large", so 059.out mismatches. The binary change is generated along the operations of: $ bunzip2 afl9.vmdk.bz2 $ qemu-img create -f vmdk fix.vmdk 1G $ dd if=3Dafl9.vmdk of=3Dfix.vmdk bs=3D512 count=3D1 conv=3Dnotrunc $ mv fix.vmdk afl9.vmdk $ bzip2 afl9.vmdk Signed-off-by: Fam Zheng Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/059.out | 2 +- tests/qemu-iotests/sample_images/afl9.vmdk.bz2 | Bin 178 -> 618 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 1ac5d56233..f6dce7947c 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -2358,5 +2358,5 @@ Offset Length Mapped to File 0x140000000 0x10000 0x50000 TEST_DIR/t-s003.vmdk =20 =3D=3D=3D Testing afl image with a very large capacity =3D=3D=3D -qemu-img: Could not open 'TEST_DIR/afl9.IMGFMT': Could not open 'TEST_DIR/= afl9.IMGFMT': Invalid argument +qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large *** done diff --git a/tests/qemu-iotests/sample_images/afl9.vmdk.bz2 b/tests/qemu-io= tests/sample_images/afl9.vmdk.bz2 index 03615d36a12425cf4240bab86f4cfe648db14572..9fcd0af45a815431acf4689e084= 5ecf2d333cd58 100644 GIT binary patch literal 618 zcmV-w0+szjT4*^jL0KkKSvgW7ssIN3|NsBH-Q9UpfAhclU70`s-*NE~5QvC~h=3D_=3DY zh>D2n*q*=3DvygR634445h35k;?00h9835kMW00004$iPepVE{Bqk)uhJ^wfGLr=3D)3s zhM5CR88jLh7)B;cA*K)*6GmuECPU3o4NWG5O#pg>Ak#xY8Z^CrMt}oD38Ns$ z02n}M0LdjZ&}cLPqd+nPKmn$j0iXe(02%-d27nnJriN-uE+X&cz@Bj4BBfd|yV!NB zwqkL}nW3AI5x^jp=3Dt%^F1pxqp)v#n#)j$zcm1xqv(!$2d*5%vF{5RPWnOV8-^tE<( zU~%&}Y0uNu*9Wt=3DyS^8PkC&gPueZO%IG;aD{l#sG`m4Ho*fsHXdM_(-i7fPIW zA+~n9iy_f)g8B2RILhd%F)dZ5f?7pFLw)@;Ncl3Bz9<|!xm0F{45K+gg8#n z4FNAJ!AN0A08g#Z9x|HJ$H)ZJi0004xF0SE*D03g5s00IDLSQelF ziVX^$pfWNUJrmRhn2k52pQ;Rs0EQC;(S%|!m`2~BZ@b++;etskRJUVl!Kt)wu7?VN zl;%JdqX2?TgsNVJP?87M*MvL1qQnBkCES&?0@MeaN-bL4;bDzxmMm|da4fuh!=3D#fu g@i9R@5z!av{9tA Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542807883236.12771447797104; Tue, 13 Feb 2018 09:26:47 -0800 (PST) Received: from localhost ([::1]:56176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleLu-0003O7-St for importer@patchew.org; Tue, 13 Feb 2018 12:26:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1Z-0002l7-PJ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1X-0005B8-Tt for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50772 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1S-00056k-PJ; Tue, 13 Feb 2018 12:05:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 692A4EB700; Tue, 13 Feb 2018 17:05:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8A2C10073CD; Tue, 13 Feb 2018 17:05:37 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:36 +0100 Message-Id: <20180213170529.10858-3-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:38 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 02/55] qemu-img.texi: Clean up parameter list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Split options out of the "@table @var" section and create a "@table @option", then use whitespaces and blank lines consistently. Suggested-by: Kevin Wolf Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Reviewed-by: Kashyap Chamarthy Signed-off-by: Kevin Wolf --- qemu-img.texi | 66 +++++++++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/qemu-img.texi b/qemu-img.texi index fdcf120f36..60a0e080c6 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -33,38 +33,14 @@ The following commands are supported: =20 Command parameters: @table @var -@item filename - is a disk image filename - -@item --object @var{objectdef} - -is a QEMU user creatable object definition. See the @code{qemu(1)} manual -page for a description of the object properties. The most common object -type is a @code{secret}, which is used to supply passwords and/or encrypti= on -keys. - -@item --image-opts - -Indicates that the source @var{filename} parameter is to be interpreted as= a -full option string, not a plain filename. This parameter is mutually -exclusive with the @var{-f} parameter. - -@item --target-image-opts =20 -Indicates that the @var{output_filename} parameter(s) are to be interprete= d as -a full option string, not a plain filename. This parameter is mutually -exclusive with the @var{-O} parameters. It is currently required to also u= se -the @var{-n} parameter to skip image creation. This restriction may be rel= axed -in a future release. +@item filename +is a disk image filename =20 @item fmt is the disk image format. It is guessed automatically in most cases. See b= elow for a description of the supported disk formats. =20 -@item --backing-chain -will enumerate information about backing files in a disk image chain. Refer -below for further description. - @item size is the disk image size in bytes. Optional suffixes @code{k} or @code{K} (kilobyte, 1024) @code{M} (megabyte, 1024k) and @code{G} (gigabyte, 1024M) @@ -74,42 +50,78 @@ and T (terabyte, 1024G) are supported. @code{b} is ign= ored. is the destination disk image filename =20 @item output_fmt - is the destination format +is the destination format + @item options is a comma separated list of format specific options in a name=3Dvalue format. Use @code{-o ?} for an overview of the options suppor= ted by the used format or see the format descriptions below for details. + @item snapshot_param is param used for internal snapshot, format is 'snapshot.id=3D[ID],snapshot.name=3D[NAME]' or '[ID_OR_NAME]' + @item snapshot_id_or_name is deprecated, use snapshot_param instead =20 +@end table + +@table @option + +@item --object @var{objectdef} +is a QEMU user creatable object definition. See the @code{qemu(1)} manual +page for a description of the object properties. The most common object +type is a @code{secret}, which is used to supply passwords and/or encrypti= on +keys. + +@item --image-opts +Indicates that the source @var{filename} parameter is to be interpreted as= a +full option string, not a plain filename. This parameter is mutually +exclusive with the @var{-f} parameter. + +@item --target-image-opts +Indicates that the @var{output_filename} parameter(s) are to be interprete= d as +a full option string, not a plain filename. This parameter is mutually +exclusive with the @var{-O} parameters. It is currently required to also u= se +the @var{-n} parameter to skip image creation. This restriction may be rel= axed +in a future release. + +@item --backing-chain +will enumerate information about backing files in a disk image chain. Refer +below for further description. + @item -c indicates that target image must be compressed (qcow format only) + @item -h with or without a command shows help and lists the supported formats + @item -p display progress bar (compare, convert and rebase commands only). If the @var{-p} option is not used for a command that supports it, the progress is reported when the process receives a @code{SIGUSR1} or @code{SIGINFO} signal. + @item -q Quiet mode - do not print any output (except errors). There's no progress = bar in case both @var{-q} and @var{-p} options are used. + @item -S @var{size} indicates the consecutive number of bytes that must contain only zeros for qemu-img to create a sparse image during conversion. This value is rou= nded down to the nearest 512 bytes. You may use the common size suffixes like @code{k} for kilobytes. + @item -t @var{cache} specifies the cache mode that should be used with the (destination) file. = See the documentation of the emulator's @code{-drive cache=3D...} option for a= llowed values. + @item -T @var{src_cache} specifies the cache mode that should be used with the source file(s). See the documentation of the emulator's @code{-drive cache=3D...} option for a= llowed values. + @end table =20 Parameters to snapshot subcommand: --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518541846437201.4976174130186; Tue, 13 Feb 2018 09:10:46 -0800 (PST) Received: from localhost ([::1]:55527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele6P-000714-IX for importer@patchew.org; Tue, 13 Feb 2018 12:10:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1Z-0002l5-HI for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1X-0005Aw-T9 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37804 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1T-00057V-N5; Tue, 13 Feb 2018 12:05:39 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53A44402291E; Tue, 13 Feb 2018 17:05:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3C5010073CD; Tue, 13 Feb 2018 17:05:38 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:37 +0100 Message-Id: <20180213170529.10858-4-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:39 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 03/55] qemu-img: Document --force-share / -U X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Reviewed-by: Kashyap Chamarthy Signed-off-by: Kevin Wolf --- qemu-img.texi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qemu-img.texi b/qemu-img.texi index 60a0e080c6..8a26400adb 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -86,6 +86,14 @@ exclusive with the @var{-O} parameters. It is currently = required to also use the @var{-n} parameter to skip image creation. This restriction may be rel= axed in a future release. =20 +@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +other QEMU processes to open it in write mode. For example, this can be us= ed to +get the image information (with 'info' subcommand) when the image is used = by a +running guest. Note that this could produce inconsistent results because = of +concurrent metadata changes, etc. This option is only allowed when opening +images in read-only mode. + @item --backing-chain will enumerate information about backing files in a disk image chain. Refer below for further description. --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542180597484.54581531232895; Tue, 13 Feb 2018 09:16:20 -0800 (PST) Received: from localhost ([::1]:55806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleBn-0003GP-Ln for importer@patchew.org; Tue, 13 Feb 2018 12:16:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1d-0002nc-CX for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005Fa-E1 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51168 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1U-00057z-JX; Tue, 13 Feb 2018 12:05:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E75B7D840; Tue, 13 Feb 2018 17:05:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F10B10075C2; Tue, 13 Feb 2018 17:05:39 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:38 +0100 Message-Id: <20180213170529.10858-5-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 04/55] docs: Document share-rw property more thoroughly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Suggested-by: Stefan Hajnoczi Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Reviewed-by: Kashyap Chamarthy Signed-off-by: Kevin Wolf --- docs/qemu-block-drivers.texi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/qemu-block-drivers.texi b/docs/qemu-block-drivers.texi index cd74767ed3..f1793692bb 100644 --- a/docs/qemu-block-drivers.texi +++ b/docs/qemu-block-drivers.texi @@ -845,6 +845,16 @@ QEMU transparently handles lock handover during shared= storage migration. For shared virtual disk images between multiple VMs, the "share-rw" device opt= ion should be used. =20 +By default, the guest has exclusive write access to its disk image. If the +guest can safely share the disk image with other writers the @code{-device +...,share-rw=3Don} parameter can be used. This is only safe if the guest = is +running software, such as a cluster file system, that coordinates disk acc= esses +to avoid corruption. + +Note that share-rw=3Don only declares the guest's ability to share the dis= k. +Some QEMU features, such as image file formats, require exclusive write ac= cess +to the disk image and this is unaffected by the share-rw=3Don option. + Alternatively, locking can be fully disabled by "locking=3Doff" block devi= ce option. In the command line, the option is usually in the form of "file.locking=3Doff" as the protocol driver is normally placed as a "file"= child --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542064591360.3501747090435; Tue, 13 Feb 2018 09:14:24 -0800 (PST) Received: from localhost ([::1]:55678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele9s-0001dE-22 for importer@patchew.org; Tue, 13 Feb 2018 12:14:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1d-0002no-GR for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005Fn-Iu for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37806 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1V-000599-GW; Tue, 13 Feb 2018 12:05:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 293754022909; Tue, 13 Feb 2018 17:05:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79CE310073CD; Tue, 13 Feb 2018 17:05:40 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:39 +0100 Message-Id: <20180213170529.10858-6-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:41 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 05/55] qcow2: Use g_try_realloc() in qcow2_expand_zero_clusters() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia g_realloc() aborts the program if it fails to allocate the required amount of memory. We want to detect that scenario and return an error instead, so let's use g_try_realloc(). Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 3a979bcd82..f077cd3ac5 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -2070,7 +2070,15 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, int l1_sectors =3D DIV_ROUND_UP(s->snapshots[i].l1_size * sizeof(uint64_t), BDRV_SECTOR_SIZE); =20 - l1_table =3D g_realloc(l1_table, l1_sectors * BDRV_SECTOR_SIZE); + uint64_t *new_l1_table =3D + g_try_realloc(l1_table, l1_sectors * BDRV_SECTOR_SIZE); + + if (!new_l1_table) { + ret =3D -ENOMEM; + goto fail; + } + + l1_table =3D new_l1_table; =20 ret =3D bdrv_read(bs->file, s->snapshots[i].l1_table_offset / BDRV_SECTOR_SIZE, --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542555134682.6040229977523; Tue, 13 Feb 2018 09:22:35 -0800 (PST) Received: from localhost ([::1]:56047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleHq-0008ST-7j for importer@patchew.org; Tue, 13 Feb 2018 12:22:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1a-0002lB-41 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1Z-0005Bv-30 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:46 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37808 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1W-00059d-E7; Tue, 13 Feb 2018 12:05:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13B724022909; Tue, 13 Feb 2018 17:05:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6422A10073CD; Tue, 13 Feb 2018 17:05:41 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:40 +0100 Message-Id: <20180213170529.10858-7-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 06/55] block: early check for blockers on drive-mirror X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this. Signed-off-by: Paolo Bonzini Reviewed-by: Fam Zheng Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blockdev.c b/blockdev.c index bdbdeae7e4..7423c5317b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3569,6 +3569,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) return; } =20 + /* Early check to avoid creating target */ + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { + return; + } + aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542998778431.5693358590788; Tue, 13 Feb 2018 09:29:58 -0800 (PST) Received: from localhost ([::1]:56200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleOz-0006Dj-Np for importer@patchew.org; Tue, 13 Feb 2018 12:29:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1g-0002r1-5l for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005G7-Uf for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37810 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1X-0005AI-BC; Tue, 13 Feb 2018 12:05:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2AA74022909; Tue, 13 Feb 2018 17:05:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F1E810073CD; Tue, 13 Feb 2018 17:05:42 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:41 +0100 Message-Id: <20180213170529.10858-8-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 07/55] iotests: Use virtio-blk in 155 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Only a few select machine types support floppy drives and there is actually nothing preventing us from using virtio here, so let's do it. Reported-by: Christian Borntraeger Signed-off-by: Max Reitz Tested-by: Christian Borntraeger Signed-off-by: Kevin Wolf --- tests/qemu-iotests/155 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 index fc9fa975be..42dae04c83 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -64,7 +64,7 @@ class BaseClass(iotests.QMPTestCase): 'file': {'driver': 'file', 'filename': source_img}} self.vm.add_blockdev(self.qmp_to_opts(blockdev)) - self.vm.add_device('floppy,id=3Dqdev0,drive=3Dsource') + self.vm.add_device('virtio-blk,id=3Dqdev0,drive=3Dsource') self.vm.launch() =20 self.assertIntactSourceBackingChain() @@ -173,21 +173,24 @@ class MirrorBaseClass(BaseClass): def testFull(self): self.runMirror('full') =20 - node =3D self.findBlockNode('target', 'qdev0') + node =3D self.findBlockNode('target', + '/machine/peripheral/qdev0/virtio-backen= d') self.assertCorrectBackingImage(node, None) self.assertIntactSourceBackingChain() =20 def testTop(self): self.runMirror('top') =20 - node =3D self.findBlockNode('target', 'qdev0') + node =3D self.findBlockNode('target', + '/machine/peripheral/qdev0/virtio-backen= d') self.assertCorrectBackingImage(node, back2_img) self.assertIntactSourceBackingChain() =20 def testNone(self): self.runMirror('none') =20 - node =3D self.findBlockNode('target', 'qdev0') + node =3D self.findBlockNode('target', + '/machine/peripheral/qdev0/virtio-backen= d') self.assertCorrectBackingImage(node, source_img) self.assertIntactSourceBackingChain() =20 @@ -239,7 +242,8 @@ class TestCommit(BaseClass): =20 self.vm.event_wait('BLOCK_JOB_COMPLETED') =20 - node =3D self.findBlockNode(None, 'qdev0') + node =3D self.findBlockNode(None, + '/machine/peripheral/qdev0/virtio-backen= d') self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename', back1_img) self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename', --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542403230140.93893591110816; Tue, 13 Feb 2018 09:20:03 -0800 (PST) Received: from localhost ([::1]:56011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleFL-0006OL-Ex for importer@patchew.org; Tue, 13 Feb 2018 12:19:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1d-0002oM-Us for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005Ft-JW for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50782 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1Y-0005BG-Av; Tue, 13 Feb 2018 12:05:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD294EAE91; Tue, 13 Feb 2018 17:05:43 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 399AC10075C2; Tue, 13 Feb 2018 17:05:43 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:42 +0100 Message-Id: <20180213170529.10858-9-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 08/55] qemu-io: fix EOF Ctrl-D handling in qemu-io readline code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" qemu-io puts the TTY into non-canonical mode, which means no EOF processing= is done and thus getchar() will never return the EOF constant. Instead we have= to query the TTY attributes to determine the configured EOF character (usually Ctrl-D / 0x4), and then explicitly check for that value. This fixes the regression that prevented Ctrl-D from triggering an exit of qemu-io that has existed since readline was first added in commit 0cf17e181798063c3824c8200ba46f25f54faa1a Author: Stefan Hajnoczi Date: Thu Nov 14 11:54:17 2013 +0100 qemu-io: use readline.c It also ensures that a newline is printed when exiting, to complete the line output by the "qemu-io> " prompt. Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- qemu-io.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/qemu-io.c b/qemu-io.c index f554ab614b..2c00ea068e 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -11,6 +11,9 @@ #include "qemu/osdep.h" #include #include +#ifndef _WIN32 +#include +#endif =20 #include "qapi/error.h" #include "qemu-io.h" @@ -42,6 +45,26 @@ static bool imageOpts; =20 static ReadLineState *readline_state; =20 +static int ttyEOF; + +static int get_eof_char(void) +{ +#ifdef _WIN32 + return 0x4; /* Ctrl-D */ +#else + struct termios tty; + if (tcgetattr(STDIN_FILENO, &tty) !=3D 0) { + if (errno =3D=3D ENOTTY) { + return 0x0; /* just expect read() =3D=3D 0 */ + } else { + return 0x4; /* Ctrl-D */ + } + } + + return tty.c_cc[VEOF]; +#endif +} + static int close_f(BlockBackend *blk, int argc, char **argv) { blk_unref(qemuio_blk); @@ -323,7 +346,8 @@ static char *fetchline_readline(void) readline_start(readline_state, get_prompt(), 0, readline_func, &line); while (!line) { int ch =3D getchar(); - if (ch =3D=3D EOF) { + if (ttyEOF !=3D 0x0 && ch =3D=3D ttyEOF) { + printf("\n"); break; } readline_handle_byte(readline_state, ch); @@ -593,6 +617,7 @@ int main(int argc, char **argv) qemuio_add_command(&close_cmd); =20 if (isatty(STDIN_FILENO)) { + ttyEOF =3D get_eof_char(); readline_state =3D readline_init(readline_printf_func, readline_flush_func, NULL, --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542783940499.7461954514192; Tue, 13 Feb 2018 09:26:23 -0800 (PST) Received: from localhost ([::1]:56175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleLW-00034q-H4 for importer@patchew.org; Tue, 13 Feb 2018 12:26:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1d-0002nV-B3 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005Ff-EP for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41052 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1Z-0005Bl-5e; Tue, 13 Feb 2018 12:05:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C851E80125D6; Tue, 13 Feb 2018 17:05:44 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2427E10073CD; Tue, 13 Feb 2018 17:05:44 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:43 +0100 Message-Id: <20180213170529.10858-10-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:44 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 09/55] gluster: Move glfs_close() to create's clean-up X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz glfs_close() is a classical clean-up operation, as can be seen by the fact that it is executed even if the truncation before it failed. Also, moving it to clean-up makes it more clear that if it fails, we do not want it to overwrite the current ret value if that signifies an error already. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/gluster.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index d8decc41ad..7fab2dfa12 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -970,7 +970,7 @@ static int qemu_gluster_create(const char *filename, { BlockdevOptionsGluster *gconf; struct glfs *glfs; - struct glfs_fd *fd; + struct glfs_fd *fd =3D NULL; int ret =3D 0; PreallocMode prealloc; int64_t total_size =3D 0; @@ -1054,10 +1054,12 @@ static int qemu_gluster_create(const char *filename, break; } =20 - if (glfs_close(fd) !=3D 0) { - ret =3D -errno; - } out: + if (fd) { + if (glfs_close(fd) !=3D 0 && ret =3D=3D 0) { + ret =3D -errno; + } + } qapi_free_BlockdevOptionsGluster(gconf); glfs_clear_preopened(glfs); return ret; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542612618717.2653940381861; Tue, 13 Feb 2018 09:23:32 -0800 (PST) Received: from localhost ([::1]:56048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleIl-0000eX-Ht for importer@patchew.org; Tue, 13 Feb 2018 12:23:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1d-0002oL-UT for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1c-0005G2-QQ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:49 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38406 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1a-0005Cj-3E; Tue, 13 Feb 2018 12:05:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1FBE407244E; Tue, 13 Feb 2018 17:05:45 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E7B710073CD; Tue, 13 Feb 2018 17:05:44 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:44 +0100 Message-Id: <20180213170529.10858-11-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:05:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:05:45 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 10/55] gluster: Pull truncation from qemu_gluster_create X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Pull out the truncation code from the qemu_cluster_create() function so we can later reuse it in qemu_gluster_truncate(). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/gluster.c | 74 +++++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 7fab2dfa12..8178541416 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -965,6 +965,45 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(= BlockDriverState *bs, } #endif =20 +static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset, + PreallocMode prealloc, Error **errp) +{ + switch (prealloc) { +#ifdef CONFIG_GLUSTERFS_FALLOCATE + case PREALLOC_MODE_FALLOC: + if (glfs_fallocate(fd, 0, 0, offset)) { + error_setg_errno(errp, errno, "Could not preallocate data"); + return -errno; + } + break; +#endif /* CONFIG_GLUSTERFS_FALLOCATE */ +#ifdef CONFIG_GLUSTERFS_ZEROFILL + case PREALLOC_MODE_FULL: + if (glfs_ftruncate(fd, offset)) { + error_setg_errno(errp, errno, "Could not resize file"); + return -errno; + } + if (glfs_zerofill(fd, 0, offset)) { + error_setg_errno(errp, errno, "Could not zerofill the new area= "); + return -errno; + } + break; +#endif /* CONFIG_GLUSTERFS_ZEROFILL */ + case PREALLOC_MODE_OFF: + if (glfs_ftruncate(fd, offset)) { + error_setg_errno(errp, errno, "Could not resize file"); + return -errno; + } + break; + default: + error_setg(errp, "Unsupported preallocation mode: %s", + PreallocMode_str(prealloc)); + return -EINVAL; + } + + return 0; +} + static int qemu_gluster_create(const char *filename, QemuOpts *opts, Error **errp) { @@ -1019,40 +1058,7 @@ static int qemu_gluster_create(const char *filename, goto out; } =20 - switch (prealloc) { -#ifdef CONFIG_GLUSTERFS_FALLOCATE - case PREALLOC_MODE_FALLOC: - if (glfs_fallocate(fd, 0, 0, total_size)) { - error_setg(errp, "Could not preallocate data for the new file"= ); - ret =3D -errno; - } - break; -#endif /* CONFIG_GLUSTERFS_FALLOCATE */ -#ifdef CONFIG_GLUSTERFS_ZEROFILL - case PREALLOC_MODE_FULL: - if (!glfs_ftruncate(fd, total_size)) { - if (glfs_zerofill(fd, 0, total_size)) { - error_setg(errp, "Could not zerofill the new file"); - ret =3D -errno; - } - } else { - error_setg(errp, "Could not resize file"); - ret =3D -errno; - } - break; -#endif /* CONFIG_GLUSTERFS_ZEROFILL */ - case PREALLOC_MODE_OFF: - if (glfs_ftruncate(fd, total_size) !=3D 0) { - ret =3D -errno; - error_setg(errp, "Could not resize file"); - } - break; - default: - ret =3D -EINVAL; - error_setg(errp, "Unsupported preallocation mode: %s", - PreallocMode_str(prealloc)); - break; - } + ret =3D qemu_gluster_do_truncate(fd, total_size, prealloc, errp); =20 out: if (fd) { --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542812415530.0528861425651; Tue, 13 Feb 2018 09:26:52 -0800 (PST) Received: from localhost ([::1]:56177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleLz-0003RK-FJ for importer@patchew.org; Tue, 13 Feb 2018 12:26:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1g-0002qy-4s for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1d-0005Gj-Hj for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41054 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1b-0005DZ-0m; Tue, 13 Feb 2018 12:05:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DC0581638F0; Tue, 13 Feb 2018 17:05:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED19C10073CD; Tue, 13 Feb 2018 17:05:45 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:45 +0100 Message-Id: <20180213170529.10858-12-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:46 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 11/55] gluster: Query current size in do_truncate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Instead of expecting the current size to be 0, query it and allocate only the area [current_size, offset) if preallocation is requested. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/gluster.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 8178541416..806b894bc8 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -968,10 +968,27 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes= (BlockDriverState *bs, static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset, PreallocMode prealloc, Error **errp) { + int64_t current_length; + + current_length =3D glfs_lseek(fd, 0, SEEK_END); + if (current_length < 0) { + error_setg_errno(errp, errno, "Failed to determine current size"); + return -errno; + } + + if (current_length > offset && prealloc !=3D PREALLOC_MODE_OFF) { + error_setg(errp, "Cannot use preallocation for shrinking files"); + return -ENOTSUP; + } + + if (current_length =3D=3D offset) { + return 0; + } + switch (prealloc) { #ifdef CONFIG_GLUSTERFS_FALLOCATE case PREALLOC_MODE_FALLOC: - if (glfs_fallocate(fd, 0, 0, offset)) { + if (glfs_fallocate(fd, 0, current_length, offset - current_length)= ) { error_setg_errno(errp, errno, "Could not preallocate data"); return -errno; } @@ -983,7 +1000,7 @@ static int qemu_gluster_do_truncate(struct glfs_fd *fd= , int64_t offset, error_setg_errno(errp, errno, "Could not resize file"); return -errno; } - if (glfs_zerofill(fd, 0, offset)) { + if (glfs_zerofill(fd, current_length, offset - current_length)) { error_setg_errno(errp, errno, "Could not zerofill the new area= "); return -errno; } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542742103294.3345533776712; Tue, 13 Feb 2018 09:25:42 -0800 (PST) Received: from localhost ([::1]:56169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleKr-0002UK-5j for importer@patchew.org; Tue, 13 Feb 2018 12:25:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1j-0002ya-Es for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1i-0005MX-LH for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50786 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1b-0005Ei-T5; Tue, 13 Feb 2018 12:05:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87B8DEAE91; Tue, 13 Feb 2018 17:05:47 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id D89D510073CD; Tue, 13 Feb 2018 17:05:46 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:46 +0100 Message-Id: <20180213170529.10858-13-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:05:47 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 12/55] gluster: Add preallocated truncation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz By using qemu_do_cluster_truncate() in qemu_cluster_truncate(), we now automatically have preallocated truncation. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/gluster.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 806b894bc8..3f17b7819d 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1122,23 +1122,8 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriv= erState *bs, static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset, PreallocMode prealloc, Error **errp) { - int ret; BDRVGlusterState *s =3D bs->opaque; - - if (prealloc !=3D PREALLOC_MODE_OFF) { - error_setg(errp, "Unsupported preallocation mode '%s'", - PreallocMode_str(prealloc)); - return -ENOTSUP; - } - - ret =3D glfs_ftruncate(s->fd, offset); - if (ret < 0) { - ret =3D -errno; - error_setg_errno(errp, -ret, "Failed to truncate file"); - return ret; - } - - return 0; + return qemu_gluster_do_truncate(s->fd, offset, prealloc, errp); } =20 static coroutine_fn int qemu_gluster_co_readv(BlockDriverState *bs, --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854229967548.81602195757614; Tue, 13 Feb 2018 09:18:19 -0800 (PST) Received: from localhost ([::1]:55991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleDi-00050M-N7 for importer@patchew.org; Tue, 13 Feb 2018 12:18:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1i-0002w8-Dd for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1h-0005KC-Es for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56602 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1c-0005Fr-Ur; Tue, 13 Feb 2018 12:05:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7260440FB648; Tue, 13 Feb 2018 17:05:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id C345610075C3; Tue, 13 Feb 2018 17:05:47 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:47 +0100 Message-Id: <20180213170529.10858-14-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:48 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 13/55] sheepdog: Make sd_prealloc() take a BDS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz We want to use this function in sd_truncate() later on, so taking a filename is not exactly ideal. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/sheepdog.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index af125a2c8d..cc1d37b3da 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1826,10 +1826,10 @@ static int do_sd_create(BDRVSheepdogState *s, uint3= 2_t *vdi_id, int snapshot, return 0; } =20 -static int sd_prealloc(const char *filename, Error **errp) +static int sd_prealloc(BlockDriverState *bs, Error **errp) { BlockBackend *blk =3D NULL; - BDRVSheepdogState *base =3D NULL; + BDRVSheepdogState *base =3D bs->opaque; unsigned long buf_size; uint32_t idx, max_idx; uint32_t object_size; @@ -1837,10 +1837,11 @@ static int sd_prealloc(const char *filename, Error = **errp) void *buf =3D NULL; int ret; =20 - blk =3D blk_new_open(filename, NULL, NULL, - BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp= ); - if (blk =3D=3D NULL) { - ret =3D -EIO; + blk =3D blk_new(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_R= ESIZE, + BLK_PERM_ALL); + + ret =3D blk_insert_bs(blk, bs, errp); + if (ret < 0) { goto out_with_err_set; } =20 @@ -1852,7 +1853,6 @@ static int sd_prealloc(const char *filename, Error **= errp) goto out; } =20 - base =3D blk_bs(blk)->opaque; object_size =3D (UINT32_C(1) << base->inode.block_size_shift); buf_size =3D MIN(object_size, SD_DATA_OBJ_SIZE); buf =3D g_malloc0(buf_size); @@ -2108,7 +2108,20 @@ static int sd_create(const char *filename, QemuOpts = *opts, } =20 if (prealloc) { - ret =3D sd_prealloc(filename, errp); + BlockDriverState *bs; + QDict *opts; + + opts =3D qdict_new(); + qdict_put_str(opts, "driver", "sheepdog"); + bs =3D bdrv_open(filename, NULL, opts, BDRV_O_PROTOCOL | BDRV_O_RD= WR, + errp); + if (!bs) { + goto out; + } + + ret =3D sd_prealloc(bs, errp); + + bdrv_unref(bs); } out: g_free(backing_file); --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543251477992.9704684829816; Tue, 13 Feb 2018 09:34:11 -0800 (PST) Received: from localhost ([::1]:56226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleT4-0001F9-IA for importer@patchew.org; Tue, 13 Feb 2018 12:34:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1i-0002wI-GY for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1h-0005KJ-G5 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37818 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1d-0005Gd-R0; Tue, 13 Feb 2018 12:05:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E423402291E; Tue, 13 Feb 2018 17:05:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADE2210073CD; Tue, 13 Feb 2018 17:05:48 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:48 +0100 Message-Id: <20180213170529.10858-15-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:05:49 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 14/55] sheepdog: Pass old and new size to sd_prealloc() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz sd_prealloc() will now preallocate the area [old_size, new_size). As before, it rounds to buf_size and may thus overshoot and preallocate areas that were not requested to be preallocated. For image creation, this is no change in behavior. For truncation, this is in accordance with the documentation for preallocated truncation. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/sheepdog.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index cc1d37b3da..d300fb69c0 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1826,14 +1826,14 @@ static int do_sd_create(BDRVSheepdogState *s, uint3= 2_t *vdi_id, int snapshot, return 0; } =20 -static int sd_prealloc(BlockDriverState *bs, Error **errp) +static int sd_prealloc(BlockDriverState *bs, int64_t old_size, int64_t new= _size, + Error **errp) { BlockBackend *blk =3D NULL; BDRVSheepdogState *base =3D bs->opaque; unsigned long buf_size; uint32_t idx, max_idx; uint32_t object_size; - int64_t vdi_size; void *buf =3D NULL; int ret; =20 @@ -1847,19 +1847,13 @@ static int sd_prealloc(BlockDriverState *bs, Error = **errp) =20 blk_set_allow_write_beyond_eof(blk, true); =20 - vdi_size =3D blk_getlength(blk); - if (vdi_size < 0) { - ret =3D vdi_size; - goto out; - } - object_size =3D (UINT32_C(1) << base->inode.block_size_shift); buf_size =3D MIN(object_size, SD_DATA_OBJ_SIZE); buf =3D g_malloc0(buf_size); =20 - max_idx =3D DIV_ROUND_UP(vdi_size, buf_size); + max_idx =3D DIV_ROUND_UP(new_size, buf_size); =20 - for (idx =3D 0; idx < max_idx; idx++) { + for (idx =3D old_size / buf_size; idx < max_idx; idx++) { /* * The created image can be a cloned image, so we need to read * a data from the source image. @@ -2119,7 +2113,7 @@ static int sd_create(const char *filename, QemuOpts *= opts, goto out; } =20 - ret =3D sd_prealloc(bs, errp); + ret =3D sd_prealloc(bs, 0, s->inode.vdi_size, errp); =20 bdrv_unref(bs); } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543028453858.4473321638224; Tue, 13 Feb 2018 09:30:28 -0800 (PST) Received: from localhost ([::1]:56203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elePT-0006q3-IS for importer@patchew.org; Tue, 13 Feb 2018 12:30:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1i-0002v9-2x for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1h-0005K1-8t for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51170 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1e-0005Hf-Ld; Tue, 13 Feb 2018 12:05:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4857A7D840; Tue, 13 Feb 2018 17:05:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9959F10073CC; Tue, 13 Feb 2018 17:05:49 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:49 +0100 Message-Id: <20180213170529.10858-16-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:50 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 15/55] sheepdog: Allow fully preallocated truncation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/sheepdog.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index d300fb69c0..ac02b10fe0 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2180,15 +2180,16 @@ static int sd_truncate(BlockDriverState *bs, int64_= t offset, int ret, fd; unsigned int datalen; uint64_t max_vdi_size; + int64_t old_size =3D s->inode.vdi_size; =20 - if (prealloc !=3D PREALLOC_MODE_OFF) { + if (prealloc !=3D PREALLOC_MODE_OFF && prealloc !=3D PREALLOC_MODE_FUL= L) { error_setg(errp, "Unsupported preallocation mode '%s'", PreallocMode_str(prealloc)); return -ENOTSUP; } =20 max_vdi_size =3D (UINT64_C(1) << s->inode.block_size_shift) * MAX_DATA= _OBJS; - if (offset < s->inode.vdi_size) { + if (offset < old_size) { error_setg(errp, "shrinking is not supported"); return -EINVAL; } else if (offset > max_vdi_size) { @@ -2211,9 +2212,17 @@ static int sd_truncate(BlockDriverState *bs, int64_t= offset, =20 if (ret < 0) { error_setg_errno(errp, -ret, "failed to update an inode"); + return ret; } =20 - return ret; + if (prealloc =3D=3D PREALLOC_MODE_FULL) { + ret =3D sd_prealloc(bs, old_size, offset, errp); + if (ret < 0) { + return ret; + } + } + + return 0; } =20 /* --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543661269593.1306304993415; Tue, 13 Feb 2018 09:41:01 -0800 (PST) Received: from localhost ([::1]:56281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleZg-0007A2-D1 for importer@patchew.org; Tue, 13 Feb 2018 12:41:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1u-0003A1-DD for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1p-0005Rv-Ig for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38408 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1f-0005IY-J7; Tue, 13 Feb 2018 12:05:51 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33CC1407244E; Tue, 13 Feb 2018 17:05:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83BA810073CC; Tue, 13 Feb 2018 17:05:50 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:50 +0100 Message-Id: <20180213170529.10858-17-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:05:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:05:51 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 16/55] block: maintain persistent disabled bitmaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy To maintain load/store disabled bitmap there is new approach: - deprecate @autoload flag of block-dirty-bitmap-add, make it ignored - store enabled bitmaps as "auto" to qcow2 - store disabled bitmaps without "auto" flag to qcow2 - on qcow2 open load "auto" bitmaps as enabled and others as disabled (except in_use bitmaps) Also, adjust iotests 165 and 176 appropriately. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-id: 20180202160752.143796-1-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- qapi/block-core.json | 6 +++--- block/qcow2.h | 2 +- include/block/dirty-bitmap.h | 1 - block/dirty-bitmap.c | 18 ------------------ block/qcow2-bitmap.c | 12 +++++++----- block/qcow2.c | 2 +- blockdev.c | 10 ++-------- qemu-doc.texi | 7 +++++++ tests/qemu-iotests/165 | 2 +- tests/qemu-iotests/176 | 2 +- 10 files changed, 23 insertions(+), 39 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 8046c2da23..2c107823fe 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1593,9 +1593,9 @@ # Qcow2 disks support persistent bitmaps. Default is false for # block-dirty-bitmap-add. (Since: 2.10) # -# @autoload: the bitmap will be automatically loaded when the image it is = stored -# in is opened. This flag may only be specified for persistent -# bitmaps. Default is false for block-dirty-bitmap-add. (Since:= 2.10) +# @autoload: ignored and deprecated since 2.12. +# Currently, all dirty tracking bitmaps are loaded from Qcow2 on +# open. # # Since: 2.4 ## diff --git a/block/qcow2.h b/block/qcow2.h index 46c8cf44ec..016e87c81a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -663,7 +663,7 @@ void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cac= he *c, void *table); int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *r= es, void **refcount_table, int64_t *refcount_table_size); -bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **er= rp); +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **er= rp); int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp); diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 3da8486ab1..e3f4bbf51d 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -66,7 +66,6 @@ void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *= bitmap, void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap); =20 void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value); -void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload= ); void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, bool persistent); =20 diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 7879d13ddb..909f0517f8 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -52,8 +52,6 @@ struct BdrvDirtyBitmap { Such operations must fail and both the = image and this bitmap must remain unchanged w= hile this flag is set. */ - bool autoload; /* For persistent bitmaps: bitmap must be - autoloaded on image opening */ bool persistent; /* bitmap must be saved to owner disk imag= e */ QLIST_ENTRY(BdrvDirtyBitmap) list; }; @@ -104,7 +102,6 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitma= p) g_free(bitmap->name); bitmap->name =3D NULL; bitmap->persistent =3D false; - bitmap->autoload =3D false; } =20 /* Called with BQL taken. */ @@ -261,8 +258,6 @@ BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriver= State *bs, bitmap->successor =3D NULL; successor->persistent =3D bitmap->persistent; bitmap->persistent =3D false; - successor->autoload =3D bitmap->autoload; - bitmap->autoload =3D false; bdrv_release_dirty_bitmap(bs, bitmap); =20 return successor; @@ -667,19 +662,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs) } =20 /* Called with BQL taken. */ -void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap *bitmap, bool autoload) -{ - qemu_mutex_lock(bitmap->mutex); - bitmap->autoload =3D autoload; - qemu_mutex_unlock(bitmap->mutex); -} - -bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap) -{ - return bitmap->autoload; -} - -/* Called with BQL taken. */ void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, bool persi= stent) { qemu_mutex_lock(bitmap->mutex); diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index efa10c6663..4f6fd863ea 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -933,14 +933,14 @@ static void set_readonly_helper(gpointer bitmap, gpoi= nter value) bdrv_dirty_bitmap_set_readonly(bitmap, (bool)value); } =20 -/* qcow2_load_autoloading_dirty_bitmaps() +/* qcow2_load_dirty_bitmaps() * Return value is a hint for caller: true means that the Qcow2 header was * updated. (false doesn't mean that the header should be updated by the * caller, it just means that updating was not needed or the image cannot = be * written to). * On failure the function returns false. */ -bool qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **er= rp) +bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp) { BDRVQcow2State *s =3D bs->opaque; Qcow2BitmapList *bm_list; @@ -960,14 +960,16 @@ bool qcow2_load_autoloading_dirty_bitmaps(BlockDriver= State *bs, Error **errp) } =20 QSIMPLEQ_FOREACH(bm, bm_list, entry) { - if ((bm->flags & BME_FLAG_AUTO) && !(bm->flags & BME_FLAG_IN_USE))= { + if (!(bm->flags & BME_FLAG_IN_USE)) { BdrvDirtyBitmap *bitmap =3D load_bitmap(bs, bm, errp); if (bitmap =3D=3D NULL) { goto fail; } =20 + if (!(bm->flags & BME_FLAG_AUTO)) { + bdrv_disable_dirty_bitmap(bitmap); + } bdrv_dirty_bitmap_set_persistance(bitmap, true); - bdrv_dirty_bitmap_set_autoload(bitmap, true); bm->flags |=3D BME_FLAG_IN_USE; created_dirty_bitmaps =3D g_slist_append(created_dirty_bitmaps, bitmap); @@ -1369,7 +1371,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriver= State *bs, Error **errp) bm->table.size =3D 0; QSIMPLEQ_INSERT_TAIL(&drop_tables, tb, entry); } - bm->flags =3D bdrv_dirty_bitmap_get_autoload(bitmap) ? BME_FLAG_AU= TO : 0; + bm->flags =3D bdrv_dirty_bitmap_enabled(bitmap) ? BME_FLAG_AUTO : = 0; bm->granularity_bits =3D ctz32(bdrv_dirty_bitmap_granularity(bitma= p)); bm->dirty_bitmap =3D bitmap; } diff --git a/block/qcow2.c b/block/qcow2.c index 801e29fc56..80774aacf6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1460,7 +1460,7 @@ static int qcow2_do_open(BlockDriverState *bs, QDict = *options, int flags, s->autoclear_features &=3D QCOW2_AUTOCLEAR_MASK; } =20 - if (qcow2_load_autoloading_dirty_bitmaps(bs, &local_err)) { + if (qcow2_load_dirty_bitmaps(bs, &local_err)) { update_header =3D false; } if (local_err !=3D NULL) { diff --git a/blockdev.c b/blockdev.c index 7423c5317b..3fb1ca803c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2825,14 +2825,9 @@ void qmp_block_dirty_bitmap_add(const char *node, co= nst char *name, if (!has_persistent) { persistent =3D false; } - if (!has_autoload) { - autoload =3D false; - } =20 - if (has_autoload && !persistent) { - error_setg(errp, "Autoload flag must be used only for persistent " - "bitmaps"); - return; + if (has_autoload) { + warn_report("Autoload option is deprecated and its value is ignore= d"); } =20 if (persistent && @@ -2847,7 +2842,6 @@ void qmp_block_dirty_bitmap_add(const char *node, con= st char *name, } =20 bdrv_dirty_bitmap_set_persistance(bitmap, persistent); - bdrv_dirty_bitmap_set_autoload(bitmap, autoload); } =20 void qmp_block_dirty_bitmap_remove(const char *node, const char *name, diff --git a/qemu-doc.texi b/qemu-doc.texi index 769968aba4..137f5814a8 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2757,6 +2757,13 @@ used and it will be removed with no replacement. The ``convert -s snapshot_id_or_name'' argument is obsoleted by the ``convert -l snapshot_param'' argument instead. =20 +@section QEMU Machine Protocol (QMP) commands + +@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) + +"autoload" parameter is now ignored. All bitmaps are automatically loaded +from qcow2 images. + @section System emulator human monitor commands =20 @subsection host_net_add (since 2.10.0) diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index a3932db3de..2936929627 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -64,7 +64,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): =20 def qmpAddBitmap(self): self.vm.qmp('block-dirty-bitmap-add', node=3D'drive0', - name=3D'bitmap0', persistent=3DTrue, autoload=3DTrue) + name=3D'bitmap0', persistent=3DTrue) =20 def test_persistent(self): self.vm =3D self.mkVm() diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 index d38b3aeb91..32baa116dd 100755 --- a/tests/qemu-iotests/176 +++ b/tests/qemu-iotests/176 @@ -95,7 +95,7 @@ case $reason in "file": { "driver": "file", "filename": "$TEST_IMG" } } } { "execute": "block-dirty-bitmap-add", "arguments": { "node": "drive0", "name": "bitmap0", - "persistent": true, "autoload": true } } + "persistent": true } } { "execute": "quit" } EOF ;; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518542515545873.7936657485498; Tue, 13 Feb 2018 09:21:55 -0800 (PST) Received: from localhost ([::1]:56045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleH7-0007sh-HY for importer@patchew.org; Tue, 13 Feb 2018 12:21:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1j-0002yO-9b for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1i-0005M1-Dw for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51172 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1g-0005JL-HC; Tue, 13 Feb 2018 12:05:52 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EAAF7CBB2; Tue, 13 Feb 2018 17:05:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F23110073CC; Tue, 13 Feb 2018 17:05:51 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:51 +0100 Message-Id: <20180213170529.10858-18-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:52 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 17/55] qcow2: Fix documentation of get_cluster_table() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function has not been returning the offset of the L2 table since commit 3948d1d4876065160583e79533bf604481063833 Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: b498733b6706a859a03678d74ecbd26aeba129aa.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f077cd3ac5..e5ab102c29 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -647,8 +647,7 @@ fail: * for a given disk offset, load (and allocate if needed) * the l2 table. * - * the l2 table offset in the qcow2 file and the cluster index - * in the l2 table are given to the caller. + * the cluster index in the l2 table is given to the caller. * * Returns 0 on success, -errno in failure case */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854293334040.386192667383625; Tue, 13 Feb 2018 09:28:53 -0800 (PST) Received: from localhost ([::1]:56198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleNw-0005Bi-6Z for importer@patchew.org; Tue, 13 Feb 2018 12:28:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1l-00031B-VQ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1k-0005OK-MS for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:57 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51176 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1h-0005Jx-Dn; Tue, 13 Feb 2018 12:05:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A7697D845; Tue, 13 Feb 2018 17:05:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A1E210073CC; Tue, 13 Feb 2018 17:05:52 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:52 +0100 Message-Id: <20180213170529.10858-19-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:53 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 18/55] qcow2: Add table size field to Qcow2Cache X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The table size in the qcow2 cache is currently equal to the cluster size. This doesn't allow us to use the cache memory efficiently, particularly with large cluster sizes, so we need to be able to have smaller cache tables that are independent from the cluster size. This patch adds a new field to Qcow2Cache that we can use instead of the cluster size. The current table size is still being initialized to the cluster size, so there are no semantic changes yet, but this patch will allow us to prepare the rest of the code and simplify a few function calls. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 67a1bf9e55f417005c567bead95a018dc34bc687.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index c48ffebd8f..38c03770b4 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -39,6 +39,7 @@ struct Qcow2Cache { Qcow2CachedTable *entries; struct Qcow2Cache *depends; int size; + int table_size; bool depends_on_flush; void *table_array; uint64_t lru_counter; @@ -48,17 +49,15 @@ struct Qcow2Cache { static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, Qcow2Cache *c, int table) { - BDRVQcow2State *s =3D bs->opaque; - return (uint8_t *) c->table_array + (size_t) table * s->cluster_size; + return (uint8_t *) c->table_array + (size_t) table * c->table_size; } =20 static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, Qcow2Cache *c, void *table) { - BDRVQcow2State *s =3D bs->opaque; ptrdiff_t table_offset =3D (uint8_t *) table - (uint8_t *) c->table_ar= ray; - int idx =3D table_offset / s->cluster_size; - assert(idx >=3D 0 && idx < c->size && table_offset % s->cluster_size = =3D=3D 0); + int idx =3D table_offset / c->table_size; + assert(idx >=3D 0 && idx < c->size && table_offset % c->table_size =3D= =3D 0); return idx; } =20 @@ -79,10 +78,9 @@ static void qcow2_cache_table_release(BlockDriverState *= bs, Qcow2Cache *c, { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX - BDRVQcow2State *s =3D bs->opaque; void *t =3D qcow2_cache_get_table_addr(bs, c, i); int align =3D getpagesize(); - size_t mem_size =3D (size_t) s->cluster_size * num_tables; + size_t mem_size =3D (size_t) c->table_size * num_tables; size_t offset =3D QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; size_t length =3D QEMU_ALIGN_DOWN(mem_size - offset, align); if (mem_size > offset && length > 0) { @@ -132,9 +130,10 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, i= nt num_tables) =20 c =3D g_new0(Qcow2Cache, 1); c->size =3D num_tables; + c->table_size =3D s->cluster_size; c->entries =3D g_try_new0(Qcow2CachedTable, num_tables); c->table_array =3D qemu_try_blockalign(bs->file->bs, - (size_t) num_tables * s->cluster_= size); + (size_t) num_tables * c->table_si= ze); =20 if (!c->entries || !c->table_array) { qemu_vfree(c->table_array); @@ -203,13 +202,13 @@ static int qcow2_cache_entry_flush(BlockDriverState *= bs, Qcow2Cache *c, int i) =20 if (c =3D=3D s->refcount_block_cache) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_BLOCK, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } else if (c =3D=3D s->l2_table_cache) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } else { ret =3D qcow2_pre_write_overlap_check(bs, 0, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } =20 if (ret < 0) { @@ -223,7 +222,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) } =20 ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(bs, c, i), s->cluster_siz= e); + qcow2_cache_get_table_addr(bs, c, i), c->table_size); if (ret < 0) { return ret; } @@ -331,7 +330,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, trace_qcow2_cache_get(qemu_coroutine_self(), c =3D=3D s->l2_table_cach= e, offset, read_from_disk); =20 - if (offset_into_cluster(s, offset)) { + if (!QEMU_IS_ALIGNED(offset, c->table_size)) { qcow2_signal_corruption(bs, true, -1, -1, "Cannot get entry from %= s " "cache: Offset %#" PRIx64 " is unaligned", qcow2_cache_get_name(s, c), offset); @@ -339,7 +338,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, } =20 /* Check if the table is already cached */ - i =3D lookup_index =3D (offset / s->cluster_size * 4) % c->size; + i =3D lookup_index =3D (offset / c->table_size * 4) % c->size; do { const Qcow2CachedTable *t =3D &c->entries[i]; if (t->offset =3D=3D offset) { @@ -380,7 +379,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, =20 ret =3D bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(bs, c, i), - s->cluster_size); + c->table_size); if (ret < 0) { return ret; } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543010861496.93320931121616; Tue, 13 Feb 2018 09:30:10 -0800 (PST) Received: from localhost ([::1]:56201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elePC-0006Wf-1R for importer@patchew.org; Tue, 13 Feb 2018 12:30:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1p-00032E-4l for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1k-0005Od-W1 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:00 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51178 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1i-0005L1-Ai; Tue, 13 Feb 2018 12:05:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E890B7D840; Tue, 13 Feb 2018 17:05:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 455A310075C2; Tue, 13 Feb 2018 17:05:53 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:53 +0100 Message-Id: <20180213170529.10858-20-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:53 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 19/55] qcow2: Remove BDS parameter from qcow2_cache_get_table_addr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: e1f943a9e89e1deb876f45de1bb22419ccdb6ad3.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 38c03770b4..a481ef499a 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -46,8 +46,7 @@ struct Qcow2Cache { uint64_t cache_clean_lru_counter; }; =20 -static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, - Qcow2Cache *c, int table) +static inline void *qcow2_cache_get_table_addr(Qcow2Cache *c, int table) { return (uint8_t *) c->table_array + (size_t) table * c->table_size; } @@ -78,7 +77,7 @@ static void qcow2_cache_table_release(BlockDriverState *b= s, Qcow2Cache *c, { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX - void *t =3D qcow2_cache_get_table_addr(bs, c, i); + void *t =3D qcow2_cache_get_table_addr(c, i); int align =3D getpagesize(); size_t mem_size =3D (size_t) c->table_size * num_tables; size_t offset =3D QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; @@ -222,7 +221,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) } =20 ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(bs, c, i), c->table_size); + qcow2_cache_get_table_addr(c, i), c->table_size); if (ret < 0) { return ret; } @@ -378,7 +377,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, } =20 ret =3D bdrv_pread(bs->file, offset, - qcow2_cache_get_table_addr(bs, c, i), + qcow2_cache_get_table_addr(c, i), c->table_size); if (ret < 0) { return ret; @@ -390,7 +389,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, /* And return the right table */ found: c->entries[i].ref++; - *table =3D qcow2_cache_get_table_addr(bs, c, i); + *table =3D qcow2_cache_get_table_addr(c, i); =20 trace_qcow2_cache_get_done(qemu_coroutine_self(), c =3D=3D s->l2_table_cache, i); @@ -439,7 +438,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, =20 for (i =3D 0; i < c->size; i++) { if (c->entries[i].offset =3D=3D offset) { - return qcow2_cache_get_table_addr(bs, c, i); + return qcow2_cache_get_table_addr(c, i); } } return NULL; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543460737361.18546959484536; Tue, 13 Feb 2018 09:37:40 -0800 (PST) Received: from localhost ([::1]:56250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleWJ-00043T-LR for importer@patchew.org; Tue, 13 Feb 2018 12:37:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1m-000323-LC for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1l-0005P2-FB for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:05:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51180 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1j-0005Mf-6j; Tue, 13 Feb 2018 12:05:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D31D07D840; Tue, 13 Feb 2018 17:05:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F47210073CD; Tue, 13 Feb 2018 17:05:54 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:54 +0100 Message-Id: <20180213170529.10858-21-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 20/55] qcow2: Remove BDS parameter from qcow2_cache_get_table_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: da3575d47c9a181a2cfd4715e53dd84a2c651017.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index a481ef499a..3749d55595 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -51,8 +51,7 @@ static inline void *qcow2_cache_get_table_addr(Qcow2Cache= *c, int table) return (uint8_t *) c->table_array + (size_t) table * c->table_size; } =20 -static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, - Qcow2Cache *c, void *table) +static inline int qcow2_cache_get_table_idx(Qcow2Cache *c, void *table) { ptrdiff_t table_offset =3D (uint8_t *) table - (uint8_t *) c->table_ar= ray; int idx =3D table_offset / c->table_size; @@ -411,7 +410,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, =20 void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { - int i =3D qcow2_cache_get_table_idx(bs, c, *table); + int i =3D qcow2_cache_get_table_idx(c, *table); =20 c->entries[i].ref--; *table =3D NULL; @@ -426,7 +425,7 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *= c, void **table) void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, void *table) { - int i =3D qcow2_cache_get_table_idx(bs, c, table); + int i =3D qcow2_cache_get_table_idx(c, table); assert(c->entries[i].offset !=3D 0); c->entries[i].dirty =3D true; } @@ -446,7 +445,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, =20 void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table) { - int i =3D qcow2_cache_get_table_idx(bs, c, table); + int i =3D qcow2_cache_get_table_idx(c, table); =20 assert(c->entries[i].ref =3D=3D 0); =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543174824465.26135258397255; Tue, 13 Feb 2018 09:32:54 -0800 (PST) Received: from localhost ([::1]:56224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleRj-0000J9-3b for importer@patchew.org; Tue, 13 Feb 2018 12:32:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1p-00032H-6i for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1m-0005Pf-BP for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:01 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51182 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1k-0005Nr-41; Tue, 13 Feb 2018 12:05:56 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE3A67D840; Tue, 13 Feb 2018 17:05:55 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AD0D10073CD; Tue, 13 Feb 2018 17:05:54 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:55 +0100 Message-Id: <20180213170529.10858-22-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:55 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 21/55] qcow2: Remove BDS parameter from qcow2_cache_table_release() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 7c1b262344375d52544525f85bbbf0548d5ba575.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 3749d55595..5ff2cbf5c5 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -71,8 +71,7 @@ static inline const char *qcow2_cache_get_name(BDRVQcow2S= tate *s, Qcow2Cache *c) } } =20 -static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, - int i, int num_tables) +static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables) { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX @@ -114,7 +113,7 @@ void qcow2_cache_clean_unused(BlockDriverState *bs, Qco= w2Cache *c) } =20 if (to_clean > 0) { - qcow2_cache_table_release(bs, c, i - to_clean, to_clean); + qcow2_cache_table_release(c, i - to_clean, to_clean); } } =20 @@ -306,7 +305,7 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache = *c) c->entries[i].lru_counter =3D 0; } =20 - qcow2_cache_table_release(bs, c, 0, c->size); + qcow2_cache_table_release(c, 0, c->size); =20 c->lru_counter =3D 0; =20 @@ -453,5 +452,5 @@ void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cac= he *c, void *table) c->entries[i].lru_counter =3D 0; c->entries[i].dirty =3D false; =20 - qcow2_cache_table_release(bs, c, i, 1); + qcow2_cache_table_release(c, i, 1); } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543278599862.8772602646532; Tue, 13 Feb 2018 09:34:38 -0800 (PST) Received: from localhost ([::1]:56228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleTV-0001aA-NU for importer@patchew.org; Tue, 13 Feb 2018 12:34:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1r-00035f-65 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1p-0005S9-Q0 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:03 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51184 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1l-0005OQ-1X; Tue, 13 Feb 2018 12:05:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A85517D840; Tue, 13 Feb 2018 17:05:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04FCD10073CD; Tue, 13 Feb 2018 17:05:55 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:56 +0100 Message-Id: <20180213170529.10858-23-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:05:56 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 22/55] qcow2: Remove BDS parameter from qcow2_cache_entry_mark_dirty() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 5c40516a91782b083c1428b7b6a41bb9e2679bfb.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 3 +-- block/qcow2-cache.c | 3 +-- block/qcow2-cluster.c | 12 ++++++------ block/qcow2-refcount.c | 14 ++++++-------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 016e87c81a..73e0e0133d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -639,8 +639,7 @@ int qcow2_read_snapshots(BlockDriverState *bs); Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); =20 -void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, - void *table); +void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_write(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 5ff2cbf5c5..07603e6b15 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -421,8 +421,7 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *= c, void **table) assert(c->entries[i].ref >=3D 0); } =20 -void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, - void *table) +void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table) { int i =3D qcow2_cache_get_table_idx(c, table); assert(c->entries[i].offset !=3D 0); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e5ab102c29..08af5c5995 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -324,7 +324,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); ret =3D qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; @@ -765,7 +765,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, /* compressed clusters never have the copied flag */ =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index] =3D cpu_to_be64(cluster_offset); qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); =20 @@ -937,7 +937,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) if (ret < 0) { goto err; } - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); =20 assert(l2_index + m->nb_clusters <=3D s->l2_size); for (i =3D 0; i < m->nb_clusters; i++) { @@ -1678,7 +1678,7 @@ static int discard_single_l2(BlockDriverState *bs, ui= nt64_t offset, } =20 /* First remove L2 entries */ - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); if (!full_discard && s->qcow_version >=3D 3) { l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); } else { @@ -1774,7 +1774,7 @@ static int zero_single_l2(BlockDriverState *bs, uint6= 4_t offset, continue; } =20 - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); @@ -1983,7 +1983,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, =20 if (is_active_l1) { if (l2_dirty) { - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_tab= le); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 92701ab7af..5434e7d4c8 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -421,7 +421,7 @@ static int alloc_refcount_block(BlockDriverState *bs, =20 /* Now the new refcount block needs to be written to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_bl= ock); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block); ret =3D qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; @@ -623,7 +623,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, goto fail; } memset(refblock_data, 0, s->cluster_size); - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock_data); =20 new_table[i] =3D block_offset; @@ -656,7 +656,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, s->set_refcount(refblock_data, j, 1); } =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock_data); } =20 @@ -845,8 +845,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, } old_table_index =3D table_index; =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, - refcount_block); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_blo= ck); =20 /* we can update the count and save it */ block_index =3D cluster_index & (s->refcount_block_size - 1); @@ -1316,8 +1315,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, s->refcount_block_cache); } l2_table[j] =3D cpu_to_be64(entry); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, - l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); } } =20 @@ -3180,7 +3178,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, } s->set_refcount(refblock, block_index, 0); =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, refblock); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock); =20 qcow2_cache_put(bs, s->refcount_block_cache, &refblock); =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543468217693.5176415572405; Tue, 13 Feb 2018 09:37:48 -0800 (PST) Received: from localhost ([::1]:56254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleWZ-0004K0-AL for importer@patchew.org; Tue, 13 Feb 2018 12:37:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1u-0003A2-Dl for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1r-0005TH-7a for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56606 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1l-0005PC-V1; Tue, 13 Feb 2018 12:05:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92CB240FB64A; Tue, 13 Feb 2018 17:05:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E371C10075C2; Tue, 13 Feb 2018 17:05:56 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:57 +0100 Message-Id: <20180213170529.10858-24-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:57 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 23/55] qcow2: Remove BDS parameter from qcow2_cache_put() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 6f98155489054a457563da77cdad1a66ebb3e896.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 2 +- block/qcow2-cache.c | 2 +- block/qcow2-cluster.c | 28 ++++++++++++++-------------- block/qcow2-refcount.c | 30 +++++++++++++++--------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 73e0e0133d..606dcdd47f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -653,7 +653,7 @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c= , uint64_t offset, void **table); int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t of= fset, void **table); -void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table); +void qcow2_cache_put(Qcow2Cache *c, void **table); void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset); void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table); diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 07603e6b15..3b55f39afb 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -407,7 +407,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, return qcow2_cache_do_get(bs, c, offset, table, false); } =20 -void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) +void qcow2_cache_put(Qcow2Cache *c, void **table) { int i =3D qcow2_cache_get_table_idx(c, *table); =20 diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 08af5c5995..ab5715c97e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -317,7 +317,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) =20 memcpy(l2_table, old_table, s->cluster_size); =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &old_table); + qcow2_cache_put(s->l2_table_cache, (void **) &old_table); } =20 /* write the l2 table to the file */ @@ -345,7 +345,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); if (l2_table !=3D NULL) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) table); + qcow2_cache_put(s->l2_table_cache, (void **) table); } s->l1_table[l1_index] =3D old_l2_offset; if (l2_offset > 0) { @@ -619,7 +619,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, abort(); } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 bytes_available =3D (int64_t)c * s->cluster_size; =20 @@ -637,7 +637,7 @@ out: return type; =20 fail: - qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); + qcow2_cache_put(s->l2_table_cache, (void **)&l2_table); return ret; } =20 @@ -744,13 +744,13 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockD= riverState *bs, * allocated. */ cluster_offset =3D be64_to_cpu(l2_table[l2_index]); if (cluster_offset & L2E_OFFSET_MASK) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); return 0; } =20 cluster_offset =3D qcow2_alloc_bytes(bs, compressed_size); if (cluster_offset < 0) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); return 0; } =20 @@ -767,7 +767,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index] =3D cpu_to_be64(cluster_offset); - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return cluster_offset; } @@ -956,7 +956,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) } =20 =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 /* * If this was a COW, we need to decrease the refcount of the old clus= ter. @@ -1174,7 +1174,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, =20 /* Cleanup */ out: - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 /* Only return a host offset if we actually made progress. Otherwise we * would make requirements for handle_alloc() that it can't fulfill */ @@ -1333,7 +1333,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, keep_old_clusters =3D true; } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 if (!alloc_cluster_offset) { /* Allocate, if necessary at a given offset in the image file */ @@ -1689,7 +1689,7 @@ static int discard_single_l2(BlockDriverState *bs, ui= nt64_t offset, qcow2_free_any_clusters(bs, old_l2_entry, 1, type); } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return nb_clusters; } @@ -1783,7 +1783,7 @@ static int zero_single_l2(BlockDriverState *bs, uint6= 4_t offset, } } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return nb_clusters; } @@ -1986,7 +1986,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } else { if (l2_dirty) { ret =3D qcow2_pre_write_overlap_check(bs, @@ -2017,7 +2017,7 @@ fail: if (!is_active_l1) { qemu_vfree(l2_table); } else { - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } } return ret; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 5434e7d4c8..65af05dd23 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -277,7 +277,7 @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cl= uster_index, block_index =3D cluster_index & (s->refcount_block_size - 1); *refcount =3D s->get_refcount(refcount_block, block_index); =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); =20 return 0; } @@ -449,7 +449,7 @@ static int alloc_refcount_block(BlockDriverState *bs, return -EAGAIN; } =20 - qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); + qcow2_cache_put(s->refcount_block_cache, refcount_block); =20 /* * If we come here, we need to grow the refcount table. Again, a new @@ -501,7 +501,7 @@ static int alloc_refcount_block(BlockDriverState *bs, =20 fail: if (*refcount_block !=3D NULL) { - qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); + qcow2_cache_put(s->refcount_block_cache, refcount_block); } return ret; } @@ -660,7 +660,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, refblock_data); } =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock_data); + qcow2_cache_put(s->refcount_block_cache, &refblock_data); } =20 assert(block_offset =3D=3D table_offset); @@ -836,7 +836,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, /* Load the refcount block and allocate it if needed */ if (table_index !=3D old_table_index) { if (refcount_block) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_blo= ck); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); } ret =3D alloc_refcount_block(bs, cluster_index, &refcount_bloc= k); if (ret < 0) { @@ -874,7 +874,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, table =3D qcow2_cache_is_table_offset(bs, s->refcount_block_ca= che, offset); if (table !=3D NULL) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_blo= ck); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); qcow2_cache_discard(bs, s->refcount_block_cache, table); } =20 @@ -897,7 +897,7 @@ fail: =20 /* Write last changed block to disk */ if (refcount_block) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); } =20 /* @@ -1319,7 +1319,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, } } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 if (addend !=3D 0) { ret =3D qcow2_update_cluster_refcount(bs, l2_offset >> @@ -1347,7 +1347,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, ret =3D bdrv_flush(bs); fail: if (l2_table) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } =20 s->cache_discards =3D false; @@ -2847,7 +2847,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, new_reftable_size, new_refblock, new_refblock_empty, allocated, errp); if (ret < 0) { - qcow2_cache_put(bs, s->refcount_block_cache, &refb= lock); + qcow2_cache_put(s->refcount_block_cache, &refblock= ); return ret; } =20 @@ -2860,7 +2860,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, if (new_refcount_bits < 64 && refcount >> new_refcount_bit= s) { uint64_t offset; =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock= ); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 offset =3D ((reftable_index << s->refcount_block_bits) + refblock_index) << s->cluster_bits; @@ -2881,7 +2881,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, new_refblock_empty =3D new_refblock_empty && refcount =3D= =3D 0; } =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); } else { /* No refblock means every refcount is 0 */ for (refblock_index =3D 0; refblock_index < s->refcount_block_= size; @@ -3173,14 +3173,14 @@ static int qcow2_discard_refcount_block(BlockDriver= State *bs, offset_to_reftable_index(s, discard_block_= offs), discard_block_offs, s->get_refcount(refblock, block_index)); - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); return -EINVAL; } s->set_refcount(refblock, block_index, 0); =20 qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock); =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 if (cluster_index < s->free_cluster_index) { s->free_cluster_index =3D cluster_index; @@ -3233,7 +3233,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) } else { unused_block =3D buffer_is_zero(refblock, s->cluster_size); } - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 reftable_tmp[i] =3D unused_block ? 0 : cpu_to_be64(s->refcount_tab= le[i]); } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854389809521.18938310427791; Tue, 13 Feb 2018 09:44:58 -0800 (PST) Received: from localhost ([::1]:56309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eledV-0002Hq-8l for importer@patchew.org; Tue, 13 Feb 2018 12:44:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1y-0003DM-ED for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1v-0005Wy-JU for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:10 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41058 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1m-0005Pr-Qn; Tue, 13 Feb 2018 12:05:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CABD80125D6; Tue, 13 Feb 2018 17:05:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD8CF10073CD; Tue, 13 Feb 2018 17:05:57 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:58 +0100 Message-Id: <20180213170529.10858-25-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:05:58 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 24/55] qcow2: Remove BDS parameter from qcow2_cache_destroy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was never using the BlockDriverState parameter so it can be safely removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 49c74fe8b3aead9056e61a85b145ce787d06262b.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 2 +- block/qcow2-cache.c | 2 +- block/qcow2.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 606dcdd47f..9936cd0700 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -637,7 +637,7 @@ int qcow2_read_snapshots(BlockDriverState *bs); =20 /* qcow2-cache.c functions */ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); -int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); +int qcow2_cache_destroy(Qcow2Cache *c); =20 void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 3b55f39afb..6f17a28635 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -142,7 +142,7 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, in= t num_tables) return c; } =20 -int qcow2_cache_destroy(BlockDriverState *bs, Qcow2Cache *c) +int qcow2_cache_destroy(Qcow2Cache *c) { int i; =20 diff --git a/block/qcow2.c b/block/qcow2.c index 80774aacf6..38e7fdc4b0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1044,10 +1044,10 @@ static void qcow2_update_options_commit(BlockDriver= State *bs, int i; =20 if (s->l2_table_cache) { - qcow2_cache_destroy(bs, s->l2_table_cache); + qcow2_cache_destroy(s->l2_table_cache); } if (s->refcount_block_cache) { - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->refcount_block_cache); } s->l2_table_cache =3D r->l2_table_cache; s->refcount_block_cache =3D r->refcount_block_cache; @@ -1073,10 +1073,10 @@ static void qcow2_update_options_abort(BlockDriverS= tate *bs, Qcow2ReopenState *r) { if (r->l2_table_cache) { - qcow2_cache_destroy(bs, r->l2_table_cache); + qcow2_cache_destroy(r->l2_table_cache); } if (r->refcount_block_cache) { - qcow2_cache_destroy(bs, r->refcount_block_cache); + qcow2_cache_destroy(r->refcount_block_cache); } qapi_free_QCryptoBlockOpenOptions(r->crypto_opts); } @@ -1514,10 +1514,10 @@ static int qcow2_do_open(BlockDriverState *bs, QDic= t *options, int flags, s->l1_table =3D NULL; cache_clean_timer_del(bs); if (s->l2_table_cache) { - qcow2_cache_destroy(bs, s->l2_table_cache); + qcow2_cache_destroy(s->l2_table_cache); } if (s->refcount_block_cache) { - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->refcount_block_cache); } qcrypto_block_free(s->crypto); qapi_free_QCryptoBlockOpenOptions(s->crypto_opts); @@ -2065,8 +2065,8 @@ static void qcow2_close(BlockDriverState *bs) } =20 cache_clean_timer_del(bs); - qcow2_cache_destroy(bs, s->l2_table_cache); - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->l2_table_cache); + qcow2_cache_destroy(s->refcount_block_cache); =20 qcrypto_block_free(s->crypto); s->crypto =3D NULL; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543236011121.59740886941415; Tue, 13 Feb 2018 09:33:56 -0800 (PST) Received: from localhost ([::1]:56225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleSo-00012f-TA for importer@patchew.org; Tue, 13 Feb 2018 12:33:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1r-00036R-LO for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1q-0005Sr-LM for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:03 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56608 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1n-0005QS-Ow; Tue, 13 Feb 2018 12:05:59 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66A0B40FB645; Tue, 13 Feb 2018 17:05:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id B79C010073CD; Tue, 13 Feb 2018 17:05:58 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:04:59 +0100 Message-Id: <20180213170529.10858-26-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:05:59 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 25/55] qcow2: Remove BDS parameter from qcow2_cache_clean_unused() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to pass it to qcow2_cache_table_release(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: b74f17591af52f201de0ea3a3b2dd0a81932334d.1517840876.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 2 +- block/qcow2-cache.c | 2 +- block/qcow2.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 9936cd0700..867f2e8828 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -646,7 +646,7 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qc= ow2Cache *c, Qcow2Cache *dependency); void qcow2_cache_depends_on_flush(Qcow2Cache *c); =20 -void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c); +void qcow2_cache_clean_unused(Qcow2Cache *c); int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c); =20 int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 6f17a28635..03b3e03c6c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -93,7 +93,7 @@ static inline bool can_clean_entry(Qcow2Cache *c, int i) t->lru_counter <=3D c->cache_clean_lru_counter; } =20 -void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c) +void qcow2_cache_clean_unused(Qcow2Cache *c) { int i =3D 0; while (i < c->size) { diff --git a/block/qcow2.c b/block/qcow2.c index 38e7fdc4b0..461cc7ab1c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -706,8 +706,8 @@ static void cache_clean_timer_cb(void *opaque) { BlockDriverState *bs =3D opaque; BDRVQcow2State *s =3D bs->opaque; - qcow2_cache_clean_unused(bs, s->l2_table_cache); - qcow2_cache_clean_unused(bs, s->refcount_block_cache); + qcow2_cache_clean_unused(s->l2_table_cache); + qcow2_cache_clean_unused(s->refcount_block_cache); timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + (int64_t) s->cache_clean_interval * 1000); } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543851809341.8147728335608; Tue, 13 Feb 2018 09:44:11 -0800 (PST) Received: from localhost ([::1]:56305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elech-0001Jy-JC for importer@patchew.org; Tue, 13 Feb 2018 12:44:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1x-0003CF-0W for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1r-0005T9-56 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:08 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37822 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1o-0005Qp-N4; Tue, 13 Feb 2018 12:06:00 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50EA4402291E; Tue, 13 Feb 2018 17:06:00 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1A3710073CD; Tue, 13 Feb 2018 17:05:59 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:00 +0100 Message-Id: <20180213170529.10858-27-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:00 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 26/55] qcow2: Remove BDS parameter from qcow2_cache_discard() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx() and qcow2_cache_table_release(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 9724f7e38e763ad3be32627c6b7fe8df9edb1476.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 2 +- block/qcow2-cache.c | 2 +- block/qcow2-refcount.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 867f2e8828..7296784353 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -656,7 +656,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, void qcow2_cache_put(Qcow2Cache *c, void **table); void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset); -void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table); +void qcow2_cache_discard(Qcow2Cache *c, void *table); =20 /* qcow2-bitmap.c functions */ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *r= es, diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 03b3e03c6c..8d0b65e671 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -441,7 +441,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, return NULL; } =20 -void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table) +void qcow2_cache_discard(Qcow2Cache *c, void *table) { int i =3D qcow2_cache_get_table_idx(c, table); =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 65af05dd23..361b39d5cc 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,12 +875,12 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bl= ockDriverState *bs, offset); if (table !=3D NULL) { qcow2_cache_put(s->refcount_block_cache, &refcount_block); - qcow2_cache_discard(bs, s->refcount_block_cache, table); + qcow2_cache_discard(s->refcount_block_cache, table); } =20 table =3D qcow2_cache_is_table_offset(bs, s->l2_table_cache, o= ffset); if (table !=3D NULL) { - qcow2_cache_discard(bs, s->l2_table_cache, table); + qcow2_cache_discard(s->l2_table_cache, table); } =20 if (s->discard_passthrough[type]) { @@ -3190,7 +3190,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, discard_block_offs); if (refblock) { /* discard refblock from the cache if refblock is cached */ - qcow2_cache_discard(bs, s->refcount_block_cache, refblock); + qcow2_cache_discard(s->refcount_block_cache, refblock); } update_refcount_discard(bs, discard_block_offs, s->cluster_size); =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854346466349.44262933780453; Tue, 13 Feb 2018 09:37:44 -0800 (PST) Received: from localhost ([::1]:56251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleWS-0004ES-QJ for importer@patchew.org; Tue, 13 Feb 2018 12:37:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1y-0003DK-Cq for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1v-0005WY-79 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:10 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37824 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1p-0005Rd-ML; Tue, 13 Feb 2018 12:06:01 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D3F1402291E; Tue, 13 Feb 2018 17:06:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BB2B10075C2; Tue, 13 Feb 2018 17:06:00 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:01 +0100 Message-Id: <20180213170529.10858-28-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:01 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 27/55] qcow2: Remove BDS parameter from qcow2_cache_is_table_offset() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_addr(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: eb0ed90affcf302e5a954bafb5931b5215483d3a.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 3 +-- block/qcow2-cache.c | 3 +-- block/qcow2-refcount.c | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 7296784353..edc5d8d57d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -654,8 +654,7 @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c= , uint64_t offset, int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t of= fset, void **table); void qcow2_cache_put(Qcow2Cache *c, void **table); -void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, - uint64_t offset); +void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset); void qcow2_cache_discard(Qcow2Cache *c, void *table); =20 /* qcow2-bitmap.c functions */ diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 8d0b65e671..b1aa42477e 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -428,8 +428,7 @@ void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *= table) c->entries[i].dirty =3D true; } =20 -void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, - uint64_t offset) +void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset) { int i; =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 361b39d5cc..9df380d52c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -871,14 +871,14 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bl= ockDriverState *bs, if (refcount =3D=3D 0) { void *table; =20 - table =3D qcow2_cache_is_table_offset(bs, s->refcount_block_ca= che, + table =3D qcow2_cache_is_table_offset(s->refcount_block_cache, offset); if (table !=3D NULL) { qcow2_cache_put(s->refcount_block_cache, &refcount_block); qcow2_cache_discard(s->refcount_block_cache, table); } =20 - table =3D qcow2_cache_is_table_offset(bs, s->l2_table_cache, o= ffset); + table =3D qcow2_cache_is_table_offset(s->l2_table_cache, offse= t); if (table !=3D NULL) { qcow2_cache_discard(s->l2_table_cache, table); } @@ -3186,7 +3186,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, s->free_cluster_index =3D cluster_index; } =20 - refblock =3D qcow2_cache_is_table_offset(bs, s->refcount_block_cache, + refblock =3D qcow2_cache_is_table_offset(s->refcount_block_cache, discard_block_offs); if (refblock) { /* discard refblock from the cache if refblock is cached */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543486008222.33495825554928; Tue, 13 Feb 2018 09:38:06 -0800 (PST) Received: from localhost ([::1]:56255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleWo-0004af-Ac for importer@patchew.org; Tue, 13 Feb 2018 12:38:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1t-00038x-Ly for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1s-0005UO-O1 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:05 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37826 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1q-0005Sb-FF; Tue, 13 Feb 2018 12:06:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 253D14022909; Tue, 13 Feb 2018 17:06:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7575310073CD; Tue, 13 Feb 2018 17:06:01 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:02 +0100 Message-Id: <20180213170529.10858-29-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:02 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 28/55] qcow2: Add offset_to_l1_index() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Similar to offset_to_l2_index(), this function returns the index in the L1 table for a given guest offset. This is only used in a couple of places and it's not a particularly complex calculation, but it makes the code a bit more readable. Although in the qcow2_get_cluster_offset() case the old code was taking advantage of the l1_bits variable, we're going to get rid of the other uses of l1_bits in a later patch anyway, so it doesn't make sense to keep it just for this. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: a5f626fed526b7459a0425fad06d823d18df8522.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 5 +++++ block/qcow2-cluster.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index edc5d8d57d..d9ba57c030 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -463,6 +463,11 @@ static inline int64_t size_to_l1(BDRVQcow2State *s, in= t64_t size) return (size + (1ULL << shift) - 1) >> shift; } =20 +static inline int offset_to_l1_index(BDRVQcow2State *s, uint64_t offset) +{ + return offset >> (s->l2_bits + s->cluster_bits); +} + static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset) { return (offset >> s->cluster_bits) & (s->l2_size - 1); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ab5715c97e..ce7591dc3d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -540,7 +540,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, =20 /* seek to the l2 offset in the l1 table */ =20 - l1_index =3D offset >> l1_bits; + l1_index =3D offset_to_l1_index(s, offset); if (l1_index >=3D s->l1_size) { type =3D QCOW2_CLUSTER_UNALLOCATED; goto out; @@ -663,7 +663,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, =20 /* seek to the l2 offset in the l1 table */ =20 - l1_index =3D offset >> (s->l2_bits + s->cluster_bits); + l1_index =3D offset_to_l1_index(s, offset); if (l1_index >=3D s->l1_size) { ret =3D qcow2_grow_l1_table(bs, l1_index + 1, false); if (ret < 0) { --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543686294457.5190401549255; Tue, 13 Feb 2018 09:41:26 -0800 (PST) Received: from localhost ([::1]:56283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elea5-0007Xx-F1 for importer@patchew.org; Tue, 13 Feb 2018 12:41:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1u-0003AT-Ml for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1t-0005VG-Oc for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50790 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1r-0005TD-DT; Tue, 13 Feb 2018 12:06:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E99AEB6ED; Tue, 13 Feb 2018 17:06:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FC8C10073CD; Tue, 13 Feb 2018 17:06:02 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:03 +0100 Message-Id: <20180213170529.10858-30-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 29/55] qcow2: Add l2_slice_size field to BDRVQcow2State X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The BDRVQcow2State structure contains an l2_size field, which stores the number of 64-bit entries in an L2 table. For efficiency reasons we want to be able to load slices instead of full L2 tables, so we need to know how many entries an L2 slice can hold. An L2 slice is the portion of an L2 table that is loaded by the qcow2 cache. At the moment that cache can only load complete tables, therefore an L2 slice has the same size as an L2 table (one cluster) and l2_size =3D=3D l2_slice_size. Later we'll allow smaller slices, but until then we have to use this new l2_slice_size field to make the rest of the code ready for that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: adb048595f9fb5dfb110c802a8b3c3be3b937f37.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 1 + block/qcow2.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index d9ba57c030..45fb7f4299 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -251,6 +251,7 @@ typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; + int l2_slice_size; int l2_bits; int l2_size; int l1_size; diff --git a/block/qcow2.c b/block/qcow2.c index 461cc7ab1c..ba8d71c72d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -807,6 +807,7 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, typedef struct Qcow2ReopenState { Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; + int l2_slice_size; /* Number of entries in a slice of the L2 table */ bool use_lazy_refcounts; int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; @@ -888,6 +889,7 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, } } =20 + r->l2_slice_size =3D s->cluster_size / sizeof(uint64_t); r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size= ); if (r->l2_table_cache =3D=3D NULL || r->refcount_block_cache =3D=3D NU= LL) { @@ -1051,6 +1053,7 @@ static void qcow2_update_options_commit(BlockDriverSt= ate *bs, } s->l2_table_cache =3D r->l2_table_cache; s->refcount_block_cache =3D r->refcount_block_cache; + s->l2_slice_size =3D r->l2_slice_size; =20 s->overlap_check =3D r->overlap_check; s->use_lazy_refcounts =3D r->use_lazy_refcounts; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544046284253.27765964150444; Tue, 13 Feb 2018 09:47:26 -0800 (PST) Received: from localhost ([::1]:56340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elefm-00049D-AK for importer@patchew.org; Tue, 13 Feb 2018 12:47:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1v-0003BV-D5 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1u-0005Vp-B6 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:07 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38420 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1s-0005Tq-AS; Tue, 13 Feb 2018 12:06:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED98C407244E; Tue, 13 Feb 2018 17:06:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49A6D10073CD; Tue, 13 Feb 2018 17:06:03 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:04 +0100 Message-Id: <20180213170529.10858-31-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 30/55] qcow2: Add offset_to_l2_slice_index() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Similar to offset_to_l2_index(), this function takes a guest offset and returns the index in the L2 slice that contains its L2 entry. An L2 slice has currently the same size as an L2 table (one cluster), so both functions return the same value for now. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: a1c45c5c5a76146dd1712d8d1e7b409ad539c718.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index 45fb7f4299..d956a6cdd2 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -474,6 +474,11 @@ static inline int offset_to_l2_index(BDRVQcow2State *s= , int64_t offset) return (offset >> s->cluster_bits) & (s->l2_size - 1); } =20 +static inline int offset_to_l2_slice_index(BDRVQcow2State *s, int64_t offs= et) +{ + return (offset >> s->cluster_bits) & (s->l2_slice_size - 1); +} + static inline int64_t align_offset(int64_t offset, int n) { offset =3D (offset + n - 1) & ~(n - 1); --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543666384241.04867961785328; Tue, 13 Feb 2018 09:41:06 -0800 (PST) Received: from localhost ([::1]:56282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleZl-0007Fz-GU for importer@patchew.org; Tue, 13 Feb 2018 12:41:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1y-0003DF-Cd for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1v-0005XJ-VJ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:10 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56610 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1t-0005UU-6x; Tue, 13 Feb 2018 12:06:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D847040FB64A; Tue, 13 Feb 2018 17:06:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34E9D10073CD; Tue, 13 Feb 2018 17:06:04 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:05 +0100 Message-Id: <20180213170529.10858-32-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:04 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 31/55] qcow2: Update l2_load() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Each entry in the qcow2 L2 cache stores a full L2 table (which uses a complete cluster in the qcow2 image). A cluster is usually too large to be used efficiently as the size for a cache entry, so we want to decouple both values by allowing smaller cache entries. Therefore the qcow2 L2 cache will no longer return full L2 tables but slices instead. This patch updates l2_load() so it can handle L2 slices correctly. Apart from the offset of the L2 table (which we already had) we also need the guest offset in order to calculate which one of the slices we need. An L2 slice has currently the same size as an L2 table (one cluster), so for now this function will load exactly the same data as before. This patch also removes a stale comment about the return value being a pointer to the L2 table. This function returns an error code since 55c17e9821c474d5fcdebdc82ed2fc096777d611. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: b830aa1fc5b6f8e3cb331d006853fe22facca847.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ce7591dc3d..542080aed0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -195,20 +195,26 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_= t min_size, /* * l2_load * - * Loads a L2 table into memory. If the table is in the cache, the cache - * is used; otherwise the L2 table is loaded from the image file. + * @bs: The BlockDriverState + * @offset: A guest offset, used to calculate what slice of the L2 + * table to load. + * @l2_offset: Offset to the L2 table in the image file. + * @l2_slice: Location to store the pointer to the L2 slice. * - * Returns a pointer to the L2 table on success, or NULL if the read from - * the image file failed. + * Loads a L2 slice into memory (L2 slices are the parts of L2 tables + * that are loaded by the qcow2 cache). If the slice is in the cache, + * the cache is used; otherwise the L2 slice is loaded from the image + * file. */ - -static int l2_load(BlockDriverState *bs, uint64_t l2_offset, - uint64_t **l2_table) +static int l2_load(BlockDriverState *bs, uint64_t offset, + uint64_t l2_offset, uint64_t **l2_slice) { BDRVQcow2State *s =3D bs->opaque; + int start_of_slice =3D sizeof(uint64_t) * + (offset_to_l2_index(s, offset) - offset_to_l2_slice_index(s, offse= t)); =20 - return qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void **)l2_table); + return qcow2_cache_get(bs, s->l2_table_cache, l2_offset + start_of_sli= ce, + (void **)l2_slice); } =20 /* @@ -561,7 +567,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, =20 /* load the l2 table in memory */ =20 - ret =3D l2_load(bs, l2_offset, &l2_table); + ret =3D l2_load(bs, offset, l2_offset, &l2_table); if (ret < 0) { return ret; } @@ -684,7 +690,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, =20 if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { /* load the l2 table in memory */ - ret =3D l2_load(bs, l2_offset, &l2_table); + ret =3D l2_load(bs, offset, l2_offset, &l2_table); if (ret < 0) { return ret; } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543652894760.3920971310714; Tue, 13 Feb 2018 09:40:52 -0800 (PST) Received: from localhost ([::1]:56278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleZU-00070P-Sc for importer@patchew.org; Tue, 13 Feb 2018 12:40:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele23-0003KZ-0g for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1y-0005ZO-HZ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:14 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37830 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1u-0005VP-4h; Tue, 13 Feb 2018 12:06:06 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C28F5402291E; Tue, 13 Feb 2018 17:06:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F12010075C2; Tue, 13 Feb 2018 17:06:04 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:06 +0100 Message-Id: <20180213170529.10858-33-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:05 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 32/55] qcow2: Prepare l2_allocate() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Adding support for L2 slices to l2_allocate() needs (among other things) an extra loop that iterates over all slices of a new L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: d0d7dca8520db304524f52f49d8157595a707a35.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 53 ++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 542080aed0..3f7272441d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -299,38 +299,43 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) /* allocate a new entry in the l2 cache */ =20 trace_qcow2_l2_allocate_get_empty(bs, l1_index); - ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void*= *) table); - if (ret < 0) { - goto fail; - } + { + ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, + l2_offset, + (void **) table); + if (ret < 0) { + goto fail; + } =20 - l2_table =3D *table; + l2_table =3D *table; =20 - if ((old_l2_offset & L1E_OFFSET_MASK) =3D=3D 0) { - /* if there was no old l2 table, clear the new table */ - memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); - } else { - uint64_t* old_table; + if ((old_l2_offset & L1E_OFFSET_MASK) =3D=3D 0) { + /* if there was no old l2 table, clear the new table */ + memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); + } else { + uint64_t *old_table; =20 - /* if there was an old l2 table, read it from the disk */ - BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); - ret =3D qcow2_cache_get(bs, s->l2_table_cache, - old_l2_offset & L1E_OFFSET_MASK, - (void**) &old_table); - if (ret < 0) { - goto fail; + /* if there was an old l2 table, read it from the disk */ + BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); + ret =3D qcow2_cache_get(bs, s->l2_table_cache, + old_l2_offset & L1E_OFFSET_MASK, + (void **) &old_table); + if (ret < 0) { + goto fail; + } + + memcpy(l2_table, old_table, s->cluster_size); + + qcow2_cache_put(s->l2_table_cache, (void **) &old_table); } =20 - memcpy(l2_table, old_table, s->cluster_size); + /* write the l2 table to the file */ + BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 - qcow2_cache_put(s->l2_table_cache, (void **) &old_table); + trace_qcow2_l2_allocate_write_l2(bs, l1_index); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); } =20 - /* write the l2 table to the file */ - BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); - - trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); ret =3D qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544606793144.52096916576306; Tue, 13 Feb 2018 09:56:46 -0800 (PST) Received: from localhost ([::1]:56450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eleos-00042E-Dr for importer@patchew.org; Tue, 13 Feb 2018 12:56:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Pu-IF for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele24-0005eG-RU for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51188 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1v-0005WM-3F; Tue, 13 Feb 2018 12:06:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD0C07CBB2; Tue, 13 Feb 2018 17:06:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 099C110073CD; Tue, 13 Feb 2018 17:06:05 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:07 +0100 Message-Id: <20180213170529.10858-34-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:06 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 33/55] qcow2: Update l2_allocate() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This patch updates l2_allocate() to support the qcow2 cache returning L2 slices instead of full L2 tables. The old code simply gets an L2 table from the cache and initializes it with zeroes or with the contents of an existing table. With a cache that returns slices instead of tables the idea remains the same, but the code must now iterate over all the slices that are contained in an L2 table. Since now we're operating with slices the function can no longer return the newly-allocated table, so it's up to the caller to retrieve the appropriate L2 slice after calling l2_allocate() (note that with this patch the caller is still loading full L2 tables, but we'll deal with that in a separate patch). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Message-id: 20fc0415bf0e011e29f6487ec86eb06a11f37445.1517840877.git.berto@i= galia.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 56 +++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 3f7272441d..4aa9ea7b29 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -263,11 +263,12 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1= _index) * */ =20 -static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **tabl= e) +static int l2_allocate(BlockDriverState *bs, int l1_index) { BDRVQcow2State *s =3D bs->opaque; uint64_t old_l2_offset; - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; + unsigned slice, slice_size2, n_slices; int64_t l2_offset; int ret; =20 @@ -298,42 +299,45 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) =20 /* allocate a new entry in the l2 cache */ =20 + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; + trace_qcow2_l2_allocate_get_empty(bs, l1_index); - { + for (slice =3D 0; slice < n_slices; slice++) { ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, - l2_offset, - (void **) table); + l2_offset + slice * slice_size2, + (void **) &l2_slice); if (ret < 0) { goto fail; } =20 - l2_table =3D *table; - if ((old_l2_offset & L1E_OFFSET_MASK) =3D=3D 0) { - /* if there was no old l2 table, clear the new table */ - memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); + /* if there was no old l2 table, clear the new slice */ + memset(l2_slice, 0, slice_size2); } else { - uint64_t *old_table; + uint64_t *old_slice; + uint64_t old_l2_slice_offset =3D + (old_l2_offset & L1E_OFFSET_MASK) + slice * slice_size2; =20 - /* if there was an old l2 table, read it from the disk */ + /* if there was an old l2 table, read a slice from the disk */ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); - ret =3D qcow2_cache_get(bs, s->l2_table_cache, - old_l2_offset & L1E_OFFSET_MASK, - (void **) &old_table); + ret =3D qcow2_cache_get(bs, s->l2_table_cache, old_l2_slice_of= fset, + (void **) &old_slice); if (ret < 0) { goto fail; } =20 - memcpy(l2_table, old_table, s->cluster_size); + memcpy(l2_slice, old_slice, slice_size2); =20 - qcow2_cache_put(s->l2_table_cache, (void **) &old_table); + qcow2_cache_put(s->l2_table_cache, (void **) &old_slice); } =20 - /* write the l2 table to the file */ + /* write the l2 slice to the file */ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 ret =3D qcow2_cache_flush(bs, s->l2_table_cache); @@ -349,14 +353,13 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) goto fail; } =20 - *table =3D l2_table; trace_qcow2_l2_allocate_done(bs, l1_index, 0); return 0; =20 fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); - if (l2_table !=3D NULL) { - qcow2_cache_put(s->l2_table_cache, (void **) table); + if (l2_slice !=3D NULL) { + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } s->l1_table[l1_index] =3D old_l2_offset; if (l2_offset > 0) { @@ -701,7 +704,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, } } else { /* First allocate a new L2 table (and do COW if needed) */ - ret =3D l2_allocate(bs, l1_index, &l2_table); + ret =3D l2_allocate(bs, l1_index); if (ret < 0) { return ret; } @@ -711,6 +714,15 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_= t), QCOW2_DISCARD_OTHER); } + + /* Get the offset of the newly-allocated l2 table */ + l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; + assert(offset_into_cluster(s, l2_offset) =3D=3D 0); + /* Load the l2 table in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_table); + if (ret < 0) { + return ret; + } } =20 /* find the cluster offset for the given disk offset */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544137758187.95047136803714; Tue, 13 Feb 2018 09:48:57 -0800 (PST) Received: from localhost ([::1]:56346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elehM-0005NY-U1 for importer@patchew.org; Tue, 13 Feb 2018 12:48:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele20-0003HO-L5 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1z-0005aP-N0 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:12 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38426 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1w-0005XF-08; Tue, 13 Feb 2018 12:06:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97B2A4072467; Tue, 13 Feb 2018 17:06:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E861110073CD; Tue, 13 Feb 2018 17:06:06 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:08 +0100 Message-Id: <20180213170529.10858-35-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:06:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Feb 2018 17:06:07 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 34/55] qcow2: Refactor get_cluster_table() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia After the previous patch we're now always using l2_load() in get_cluster_table() regardless of whether a new L2 table has to be allocated or not. This patch refactors that part of the code to use one single l2_load() call. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: ce31758c4a1fadccea7a6ccb93951eb01d95fd4c.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 4aa9ea7b29..044eccda72 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -694,15 +694,7 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, return -EIO; } =20 - /* seek the l2 table of the given l2 offset */ - - if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { - /* load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } - } else { + if (!(s->l1_table[l1_index] & QCOW_OFLAG_COPIED)) { /* First allocate a new L2 table (and do COW if needed) */ ret =3D l2_allocate(bs, l1_index); if (ret < 0) { @@ -718,11 +710,12 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, /* Get the offset of the newly-allocated l2 table */ l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; assert(offset_into_cluster(s, l2_offset) =3D=3D 0); - /* Load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } + } + + /* load the l2 table in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_table); + if (ret < 0) { + return ret; } =20 /* find the cluster offset for the given disk offset */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854387491658.54106950417338; Tue, 13 Feb 2018 09:44:34 -0800 (PST) Received: from localhost ([::1]:56307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eled8-0001ov-2o for importer@patchew.org; Tue, 13 Feb 2018 12:44:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Q9-LE for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele24-0005dn-FB for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37832 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1w-0005Xt-TY; Tue, 13 Feb 2018 12:06:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82CE24022909; Tue, 13 Feb 2018 17:06:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2B1C10075C2; Tue, 13 Feb 2018 17:06:07 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:09 +0100 Message-Id: <20180213170529.10858-36-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:08 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 35/55] qcow2: Update get_cluster_table() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This patch updates get_cluster_table() to return L2 slices instead of full L2 tables. The code itself needs almost no changes, it only needs to call offset_to_l2_slice_index() instead of offset_to_l2_index(). This patch also renames all the relevant variables and the documentation. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 64cf064c0021ba315d3f3032da0f95db1b615f33.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 044eccda72..cd1ba40f74 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -659,20 +659,20 @@ fail: * get_cluster_table * * for a given disk offset, load (and allocate if needed) - * the l2 table. + * the appropriate slice of its l2 table. * - * the cluster index in the l2 table is given to the caller. + * the cluster index in the l2 slice is given to the caller. * * Returns 0 on success, -errno in failure case */ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, - uint64_t **new_l2_table, + uint64_t **new_l2_slice, int *new_l2_index) { BDRVQcow2State *s =3D bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; int ret; =20 /* seek to the l2 offset in the l1 table */ @@ -712,17 +712,17 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, assert(offset_into_cluster(s, l2_offset) =3D=3D 0); } =20 - /* load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); + /* load the l2 slice in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_slice); if (ret < 0) { return ret; } =20 /* find the cluster offset for the given disk offset */ =20 - l2_index =3D offset_to_l2_index(s, offset); + l2_index =3D offset_to_l2_slice_index(s, offset); =20 - *new_l2_table =3D l2_table; + *new_l2_slice =3D l2_slice; *new_l2_index =3D l2_index; =20 return 0; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544443052894.0298287104005; Tue, 13 Feb 2018 09:54:03 -0800 (PST) Received: from localhost ([::1]:56394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elemI-0001V4-5z for importer@patchew.org; Tue, 13 Feb 2018 12:54:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2A-0003Tl-9s for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele28-0005hR-JO for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:22 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51190 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1x-0005YW-QH; Tue, 13 Feb 2018 12:06:09 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DE237CBB2; Tue, 13 Feb 2018 17:06:09 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE41910073CD; Tue, 13 Feb 2018 17:06:08 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:10 +0100 Message-Id: <20180213170529.10858-37-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:09 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 36/55] qcow2: Update qcow2_get_cluster_offset() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia qcow2_get_cluster_offset() checks how many contiguous bytes are available at a given offset. The returned number of bytes is limited by the amount that can be addressed without having to load more than one L2 table. Since we'll be loading L2 slices instead of full tables this patch changes the limit accordingly using the size of the L2 slice for the calculations instead of the full table size. One consequence of this is that with small L2 slices operations such as 'qemu-img map' will need to iterate in more steps because each qcow2_get_cluster_offset() call will potentially return a smaller number. However the code is already prepared for that so this doesn't break semantics. The l2_table variable is also renamed to l2_slice to reflect this, and offset_to_l2_index() is replaced with offset_to_l2_slice_index(). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 6b602260acb33da56ed6af9611731cb7acd110eb.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index cd1ba40f74..e0eea73297 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -529,8 +529,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, { BDRVQcow2State *s =3D bs->opaque; unsigned int l2_index; - uint64_t l1_index, l2_offset, *l2_table; - int l1_bits, c; + uint64_t l1_index, l2_offset, *l2_slice; + int c; unsigned int offset_in_cluster; uint64_t bytes_available, bytes_needed, nb_clusters; QCow2ClusterType type; @@ -539,12 +539,12 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, offset_in_cluster =3D offset_into_cluster(s, offset); bytes_needed =3D (uint64_t) *bytes + offset_in_cluster; =20 - l1_bits =3D s->l2_bits + s->cluster_bits; - /* compute how many bytes there are between the start of the cluster - * containing offset and the end of the l1 entry */ - bytes_available =3D (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) -= 1)) - + offset_in_cluster; + * containing offset and the end of the l2 slice that contains + * the entry pointing to it */ + bytes_available =3D + ((uint64_t) (s->l2_slice_size - offset_to_l2_slice_index(s, offset= ))) + << s->cluster_bits; =20 if (bytes_needed > bytes_available) { bytes_needed =3D bytes_available; @@ -573,17 +573,17 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, return -EIO; } =20 - /* load the l2 table in memory */ + /* load the l2 slice in memory */ =20 - ret =3D l2_load(bs, offset, l2_offset, &l2_table); + ret =3D l2_load(bs, offset, l2_offset, &l2_slice); if (ret < 0) { return ret; } =20 /* find the cluster offset for the given disk offset */ =20 - l2_index =3D offset_to_l2_index(s, offset); - *cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + l2_index =3D offset_to_l2_slice_index(s, offset); + *cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); =20 nb_clusters =3D size_to_clusters(s, bytes_needed); /* bytes_needed <=3D *bytes + offset_in_cluster, both of which are uns= igned @@ -610,14 +610,14 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c =3D count_contiguous_clusters_unallocated(nb_clusters, - &l2_table[l2_index], typ= e); + &l2_slice[l2_index], typ= e); *cluster_offset =3D 0; break; case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_ZERO= ); + &l2_slice[l2_index], QCOW_OFLAG_ZERO= ); *cluster_offset &=3D L2E_OFFSET_MASK; if (offset_into_cluster(s, *cluster_offset)) { qcow2_signal_corruption(bs, true, -1, -1, @@ -633,7 +633,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, abort(); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 bytes_available =3D (int64_t)c * s->cluster_size; =20 @@ -651,7 +651,7 @@ out: return type; =20 fail: - qcow2_cache_put(s->l2_table_cache, (void **)&l2_table); + qcow2_cache_put(s->l2_table_cache, (void **)&l2_slice); return ret; } =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543875235842.9045532305353; Tue, 13 Feb 2018 09:44:35 -0800 (PST) Received: from localhost ([::1]:56306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elecz-0001e5-R9 for importer@patchew.org; Tue, 13 Feb 2018 12:44:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele22-0003KV-DQ for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele21-0005bc-Eo for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:14 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51192 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1y-0005ZB-Nt; Tue, 13 Feb 2018 12:06:10 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5842C7CBB2; Tue, 13 Feb 2018 17:06:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id A919110073CD; Tue, 13 Feb 2018 17:06:09 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:11 +0100 Message-Id: <20180213170529.10858-38-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:10 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 37/55] qcow2: Update qcow2_alloc_cluster_link_l2() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia There's a loop in this function that iterates over the L2 entries in a table, so now we need to assert that it remains within the limits of an L2 slice. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: f9846a1c2efc51938e877e2a25852d9ab14797ff.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e0eea73297..a01abb3b18 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -922,7 +922,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) { BDRVQcow2State *s =3D bs->opaque; int i, j =3D 0, l2_index, ret; - uint64_t *old_cluster, *l2_table; + uint64_t *old_cluster, *l2_slice; uint64_t cluster_offset =3D m->alloc_offset; =20 trace_qcow2_cluster_link_l2(qemu_coroutine_self(), m->nb_clusters); @@ -949,13 +949,13 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) s->refcount_block_cache); } =20 - ret =3D get_cluster_table(bs, m->offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, m->offset, &l2_slice, &l2_index); if (ret < 0) { goto err; } - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); =20 - assert(l2_index + m->nb_clusters <=3D s->l2_size); + assert(l2_index + m->nb_clusters <=3D s->l2_slice_size); for (i =3D 0; i < m->nb_clusters; i++) { /* if two concurrent writes happen to the same unallocated cluster * each write allocates separate cluster and writes data concurren= tly. @@ -963,16 +963,16 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) * cluster the second one has to do RMW (which is done above by * perform_cow()), update l2 table with its cluster pointer and fr= ee * old cluster. This is what this loop does */ - if (l2_table[l2_index + i] !=3D 0) { - old_cluster[j++] =3D l2_table[l2_index + i]; + if (l2_slice[l2_index + i] !=3D 0) { + old_cluster[j++] =3D l2_slice[l2_index + i]; } =20 - l2_table[l2_index + i] =3D cpu_to_be64((cluster_offset + + l2_slice[l2_index + i] =3D cpu_to_be64((cluster_offset + (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); } =20 =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 /* * If this was a COW, we need to decrease the refcount of the old clus= ter. --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544244922497.9899724557264; Tue, 13 Feb 2018 09:50:44 -0800 (PST) Received: from localhost ([::1]:56369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elej1-00077i-0m for importer@patchew.org; Tue, 13 Feb 2018 12:50:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Pt-HD for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele24-0005dr-G3 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56614 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1z-0005a2-KT; Tue, 13 Feb 2018 12:06:11 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 429D040FB645; Tue, 13 Feb 2018 17:06:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 938EB10073CD; Tue, 13 Feb 2018 17:06:10 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:12 +0100 Message-Id: <20180213170529.10858-39-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:11 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 38/55] qcow2: Update handle_copied() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia handle_copied() loads an L2 table and limits the number of checked clusters to the amount that fits inside that table. Since we'll be loading L2 slices instead of full tables we need to update that limit. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 541ac001a7d6b86bab2392554bee53c2b312148c.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index a01abb3b18..7699544358 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1119,7 +1119,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, BDRVQcow2State *s =3D bs->opaque; int l2_index; uint64_t cluster_offset; - uint64_t *l2_table; + uint64_t *l2_slice; uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -1131,23 +1131,23 @@ static int handle_copied(BlockDriverState *bs, uint= 64_t guest_offset, =3D=3D offset_into_cluster(s, *host_offset= )); =20 /* - * Calculate the number of clusters to look for. We stop at L2 table + * Calculate the number of clusters to look for. We stop at L2 slice * boundaries to keep things simple. */ nb_clusters =3D size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); =20 - l2_index =3D offset_to_l2_index(s, guest_offset); - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + l2_index =3D offset_to_l2_slice_index(s, guest_offset); + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 /* Find L2 entry for the first involved cluster */ - ret =3D get_cluster_table(bs, guest_offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, guest_offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); =20 /* Check how many clusters are already allocated and don't need COW */ if (qcow2_get_cluster_type(cluster_offset) =3D=3D QCOW2_CLUSTER_NORMAL @@ -1175,7 +1175,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, /* We keep all QCOW_OFLAG_COPIED clusters */ keep_clusters =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], + &l2_slice[l2_index], QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO); assert(keep_clusters <=3D nb_clusters); =20 @@ -1190,7 +1190,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, =20 /* Cleanup */ out: - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 /* Only return a host offset if we actually made progress. Otherwise we * would make requirements for handle_alloc() that it can't fulfill */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854442059790.1300026723975; Tue, 13 Feb 2018 09:53:40 -0800 (PST) Received: from localhost ([::1]:56388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elels-0001AG-Jt for importer@patchew.org; Tue, 13 Feb 2018 12:53:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Py-ID for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele25-0005fT-Um for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50794 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele20-0005an-Gy; Tue, 13 Feb 2018 12:06:12 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E539EB6F9; Tue, 13 Feb 2018 17:06:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DD7410073CD; Tue, 13 Feb 2018 17:06:11 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:13 +0100 Message-Id: <20180213170529.10858-40-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:12 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 39/55] qcow2: Update handle_alloc() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia handle_alloc() loads an L2 table and limits the number of checked clusters to the amount that fits inside that table. Since we'll be loading L2 slices instead of full tables we need to update that limit. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: b243299c7136f7014c5af51665431ddbf5e99afd.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 7699544358..dbd57cd35f 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1274,7 +1274,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, { BDRVQcow2State *s =3D bs->opaque; int l2_index; - uint64_t *l2_table; + uint64_t *l2_slice; uint64_t entry; uint64_t nb_clusters; int ret; @@ -1287,29 +1287,29 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, assert(*bytes > 0); =20 /* - * Calculate the number of clusters to look for. We stop at L2 table + * Calculate the number of clusters to look for. We stop at L2 slice * boundaries to keep things simple. */ nb_clusters =3D size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); =20 - l2_index =3D offset_to_l2_index(s, guest_offset); - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + l2_index =3D offset_to_l2_slice_index(s, guest_offset); + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 /* Find L2 entry for the first involved cluster */ - ret =3D get_cluster_table(bs, guest_offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, guest_offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - entry =3D be64_to_cpu(l2_table[l2_index]); + entry =3D be64_to_cpu(l2_slice[l2_index]); =20 /* For the moment, overwrite compressed clusters one by one */ if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters =3D 1; } else { - nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_table, l2_in= dex); + nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_slice, l2_in= dex); } =20 /* This function is only called when there were no non-COW clusters, s= o if @@ -1338,7 +1338,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, * nb_clusters already to a range of COW clusters */ preallocated_nb_clusters =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_COPI= ED); + &l2_slice[l2_index], QCOW_OFLAG_COPI= ED); assert(preallocated_nb_clusters > 0); =20 nb_clusters =3D preallocated_nb_clusters; @@ -1349,7 +1349,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, keep_old_clusters =3D true; } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 if (!alloc_cluster_offset) { /* Allocate, if necessary at a given offset in the image file */ --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544809985180.75419797648033; Tue, 13 Feb 2018 10:00:09 -0800 (PST) Received: from localhost ([::1]:56636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elesD-00070g-4S for importer@patchew.org; Tue, 13 Feb 2018 13:00:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2A-0003VA-Pn for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele29-0005i5-3i for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:22 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56616 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele21-0005bX-Eb; Tue, 13 Feb 2018 12:06:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1800040FB645; Tue, 13 Feb 2018 17:06:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6978D1007D95; Tue, 13 Feb 2018 17:06:12 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:14 +0100 Message-Id: <20180213170529.10858-41-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:13 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 40/55] qcow2: Update discard_single_l2() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia discard_single_l2() limits the number of clusters to be discarded to the amount that fits inside an L2 table. Since we'll be loading L2 slices instead of full tables we need to update that limit. The function is renamed to discard_in_l2_slice() for clarity. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Message-id: 1cb44a5b68be5334cb01b97a3db3a3c5a43396e5.1517840877.git.berto@i= galia.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index dbd57cd35f..62336960a5 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1631,32 +1631,32 @@ int qcow2_decompress_cluster(BlockDriverState *bs, = uint64_t cluster_offset) =20 /* * This discards as many clusters of nb_clusters as possible at once (i.e. - * all clusters in the same L2 table) and returns the number of discarded + * all clusters in the same L2 slice) and returns the number of discarded * clusters. */ -static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - uint64_t nb_clusters, enum qcow2_discard_type= type, - bool full_discard) +static int discard_in_l2_slice(BlockDriverState *bs, uint64_t offset, + uint64_t nb_clusters, + enum qcow2_discard_type type, bool full_dis= card) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_table; + uint64_t *l2_slice; int l2_index; int ret; int i; =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - /* Limit nb_clusters to one L2 table */ - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + /* Limit nb_clusters to one L2 slice */ + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_l2_entry; =20 - old_l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); + old_l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); =20 /* * If full_discard is false, make sure that a discarded area reads= back @@ -1694,18 +1694,18 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, } =20 /* First remove L2 entries */ - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (!full_discard && s->qcow_version >=3D 3) { - l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); } else { - l2_table[l2_index + i] =3D cpu_to_be64(0); + l2_slice[l2_index + i] =3D cpu_to_be64(0); } =20 /* Then decrease the refcount */ qcow2_free_any_clusters(bs, old_l2_entry, 1, type); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return nb_clusters; } @@ -1729,10 +1729,10 @@ int qcow2_cluster_discard(BlockDriverState *bs, uin= t64_t offset, =20 s->cache_discards =3D true; =20 - /* Each L2 table is handled by its own loop iteration */ + /* Each L2 slice is handled by its own loop iteration */ while (nb_clusters > 0) { - cleared =3D discard_single_l2(bs, offset, nb_clusters, type, - full_discard); + cleared =3D discard_in_l2_slice(bs, offset, nb_clusters, type, + full_discard); if (cleared < 0) { ret =3D cleared; goto fail; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544077149920.4018614826508; Tue, 13 Feb 2018 09:47:57 -0800 (PST) Received: from localhost ([::1]:56342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elegO-0004bh-8r for importer@patchew.org; Tue, 13 Feb 2018 12:47:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Q4-Ji for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele24-0005eL-Rj for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51194 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele22-0005cE-BL; Tue, 13 Feb 2018 12:06:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02CD47CBB2; Tue, 13 Feb 2018 17:06:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5391910075C3; Tue, 13 Feb 2018 17:06:13 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:15 +0100 Message-Id: <20180213170529.10858-42-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:14 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 41/55] qcow2: Update zero_single_l2() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia zero_single_l2() limits the number of clusters to be zeroed to the amount that fits inside an L2 table. Since we'll be loading L2 slices instead of full tables we need to update that limit. The function is renamed to zero_in_l2_slice() for clarity. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Message-id: ebc16e7e79fa6969d8975ef487d679794de4fbcc.1517840877.git.berto@i= galia.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 62336960a5..f440105f6c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1752,33 +1752,33 @@ fail: =20 /* * This zeroes as many clusters of nb_clusters as possible at once (i.e. - * all clusters in the same L2 table) and returns the number of zeroed + * all clusters in the same L2 slice) and returns the number of zeroed * clusters. */ -static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - uint64_t nb_clusters, int flags) +static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset, + uint64_t nb_clusters, int flags) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_table; + uint64_t *l2_slice; int l2_index; int ret; int i; bool unmap =3D !!(flags & BDRV_REQ_MAY_UNMAP); =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - /* Limit nb_clusters to one L2 table */ - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + /* Limit nb_clusters to one L2 slice */ + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_offset; QCow2ClusterType cluster_type; =20 - old_offset =3D be64_to_cpu(l2_table[l2_index + i]); + old_offset =3D be64_to_cpu(l2_slice[l2_index + i]); =20 /* * Minimize L2 changes if the cluster already reads back as @@ -1790,16 +1790,16 @@ static int zero_single_l2(BlockDriverState *bs, uin= t64_t offset, continue; } =20 - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { - l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { - l2_table[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); } } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return nb_clusters; } @@ -1823,13 +1823,13 @@ int qcow2_cluster_zeroize(BlockDriverState *bs, uin= t64_t offset, return -ENOTSUP; } =20 - /* Each L2 table is handled by its own loop iteration */ + /* Each L2 slice is handled by its own loop iteration */ nb_clusters =3D size_to_clusters(s, bytes); =20 s->cache_discards =3D true; =20 while (nb_clusters > 0) { - cleared =3D zero_single_l2(bs, offset, nb_clusters, flags); + cleared =3D zero_in_l2_slice(bs, offset, nb_clusters, flags); if (cleared < 0) { ret =3D cleared; goto fail; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544274599107.65097867463783; Tue, 13 Feb 2018 09:51:14 -0800 (PST) Received: from localhost ([::1]:56375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elejM-0007UZ-NU for importer@patchew.org; Tue, 13 Feb 2018 12:51:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2A-0003U3-Dc for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele27-0005gh-Lg for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:22 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50796 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele23-0005cr-95; Tue, 13 Feb 2018 12:06:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2EEFEB705; Tue, 13 Feb 2018 17:06:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E9BB10075C2; Tue, 13 Feb 2018 17:06:14 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:16 +0100 Message-Id: <20180213170529.10858-43-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:14 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 42/55] qcow2: Prepare qcow2_update_snapshot_refcount() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Adding support for L2 slices to qcow2_update_snapshot_refcount() needs (among other things) an extra loop that iterates over all slices of each L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 8ffaa5e55bd51121f80e498f4045b64902a94293.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 144 +++++++++++++++++++++++++--------------------= ---- 1 file changed, 75 insertions(+), 69 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9df380d52c..dfa28301c4 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1236,90 +1236,96 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void**) &l2_table); - if (ret < 0) { - goto fail; - } + { + ret =3D qcow2_cache_get(bs, s->l2_table_cache, + l2_offset, + (void **) &l2_table); + if (ret < 0) { + goto fail; + } =20 - for (j =3D 0; j < s->l2_size; j++) { - uint64_t cluster_index; - uint64_t offset; - - entry =3D be64_to_cpu(l2_table[j]); - old_entry =3D entry; - entry &=3D ~QCOW_OFLAG_COPIED; - offset =3D entry & L2E_OFFSET_MASK; - - switch (qcow2_get_cluster_type(entry)) { - case QCOW2_CLUSTER_COMPRESSED: - nb_csectors =3D ((entry >> s->csize_shift) & - s->csize_mask) + 1; - if (addend !=3D 0) { - ret =3D update_refcount(bs, - (entry & s->cluster_offset_mask) & ~511, + for (j =3D 0; j < s->l2_size; j++) { + uint64_t cluster_index; + uint64_t offset; + + entry =3D be64_to_cpu(l2_table[j]); + old_entry =3D entry; + entry &=3D ~QCOW_OFLAG_COPIED; + offset =3D entry & L2E_OFFSET_MASK; + + switch (qcow2_get_cluster_type(entry)) { + case QCOW2_CLUSTER_COMPRESSED: + nb_csectors =3D ((entry >> s->csize_shift) & + s->csize_mask) + 1; + if (addend !=3D 0) { + ret =3D update_refcount( + bs, (entry & s->cluster_offset_mask) & ~51= 1, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); - if (ret < 0) { + if (ret < 0) { + goto fail; + } + } + /* compressed clusters are never modified */ + refcount =3D 2; + break; + + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_ZERO_ALLOC: + if (offset_into_cluster(s, offset)) { + qcow2_signal_corruption( + bs, true, -1, -1, "Cluster " + "allocation offset %#" PRIx64 + " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", + offset, l2_offset, j); + ret =3D -EIO; goto fail; } - } - /* compressed clusters are never modified */ - refcount =3D 2; - break; - - case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_ZERO_ALLOC: - if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, "Cluster= " - "allocation offset %#" PRI= x64 - " unaligned (L2 offset: %#" - PRIx64 ", L2 index: %#x)", - offset, l2_offset, j); - ret =3D -EIO; - goto fail; - } =20 - cluster_index =3D offset >> s->cluster_bits; - assert(cluster_index); - if (addend !=3D 0) { - ret =3D qcow2_update_cluster_refcount(bs, - cluster_index, abs(addend), addend < 0, - QCOW2_DISCARD_SNAPSHOT); + cluster_index =3D offset >> s->cluster_bits; + assert(cluster_index); + if (addend !=3D 0) { + ret =3D qcow2_update_cluster_refcount( + bs, cluster_index, abs(addend), addend < 0, + QCOW2_DISCARD_SNAPSHOT); + if (ret < 0) { + goto fail; + } + } + + ret =3D qcow2_get_refcount(bs, cluster_index, &ref= count); if (ret < 0) { goto fail; } - } + break; =20 - ret =3D qcow2_get_refcount(bs, cluster_index, &refcoun= t); - if (ret < 0) { - goto fail; - } - break; - - case QCOW2_CLUSTER_ZERO_PLAIN: - case QCOW2_CLUSTER_UNALLOCATED: - refcount =3D 0; - break; + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_UNALLOCATED: + refcount =3D 0; + break; =20 - default: - abort(); - } + default: + abort(); + } =20 - if (refcount =3D=3D 1) { - entry |=3D QCOW_OFLAG_COPIED; - } - if (entry !=3D old_entry) { - if (addend > 0) { - qcow2_cache_set_dependency(bs, s->l2_table_cache, - s->refcount_block_cache); + if (refcount =3D=3D 1) { + entry |=3D QCOW_OFLAG_COPIED; + } + if (entry !=3D old_entry) { + if (addend > 0) { + qcow2_cache_set_dependency(bs, s->l2_table_cac= he, + s->refcount_block_c= ache); + } + l2_table[j] =3D cpu_to_be64(entry); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, + l2_table); } - l2_table[j] =3D cpu_to_be64(entry); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); } - } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + + } =20 if (addend !=3D 0) { ret =3D qcow2_update_cluster_refcount(bs, l2_offset >> --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544350854835.5787199198958; Tue, 13 Feb 2018 09:52:30 -0800 (PST) Received: from localhost ([::1]:56382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elekn-0000Dk-Ul for importer@patchew.org; Tue, 13 Feb 2018 12:52:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2B-0003Vu-6E for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele29-0005iR-HV for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:23 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41066 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele24-0005dT-69; Tue, 13 Feb 2018 12:06:16 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD7E780125D6; Tue, 13 Feb 2018 17:06:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29E4510073CD; Tue, 13 Feb 2018 17:06:15 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:17 +0100 Message-Id: <20180213170529.10858-44-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:06:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:06:15 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 43/55] qcow2: Update qcow2_update_snapshot_refcount() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia qcow2_update_snapshot_refcount() increases the refcount of all clusters of a given snapshot. In order to do that it needs to load all its L2 tables and iterate over their entries. Since we'll be loading L2 slices instead of full tables we need to add an extra loop that iterates over all slices of each L2 table. This function doesn't need any additional changes so apart from that this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Message-id: 5f4db199b9637f4833b58487135124d70add8cf0.1517840877.git.berto@i= galia.com Reviewed-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index dfa28301c4..d46b69d7f3 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1183,17 +1183,20 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l1_table, *l2_table, l2_offset, entry, l1_size2, refcount; + uint64_t *l1_table, *l2_slice, l2_offset, entry, l1_size2, refcount; bool l1_allocated =3D false; int64_t old_entry, old_l2_offset; + unsigned slice, slice_size2, n_slices; int i, j, l1_modified =3D 0, nb_csectors; int ret; =20 assert(addend >=3D -1 && addend <=3D 1); =20 - l2_table =3D NULL; + l2_slice =3D NULL; l1_table =3D NULL; l1_size2 =3D l1_size * sizeof(uint64_t); + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; =20 s->cache_discards =3D true; =20 @@ -1236,19 +1239,19 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - { + for (slice =3D 0; slice < n_slices; slice++) { ret =3D qcow2_cache_get(bs, s->l2_table_cache, - l2_offset, - (void **) &l2_table); + l2_offset + slice * slice_size2, + (void **) &l2_slice); if (ret < 0) { goto fail; } =20 - for (j =3D 0; j < s->l2_size; j++) { + for (j =3D 0; j < s->l2_slice_size; j++) { uint64_t cluster_index; uint64_t offset; =20 - entry =3D be64_to_cpu(l2_table[j]); + entry =3D be64_to_cpu(l2_slice[j]); old_entry =3D entry; entry &=3D ~QCOW_OFLAG_COPIED; offset =3D entry & L2E_OFFSET_MASK; @@ -1273,12 +1276,14 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, case QCOW2_CLUSTER_NORMAL: case QCOW2_CLUSTER_ZERO_ALLOC: if (offset_into_cluster(s, offset)) { + /* Here l2_index means table (not slice) index= */ + int l2_index =3D slice * s->l2_slice_size + j; qcow2_signal_corruption( bs, true, -1, -1, "Cluster " "allocation offset %#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", - offset, l2_offset, j); + offset, l2_offset, l2_index); ret =3D -EIO; goto fail; } @@ -1317,14 +1322,13 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, qcow2_cache_set_dependency(bs, s->l2_table_cac= he, s->refcount_block_c= ache); } - l2_table[j] =3D cpu_to_be64(entry); + l2_slice[j] =3D cpu_to_be64(entry); qcow2_cache_entry_mark_dirty(s->l2_table_cache, - l2_table); + l2_slice); } } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); - + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 if (addend !=3D 0) { @@ -1352,8 +1356,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, =20 ret =3D bdrv_flush(bs); fail: - if (l2_table) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + if (l2_slice) { + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 s->cache_discards =3D false; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544533058528.399325044469; Tue, 13 Feb 2018 09:55:33 -0800 (PST) Received: from localhost ([::1]:56399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elenk-00031q-7W for importer@patchew.org; Tue, 13 Feb 2018 12:55:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2C-0003X5-8Q for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2A-0005jp-Nj for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:24 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50798 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele25-0005eP-55; Tue, 13 Feb 2018 12:06:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8B8AEB705; Tue, 13 Feb 2018 17:06:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14BCF10073CD; Tue, 13 Feb 2018 17:06:15 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:18 +0100 Message-Id: <20180213170529.10858-45-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:16 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 44/55] qcow2: Read refcount before L2 table in expand_zero_clusters_in_l1() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia At the moment it doesn't really make a difference whether we call qcow2_get_refcount() before of after reading the L2 table, but if we want to support L2 slices we'll need to read the refcount first. This patch simply changes the order of those two operations to prepare for that. The patch with the actual semantic changes will be easier to read because of this. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 947a91d934053a2dbfef979aeb9568f57ef57c5d.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f440105f6c..1041dcb6dd 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1898,6 +1898,12 @@ static int expand_zero_clusters_in_l1(BlockDriverSta= te *bs, uint64_t *l1_table, goto fail; } =20 + ret =3D qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, + &l2_refcount); + if (ret < 0) { + goto fail; + } + if (is_active_l1) { /* get active L2 tables from cache */ ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, @@ -1911,12 +1917,6 @@ static int expand_zero_clusters_in_l1(BlockDriverSta= te *bs, uint64_t *l1_table, goto fail; } =20 - ret =3D qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, - &l2_refcount); - if (ret < 0) { - goto fail; - } - for (j =3D 0; j < s->l2_size; j++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544865769916.4478155938275; Tue, 13 Feb 2018 10:01:05 -0800 (PST) Received: from localhost ([::1]:56747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elet6-0007yD-S5 for importer@patchew.org; Tue, 13 Feb 2018 13:01:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2H-0003ad-O7 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2E-0005nO-4a for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:28 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41068 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele26-0005f8-0k; Tue, 13 Feb 2018 12:06:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A38C18163C60; Tue, 13 Feb 2018 17:06:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3E9C10073CD; Tue, 13 Feb 2018 17:06:16 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:19 +0100 Message-Id: <20180213170529.10858-46-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:06:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 13 Feb 2018 17:06:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 45/55] qcow2: Prepare expand_zero_clusters_in_l1() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Adding support for L2 slices to expand_zero_clusters_in_l1() needs (among other things) an extra loop that iterates over all slices of each L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: c2ae9f31ed5b6e591477ad4654448badd1c89d73.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 187 ++++++++++++++++++++++++++--------------------= ---- 1 file changed, 96 insertions(+), 91 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 1041dcb6dd..ccb2944eda 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1904,118 +1904,123 @@ static int expand_zero_clusters_in_l1(BlockDriver= State *bs, uint64_t *l1_table, goto fail; } =20 - if (is_active_l1) { - /* get active L2 tables from cache */ - ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void **)&l2_table); - } else { - /* load inactive L2 tables from disk */ - ret =3D bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); - } - if (ret < 0) { - goto fail; - } - - for (j =3D 0; j < s->l2_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); - int64_t offset =3D l2_entry & L2E_OFFSET_MASK; - QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); - - if (cluster_type !=3D QCOW2_CLUSTER_ZERO_PLAIN && - cluster_type !=3D QCOW2_CLUSTER_ZERO_ALLOC) { - continue; + { + if (is_active_l1) { + /* get active L2 tables from cache */ + ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, + (void **)&l2_table); + } else { + /* load inactive L2 tables from disk */ + ret =3D bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, + (void *)l2_table, s->cluster_sectors); + } + if (ret < 0) { + goto fail; } =20 - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - if (!bs->backing) { - /* not backed; therefore we can simply deallocate the - * cluster */ - l2_table[j] =3D 0; - l2_dirty =3D true; + for (j =3D 0; j < s->l2_size; j++) { + uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); + int64_t offset =3D l2_entry & L2E_OFFSET_MASK; + QCow2ClusterType cluster_type =3D + qcow2_get_cluster_type(l2_entry); + + if (cluster_type !=3D QCOW2_CLUSTER_ZERO_PLAIN && + cluster_type !=3D QCOW2_CLUSTER_ZERO_ALLOC) { continue; } =20 - offset =3D qcow2_alloc_clusters(bs, s->cluster_size); - if (offset < 0) { - ret =3D offset; - goto fail; - } + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + if (!bs->backing) { + /* not backed; therefore we can simply deallocate = the + * cluster */ + l2_table[j] =3D 0; + l2_dirty =3D true; + continue; + } + + offset =3D qcow2_alloc_clusters(bs, s->cluster_size); + if (offset < 0) { + ret =3D offset; + goto fail; + } =20 - if (l2_refcount > 1) { - /* For shared L2 tables, set the refcount accordingly = (it is - * already 1 and needs to be l2_refcount) */ - ret =3D qcow2_update_cluster_refcount(bs, - offset >> s->cluster_bits, + if (l2_refcount > 1) { + /* For shared L2 tables, set the refcount accordin= gly + * (it is already 1 and needs to be l2_refcount) */ + ret =3D qcow2_update_cluster_refcount( + bs, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); - if (ret < 0) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_OTHER); - goto fail; + if (ret < 0) { + qcow2_free_clusters(bs, offset, s->cluster_siz= e, + QCOW2_DISCARD_OTHER); + goto fail; + } } } - } =20 - if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, - "Cluster allocation offset " - "%#" PRIx64 " unaligned (L2 offset= : %#" - PRIx64 ", L2 index: %#x)", offset, - l2_offset, j); - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + if (offset_into_cluster(s, offset)) { + qcow2_signal_corruption( + bs, true, -1, -1, + "Cluster allocation offset " + "%#" PRIx64 " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", offset, + l2_offset, j); + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + qcow2_free_clusters(bs, offset, s->cluster_size, + QCOW2_DISCARD_ALWAYS); + } + ret =3D -EIO; + goto fail; } - ret =3D -EIO; - goto fail; - } =20 - ret =3D qcow2_pre_write_overlap_check(bs, 0, offset, s->cluste= r_size); - if (ret < 0) { - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + ret =3D qcow2_pre_write_overlap_check(bs, 0, offset, + s->cluster_size); + if (ret < 0) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + qcow2_free_clusters(bs, offset, s->cluster_size, + QCOW2_DISCARD_ALWAYS); + } + goto fail; } - goto fail; - } =20 - ret =3D bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, = 0); - if (ret < 0) { - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + ret =3D bdrv_pwrite_zeroes(bs->file, offset, s->cluster_si= ze, 0); + if (ret < 0) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + qcow2_free_clusters(bs, offset, s->cluster_size, + QCOW2_DISCARD_ALWAYS); + } + goto fail; } - goto fail; - } =20 - if (l2_refcount =3D=3D 1) { - l2_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED); - } else { - l2_table[j] =3D cpu_to_be64(offset); + if (l2_refcount =3D=3D 1) { + l2_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + } else { + l2_table[j] =3D cpu_to_be64(offset); + } + l2_dirty =3D true; } - l2_dirty =3D true; - } =20 - if (is_active_l1) { - if (l2_dirty) { - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); - qcow2_cache_depends_on_flush(s->l2_table_cache); - } - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); - } else { - if (l2_dirty) { - ret =3D qcow2_pre_write_overlap_check(bs, - QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offs= et, - s->cluster_size); - if (ret < 0) { - goto fail; + if (is_active_l1) { + if (l2_dirty) { + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); + qcow2_cache_depends_on_flush(s->l2_table_cache); } + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + } else { + if (l2_dirty) { + ret =3D qcow2_pre_write_overlap_check( + bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, + l2_offset, s->cluster_size); + if (ret < 0) { + goto fail; + } =20 - ret =3D bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); - if (ret < 0) { - goto fail; + ret =3D bdrv_write(bs->file, l2_offset / BDRV_SECTOR_S= IZE, + (void *)l2_table, s->cluster_sectors); + if (ret < 0) { + goto fail; + } } } } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518545264726594.8205129457277; Tue, 13 Feb 2018 10:07:44 -0800 (PST) Received: from localhost ([::1]:57435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elezM-0005By-PN for importer@patchew.org; Tue, 13 Feb 2018 13:07:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2D-0003ZQ-Ow for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2B-0005kq-EK for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:25 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50800 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele26-0005fo-Uw; Tue, 13 Feb 2018 12:06:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EEFFEB700; Tue, 13 Feb 2018 17:06:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEEA810075C2; Tue, 13 Feb 2018 17:06:17 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:20 +0100 Message-Id: <20180213170529.10858-47-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:18 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 46/55] qcow2: Update expand_zero_clusters_in_l1() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia expand_zero_clusters_in_l1() expands zero clusters as a necessary step to downgrade qcow2 images to a version that doesn't support metadata zero clusters. This function takes an L1 table (which may or may not be active) and iterates over all its L2 tables looking for zero clusters. Since we'll be loading L2 slices instead of full tables we need to add an extra loop that iterates over all slices of each L2 table, and we should also use the slice size when allocating the buffer used when the L1 table is not active. This function doesn't need any additional changes so apart from that this patch simply updates the variable name from l2_table to l2_slice. Finally, and since we have to touch the bdrv_read() / bdrv_write() calls anyway, this patch takes the opportunity to replace them with the byte-based bdrv_pread() / bdrv_pwrite(). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 43590976f730501688096cff103f2923b72b0f32.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 51 ++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ccb2944eda..8fbaba008b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1863,22 +1863,25 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, { BDRVQcow2State *s =3D bs->opaque; bool is_active_l1 =3D (l1_table =3D=3D s->l1_table); - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; + unsigned slice, slice_size2, n_slices; int ret; int i, j; =20 + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; + if (!is_active_l1) { /* inactive L2 tables require a buffer to be stored in when loading * them from disk */ - l2_table =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); - if (l2_table =3D=3D NULL) { + l2_slice =3D qemu_try_blockalign(bs->file->bs, slice_size2); + if (l2_slice =3D=3D NULL) { return -ENOMEM; } } =20 for (i =3D 0; i < l1_size; i++) { uint64_t l2_offset =3D l1_table[i] & L1E_OFFSET_MASK; - bool l2_dirty =3D false; uint64_t l2_refcount; =20 if (!l2_offset) { @@ -1904,22 +1907,23 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, goto fail; } =20 - { + for (slice =3D 0; slice < n_slices; slice++) { + uint64_t slice_offset =3D l2_offset + slice * slice_size2; + bool l2_dirty =3D false; if (is_active_l1) { /* get active L2 tables from cache */ - ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void **)&l2_table); + ret =3D qcow2_cache_get(bs, s->l2_table_cache, slice_offse= t, + (void **)&l2_slice); } else { /* load inactive L2 tables from disk */ - ret =3D bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); + ret =3D bdrv_pread(bs->file, slice_offset, l2_slice, slice= _size2); } if (ret < 0) { goto fail; } =20 - for (j =3D 0; j < s->l2_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); + for (j =3D 0; j < s->l2_slice_size; j++) { + uint64_t l2_entry =3D be64_to_cpu(l2_slice[j]); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_entry); @@ -1933,7 +1937,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, if (!bs->backing) { /* not backed; therefore we can simply deallocate = the * cluster */ - l2_table[j] =3D 0; + l2_slice[j] =3D 0; l2_dirty =3D true; continue; } @@ -1960,12 +1964,13 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, } =20 if (offset_into_cluster(s, offset)) { + int l2_index =3D slice * s->l2_slice_size + j; qcow2_signal_corruption( bs, true, -1, -1, "Cluster allocation offset " "%#" PRIx64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, - l2_offset, j); + l2_offset, l2_index); if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); @@ -1994,30 +1999,30 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, } =20 if (l2_refcount =3D=3D 1) { - l2_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + l2_slice[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); } else { - l2_table[j] =3D cpu_to_be64(offset); + l2_slice[j] =3D cpu_to_be64(offset); } l2_dirty =3D true; } =20 if (is_active_l1) { if (l2_dirty) { - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_sli= ce); qcow2_cache_depends_on_flush(s->l2_table_cache); } - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } else { if (l2_dirty) { ret =3D qcow2_pre_write_overlap_check( bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, - l2_offset, s->cluster_size); + slice_offset, slice_size2); if (ret < 0) { goto fail; } =20 - ret =3D bdrv_write(bs->file, l2_offset / BDRV_SECTOR_S= IZE, - (void *)l2_table, s->cluster_sectors); + ret =3D bdrv_pwrite(bs->file, slice_offset, + l2_slice, slice_size2); if (ret < 0) { goto fail; } @@ -2034,11 +2039,11 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, ret =3D 0; =20 fail: - if (l2_table) { + if (l2_slice) { if (!is_active_l1) { - qemu_vfree(l2_table); + qemu_vfree(l2_slice); } else { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } } return ret; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544082234167.99698068858027; Tue, 13 Feb 2018 09:48:02 -0800 (PST) Received: from localhost ([::1]:56343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elegT-0004hH-Cm for importer@patchew.org; Tue, 13 Feb 2018 12:48:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2D-0003Yu-Fb for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2B-0005kl-De for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:25 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37842 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele27-0005gU-T7; Tue, 13 Feb 2018 12:06:19 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A0A8402291E; Tue, 13 Feb 2018 17:06:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9DF910073CD; Tue, 13 Feb 2018 17:06:18 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:21 +0100 Message-Id: <20180213170529.10858-48-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 47/55] qcow2: Update qcow2_truncate() to support L2 slices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The qcow2_truncate() code is mostly independent from whether we're using L2 slices or full L2 tables, but in full and falloc preallocation modes new L2 tables are allocated using qcow2_alloc_cluster_link_l2(). Therefore the code needs to be modified to ensure that all nb_clusters that are processed in each call can be allocated with just one L2 slice. Signed-off-by: Alberto Garcia Message-id: 1fd7d272b5e7b66254a090b74cf2bed1cc334c0e.1517840877.git.berto@i= galia.com Reviewed-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block/qcow2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ba8d71c72d..953254a004 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3262,9 +3262,9 @@ static int qcow2_truncate(BlockDriverState *bs, int64= _t offset, host_offset =3D allocation_start; guest_offset =3D old_length; while (nb_new_data_clusters) { - int64_t guest_cluster =3D guest_offset >> s->cluster_bits; - int64_t nb_clusters =3D MIN(nb_new_data_clusters, - s->l2_size - guest_cluster % s->l2_s= ize); + int64_t nb_clusters =3D MIN( + nb_new_data_clusters, + s->l2_slice_size - offset_to_l2_slice_index(s, guest_offse= t)); QCowL2Meta allocation =3D { .offset =3D guest_offset, .alloc_offset =3D host_offset, --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518545035150494.3739211221267; Tue, 13 Feb 2018 10:03:55 -0800 (PST) Received: from localhost ([::1]:56790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elevo-0001fZ-9x for importer@patchew.org; Tue, 13 Feb 2018 13:03:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2E-0003Zv-5u for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2C-0005lj-FN for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:26 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51200 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele28-0005hH-QP; Tue, 13 Feb 2018 12:06:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64BE87CBB2; Tue, 13 Feb 2018 17:06:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4F5110073CD; Tue, 13 Feb 2018 17:06:19 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:22 +0100 Message-Id: <20180213170529.10858-49-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:20 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 48/55] qcow2: Rename l2_table in qcow2_alloc_compressed_cluster_offset() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function doesn't need any changes to support L2 slices, but since it's now dealing with slices instead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 0c5d4b9bf163aa3b49ec19cc512a50d83563f2ad.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 8fbaba008b..24055e19a1 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -747,26 +747,26 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockD= riverState *bs, { BDRVQcow2State *s =3D bs->opaque; int l2_index, ret; - uint64_t *l2_table; + uint64_t *l2_slice; int64_t cluster_offset; int nb_csectors; =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return 0; } =20 /* Compression can't overwrite anything. Fail if the cluster was alrea= dy * allocated. */ - cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); if (cluster_offset & L2E_OFFSET_MASK) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return 0; } =20 cluster_offset =3D qcow2_alloc_bytes(bs, compressed_size); if (cluster_offset < 0) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return 0; } =20 @@ -781,9 +781,9 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, /* compressed clusters never have the copied flag */ =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); - l2_table[l2_index] =3D cpu_to_be64(cluster_offset); - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + l2_slice[l2_index] =3D cpu_to_be64(cluster_offset); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return cluster_offset; } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544736203679.5408530691778; Tue, 13 Feb 2018 09:58:56 -0800 (PST) Received: from localhost ([::1]:56459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eler1-0005iz-9y for importer@patchew.org; Tue, 13 Feb 2018 12:58:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2H-0003ae-O8 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2D-0005mZ-Bw for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:28 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50802 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele29-0005iL-Mf; Tue, 13 Feb 2018 12:06:21 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50311EAE91; Tue, 13 Feb 2018 17:06:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id A05B310073CD; Tue, 13 Feb 2018 17:06:20 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:23 +0100 Message-Id: <20180213170529.10858-50-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:21 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 49/55] qcow2: Rename l2_table in count_contiguous_clusters() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 812b0c3505bb1687e51285dccf1a94f0cecb1f74.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 24055e19a1..54ae210b43 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -370,19 +370,19 @@ fail: } =20 /* - * Checks how many clusters in a given L2 table are contiguous in the image + * Checks how many clusters in a given L2 slice are contiguous in the image * file. As soon as one of the flags in the bitmask stop_flags changes com= pared * to the first cluster, the search is stopped and the cluster is not coun= ted * as contiguous. (This allows it, for example, to stop at the first compr= essed * cluster which may require a different handling) */ static int count_contiguous_clusters(int nb_clusters, int cluster_size, - uint64_t *l2_table, uint64_t stop_flags) + uint64_t *l2_slice, uint64_t stop_flags) { int i; QCow2ClusterType first_cluster_type; uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; - uint64_t first_entry =3D be64_to_cpu(l2_table[0]); + uint64_t first_entry =3D be64_to_cpu(l2_slice[0]); uint64_t offset =3D first_entry & mask; =20 if (!offset) { @@ -395,7 +395,7 @@ static int count_contiguous_clusters(int nb_clusters, i= nt cluster_size, first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC); =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[i]) & mask; + uint64_t l2_entry =3D be64_to_cpu(l2_slice[i]) & mask; if (offset + (uint64_t) i * cluster_size !=3D l2_entry) { break; } --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15185454876931004.96115232188; Tue, 13 Feb 2018 10:11:27 -0800 (PST) Received: from localhost ([::1]:57983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elf36-0000i6-KD for importer@patchew.org; Tue, 13 Feb 2018 13:11:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2J-0003d3-5r for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2I-0005qY-6R for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56620 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2A-0005jO-K9; Tue, 13 Feb 2018 12:06:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ACAA40FB645; Tue, 13 Feb 2018 17:06:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B68810075C2; Tue, 13 Feb 2018 17:06:21 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:24 +0100 Message-Id: <20180213170529.10858-51-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 50/55] qcow2: Rename l2_table in count_contiguous_clusters_unallocated() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function doesn't need any changes to support L2 slices, but since it's now dealing with slices instead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 78bcc54bc632574dd0b900a77a00a1b6ffc359e6.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 54ae210b43..074a4aaf1e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -406,10 +406,10 @@ static int count_contiguous_clusters(int nb_clusters,= int cluster_size, =20 /* * Checks how many consecutive unallocated clusters in a given L2 - * table have the same cluster type. + * slice have the same cluster type. */ static int count_contiguous_clusters_unallocated(int nb_clusters, - uint64_t *l2_table, + uint64_t *l2_slice, QCow2ClusterType wanted_t= ype) { int i; @@ -417,7 +417,7 @@ static int count_contiguous_clusters_unallocated(int nb= _clusters, assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { - uint64_t entry =3D be64_to_cpu(l2_table[i]); + uint64_t entry =3D be64_to_cpu(l2_slice[i]); QCow2ClusterType type =3D qcow2_get_cluster_type(entry); =20 if (type !=3D wanted_type) { --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544270624859.6792795495705; Tue, 13 Feb 2018 09:51:10 -0800 (PST) Received: from localhost ([::1]:56378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elejV-0007ZQ-PV for importer@patchew.org; Tue, 13 Feb 2018 12:51:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2J-0003e5-Q7 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2I-0005qj-DY for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:31 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50806 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2B-0005kg-J2; Tue, 13 Feb 2018 12:06:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26F4EEAE91; Tue, 13 Feb 2018 17:06:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 768F510073CD; Tue, 13 Feb 2018 17:06:22 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:25 +0100 Message-Id: <20180213170529.10858-52-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:23 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 51/55] qcow2: Rename l2_table in count_cow_clusters() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 6107001fc79e6739242f1de7d191375e4f130aac.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 074a4aaf1e..e406b0f3b9 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -999,12 +999,12 @@ err: * which must copy from the backing file) */ static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, - uint64_t *l2_table, int l2_index) + uint64_t *l2_slice, int l2_index) { int i; =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); + uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_entry); =20 switch(cluster_type) { --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15185457902531011.8137361339822; Tue, 13 Feb 2018 10:16:30 -0800 (PST) Received: from localhost ([::1]:59351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elf81-0006Of-8n for importer@patchew.org; Tue, 13 Feb 2018 13:16:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2O-0003kI-Ds for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2J-0005sP-Lv for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56622 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2C-0005lV-Hu; Tue, 13 Feb 2018 12:06:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 116DC40FB646; Tue, 13 Feb 2018 17:06:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61F7710073CD; Tue, 13 Feb 2018 17:06:23 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:26 +0100 Message-Id: <20180213170529.10858-53-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 17:06:24 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 52/55] qcow2: Allow configuring the L2 slice size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Now that the code is ready to handle L2 slices we can finally add an option to allow configuring their size. An L2 slice is the portion of an L2 table that is read by the qcow2 cache. Until now the cache was always reading full L2 tables, and since the L2 table size is equal to the cluster size this was not very efficient with large clusters. Here's a more detailed explanation of why it makes sense to have smaller cache entries in order to load L2 data: https://lists.gnu.org/archive/html/qemu-block/2017-09/msg00635.html This patch introduces a new command-line option to the qcow2 driver named l2-cache-entry-size (cf. l2-cache-size). The cache entry size has the same restrictions as the cluster size: it must be a power of two and it has the same range of allowed values, with the additional requirement that it must not be larger than the cluster size. The L2 cache entry size (L2 slice size) remains equal to the cluster size for now by default, so this feature must be explicitly enabled. Although my tests show that 4KB slices consistently improve performance and give the best results, let's wait and make more tests with different cluster sizes before deciding on an optimal default. Now that the cache entry size is not necessarily equal to the cluster size we need to reflect that in the MIN_L2_CACHE_SIZE documentation. That minimum value is a requirement of the COW algorithm: we need to read two L2 slices (and not two L2 tables) in order to do COW, see l2_allocate() for the actual code. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: c73e5611ff4a9ec5d20de68a6c289553a13d2354.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- qapi/block-core.json | 6 ++++++ block/qcow2.h | 6 ++++-- block/qcow2-cache.c | 10 ++++++++-- block/qcow2.c | 34 +++++++++++++++++++++++++++------- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 2c107823fe..5c5921bfb7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2521,6 +2521,11 @@ # @l2-cache-size: the maximum size of the L2 table cache in # bytes (since 2.2) # +# @l2-cache-entry-size: the size of each entry in the L2 cache in +# bytes. It must be a power of two between 512 +# and the cluster size. The default value is +# the cluster size (since 2.12) +# # @refcount-cache-size: the maximum size of the refcount block cache # in bytes (since 2.2) # @@ -2542,6 +2547,7 @@ '*overlap-check': 'Qcow2OverlapChecks', '*cache-size': 'int', '*l2-cache-size': 'int', + '*l2-cache-entry-size': 'int', '*refcount-cache-size': 'int', '*cache-clean-interval': 'int', '*encrypt': 'BlockdevQcow2Encryption' } } diff --git a/block/qcow2.h b/block/qcow2.h index d956a6cdd2..883802241f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -68,7 +68,7 @@ #define MAX_CLUSTER_BITS 21 =20 /* Must be at least 2 to cover COW */ -#define MIN_L2_CACHE_SIZE 2 /* clusters */ +#define MIN_L2_CACHE_SIZE 2 /* cache entries */ =20 /* Must be at least 4 to cover all cases of refcount table growth */ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ @@ -100,6 +100,7 @@ #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2" #define QCOW2_OPT_CACHE_SIZE "cache-size" #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size" +#define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size" #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" #define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" =20 @@ -647,7 +648,8 @@ void qcow2_free_snapshots(BlockDriverState *bs); int qcow2_read_snapshots(BlockDriverState *bs); =20 /* qcow2-cache.c functions */ -Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); +Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables, + unsigned table_size); int qcow2_cache_destroy(Qcow2Cache *c); =20 void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index b1aa42477e..d9dafa31e5 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -120,14 +120,20 @@ void qcow2_cache_clean_unused(Qcow2Cache *c) c->cache_clean_lru_counter =3D c->lru_counter; } =20 -Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) +Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables, + unsigned table_size) { BDRVQcow2State *s =3D bs->opaque; Qcow2Cache *c; =20 + assert(num_tables > 0); + assert(is_power_of_2(table_size)); + assert(table_size >=3D (1 << MIN_CLUSTER_BITS)); + assert(table_size <=3D s->cluster_size); + c =3D g_new0(Qcow2Cache, 1); c->size =3D num_tables; - c->table_size =3D s->cluster_size; + c->table_size =3D table_size; c->entries =3D g_try_new0(Qcow2CachedTable, num_tables); c->table_array =3D qemu_try_blockalign(bs->file->bs, (size_t) num_tables * c->table_si= ze); diff --git a/block/qcow2.c b/block/qcow2.c index 953254a004..57a517e2bd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -676,6 +676,11 @@ static QemuOptsList qcow2_runtime_opts =3D { .help =3D "Maximum L2 table cache size", }, { + .name =3D QCOW2_OPT_L2_CACHE_ENTRY_SIZE, + .type =3D QEMU_OPT_SIZE, + .help =3D "Size of each entry in the L2 cache", + }, + { .name =3D QCOW2_OPT_REFCOUNT_CACHE_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "Maximum refcount block cache size", @@ -747,6 +752,7 @@ static void qcow2_attach_aio_context(BlockDriverState *= bs, =20 static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, + uint64_t *l2_cache_entry_size, uint64_t *refcount_cache_size, Error **errp) { BDRVQcow2State *s =3D bs->opaque; @@ -762,6 +768,9 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, *refcount_cache_size =3D qemu_opt_get_size(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE= , 0); =20 + *l2_cache_entry_size =3D qemu_opt_get_size( + opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); + if (combined_cache_size_set) { if (l2_cache_size_set && refcount_cache_size_set) { error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_= SIZE @@ -802,6 +811,15 @@ static void read_cache_sizes(BlockDriverState *bs, Qem= uOpts *opts, / DEFAULT_L2_REFCOUNT_SIZE_RATIO; } } + + if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) || + *l2_cache_entry_size > s->cluster_size || + !is_power_of_2(*l2_cache_entry_size)) { + error_setg(errp, "L2 cache entry size must be a power of two " + "between %d and the cluster size (%d)", + 1 << MIN_CLUSTER_BITS, s->cluster_size); + return; + } } =20 typedef struct Qcow2ReopenState { @@ -824,7 +842,7 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, QemuOpts *opts =3D NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template =3D 0; - uint64_t l2_cache_size, refcount_cache_size; + uint64_t l2_cache_size, l2_cache_entry_size, refcount_cache_size; int i; const char *encryptfmt; QDict *encryptopts =3D NULL; @@ -843,15 +861,15 @@ static int qcow2_update_options_prepare(BlockDriverSt= ate *bs, } =20 /* get L2 table/refcount block cache size from command line options */ - read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, - &local_err); + read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, + &refcount_cache_size, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -EINVAL; goto fail; } =20 - l2_cache_size /=3D s->cluster_size; + l2_cache_size /=3D l2_cache_entry_size; if (l2_cache_size < MIN_L2_CACHE_SIZE) { l2_cache_size =3D MIN_L2_CACHE_SIZE; } @@ -889,9 +907,11 @@ static int qcow2_update_options_prepare(BlockDriverSta= te *bs, } } =20 - r->l2_slice_size =3D s->cluster_size / sizeof(uint64_t); - r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size); - r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size= ); + r->l2_slice_size =3D l2_cache_entry_size / sizeof(uint64_t); + r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size, + l2_cache_entry_size); + r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size, + s->cluster_size); if (r->l2_table_cache =3D=3D NULL || r->refcount_block_cache =3D=3D NU= LL) { error_setg(errp, "Could not allocate metadata caches"); ret =3D -ENOMEM; --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518545089155941.5297075580395; Tue, 13 Feb 2018 10:04:49 -0800 (PST) Received: from localhost ([::1]:56809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elewi-0002Ta-8O for importer@patchew.org; Tue, 13 Feb 2018 13:04:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2P-0003li-Bp for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2M-0005ur-6q for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:37 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51202 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2D-0005mN-Ez; Tue, 13 Feb 2018 12:06:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3BC37CBB2; Tue, 13 Feb 2018 17:06:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CB6110073CD; Tue, 13 Feb 2018 17:06:24 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:27 +0100 Message-Id: <20180213170529.10858-54-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:25 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 53/55] iotests: Test valid values of l2-cache-entry-size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia The l2-cache-entry-size setting can only contain values that are powers of two between 512 and the cluster size. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: bd3547b670b8d0af11480c760991a22bcae5b48c.1517840877.git.berto@i= galia.com [mreitz: Changed non-power-of-two test value from 300 to 4242] Signed-off-by: Max Reitz --- tests/qemu-iotests/103 | 17 +++++++++++++++++ tests/qemu-iotests/103.out | 3 +++ 2 files changed, 20 insertions(+) diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103 index d0cfab8844..2841318492 100755 --- a/tests/qemu-iotests/103 +++ b/tests/qemu-iotests/103 @@ -66,6 +66,14 @@ $QEMU_IO -c "open -o cache-size=3D1M,refcount-cache-size= =3D2M $TEST_IMG" 2>&1 \ $QEMU_IO -c "open -o cache-size=3D0,l2-cache-size=3D0,refcount-cache-size= =3D0 $TEST_IMG" \ 2>&1 | _filter_testdir | _filter_imgfmt =20 +# Invalid cache entry sizes +$QEMU_IO -c "open -o l2-cache-entry-size=3D256 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D4242 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D128k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt + echo echo '=3D=3D=3D Testing valid option combinations =3D=3D=3D' echo @@ -94,6 +102,15 @@ $QEMU_IO -c "open -o l2-cache-size=3D1M,refcount-cache-= size=3D0.25M $TEST_IMG" \ -c 'read -P 42 0 64k' \ | _filter_qemu_io =20 +# Valid cache entry sizes +$QEMU_IO -c "open -o l2-cache-entry-size=3D512 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D16k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D64k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt + + echo echo '=3D=3D=3D Testing minimal L2 cache and COW =3D=3D=3D' echo diff --git a/tests/qemu-iotests/103.out b/tests/qemu-iotests/103.out index b7aaadf89a..bd45d3875a 100644 --- a/tests/qemu-iotests/103.out +++ b/tests/qemu-iotests/103.out @@ -9,6 +9,9 @@ can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-s= ize and refcount-cach can't open device TEST_DIR/t.IMGFMT: l2-cache-size may not exceed cache-si= ze can't open device TEST_DIR/t.IMGFMT: refcount-cache-size may not exceed ca= che-size can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcoun= t-cache-size may not be set the same time +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) =20 =3D=3D=3D Testing valid option combinations =3D=3D=3D =20 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518544447785694.0486591099776; Tue, 13 Feb 2018 09:54:07 -0800 (PST) Received: from localhost ([::1]:56395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elemM-0001cT-Vy for importer@patchew.org; Tue, 13 Feb 2018 12:54:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2K-0003fU-Q7 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2J-0005rx-99 for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51204 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2E-0005nJ-Cb; Tue, 13 Feb 2018 12:06:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC5647CBB2; Tue, 13 Feb 2018 17:06:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3905B10075C2; Tue, 13 Feb 2018 17:06:25 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:28 +0100 Message-Id: <20180213170529.10858-55-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 13 Feb 2018 17:06:25 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 54/55] iotests: Test downgrading an image using a small L2 slice size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia expand_zero_clusters_in_l1() is used when downgrading qcow2 images from v3 to v2 (compat=3D0.10). This is one of the functions that needed more changes to support L2 slices, so this patch extends iotest 061 to test downgrading a qcow2 image using a smaller slice size. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 3e5662dce5e4926c8fabbad4c0b9142b2a506dd4.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- tests/qemu-iotests/061 | 16 ++++++++++++ tests/qemu-iotests/061.out | 61 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 77 insertions(+) diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index f5678b10c9..911b6f2894 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -54,6 +54,22 @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qem= u_io _check_test_img =20 echo +echo "=3D=3D=3D Testing version downgrade with zero expansion and 4K cache= entries =3D=3D=3D" +echo +IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M +$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io +$PYTHON qcow2.py "$TEST_IMG" dump-header +$QEMU_IMG amend -o "compat=3D0.10" --image-opts \ + driver=3Dqcow2,file.filename=3D$TEST_IMG,l2-cache-entry-size=3D4= 096 +$PYTHON qcow2.py "$TEST_IMG" dump-header +$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io +_check_test_img + +echo echo "=3D=3D=3D Testing dirty version downgrade =3D=3D=3D" echo IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 942485de99..e857ef9a7d 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -52,6 +52,67 @@ read 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. =20 +=3D=3D=3D Testing version downgrade with zero expansion and 4K cache entri= es =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +wrote 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 33554432 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +128 KiB (0x20000) bytes allocated at offset 0 bytes (0x0) +31.875 MiB (0x1fe0000) bytes not allocated at offset 128 KiB (0x20000) +128 KiB (0x20000) bytes allocated at offset 32 MiB (0x2000000) +31.875 MiB (0x1fe0000) bytes not allocated at offset 32.125 MiB (0x2020000) +magic 0x514649fb +version 3 +backing_file_offset 0x0 +backing_file_size 0x0 +cluster_bits 16 +size 67108864 +crypt_method 0 +l1_size 1 +l1_table_offset 0x30000 +refcount_table_offset 0x10000 +refcount_table_clusters 1 +nb_snapshots 0 +snapshot_offset 0x0 +incompatible_features 0x0 +compatible_features 0x1 +autoclear_features 0x0 +refcount_order 4 +header_length 104 + +Header extension: +magic 0x6803f857 +length 144 +data + +magic 0x514649fb +version 2 +backing_file_offset 0x0 +backing_file_size 0x0 +cluster_bits 16 +size 67108864 +crypt_method 0 +l1_size 1 +l1_table_offset 0x30000 +refcount_table_offset 0x10000 +refcount_table_clusters 1 +nb_snapshots 0 +snapshot_offset 0x0 +incompatible_features 0x0 +compatible_features 0x0 +autoclear_features 0x0 +refcount_order 4 +header_length 72 + +read 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 33554432 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 MiB (0x4000000) bytes not allocated at offset 0 bytes (0x0) +No errors were found on the image. + =3D=3D=3D Testing dirty version downgrade =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 --=20 2.13.6 From nobody Sat May 4 00:59:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151854465327999.46663556971066; Tue, 13 Feb 2018 09:57:33 -0800 (PST) Received: from localhost ([::1]:56454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elepg-0004fG-CP for importer@patchew.org; Tue, 13 Feb 2018 12:57:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele2K-0003eh-5q for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele2J-0005rl-7r for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50812 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele2F-0005o4-7J; Tue, 13 Feb 2018 12:06:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7652EAE91; Tue, 13 Feb 2018 17:06:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23F7310073CD; Tue, 13 Feb 2018 17:06:26 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:29 +0100 Message-Id: <20180213170529.10858-56-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:26 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 55/55] iotests: Add l2-cache-entry-size to iotest 137 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This test tries reopening a qcow2 image with valid and invalid options. This patch adds l2-cache-entry-size to the set. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 3d3b7d2dbfc020deaef60fb58739b0801eb9517c.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- tests/qemu-iotests/137 | 5 +++++ tests/qemu-iotests/137.out | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 5a01250005..87965625d8 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -83,6 +83,9 @@ $QEMU_IO \ -c "reopen -o overlap-check.inactive-l2=3Doff" \ -c "reopen -o cache-size=3D1M" \ -c "reopen -o l2-cache-size=3D512k" \ + -c "reopen -o l2-cache-entry-size=3D512" \ + -c "reopen -o l2-cache-entry-size=3D4k" \ + -c "reopen -o l2-cache-entry-size=3D64k" \ -c "reopen -o refcount-cache-size=3D128k" \ -c "reopen -o cache-clean-interval=3D5" \ -c "reopen -o cache-clean-interval=3D0" \ @@ -107,6 +110,8 @@ $QEMU_IO \ -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ -c "reopen -o l2-cache-size=3D256T" \ + -c "reopen -o l2-cache-entry-size=3D33k" \ + -c "reopen -o l2-cache-entry-size=3D128k" \ -c "reopen -o refcount-cache-size=3D256T" \ -c "reopen -o overlap-check=3Dconstant,overlap-check.template=3Dall" \ -c "reopen -o overlap-check=3Dblubb" \ diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out index 05efd74d17..e28e1eadba 100644 --- a/tests/qemu-iotests/137.out +++ b/tests/qemu-iotests/137.out @@ -20,6 +20,8 @@ cache-size, l2-cache-size and refcount-cache-size may not= be set the same time l2-cache-size may not exceed cache-size refcount-cache-size may not exceed cache-size L2 cache size too big +L2 cache entry size must be a power of two between 512 and the cluster siz= e (65536) +L2 cache entry size must be a power of two between 512 and the cluster siz= e (65536) L2 cache size too big Conflicting values for qcow2 options 'overlap-check' ('constant') and 'ove= rlap-check.template' ('all') Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are an= y of the following: none, constant, cached, all --=20 2.13.6