From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vky9C-00038G-62 for qemu-devel@nongnu.org; Mon, 25 Nov 2013 10:32:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vky92-0001Q5-KD for qemu-devel@nongnu.org; Mon, 25 Nov 2013 10:32:26 -0500 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:40888 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vky92-0001Ph-9g for qemu-devel@nongnu.org; Mon, 25 Nov 2013 10:32:16 -0500 Message-ID: <52936D8C.50709@kamp.de> Date: Mon, 25 Nov 2013 16:32:28 +0100 From: Peter Lieven MIME-Version: 1.0 References: <1385387840-17307-1-git-send-email-pl@kamp.de> <1385387840-17307-6-git-send-email-pl@kamp.de> <529368A8.8050807@redhat.com> In-Reply-To: <529368A8.8050807@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1.8 5/6] qemu-img: add option to align writes to cluster_sectors during convert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 25.11.2013 16:11, Paolo Bonzini wrote: > Il 25/11/2013 14:57, Peter Lieven ha scritto: >> Signed-off-by: Peter Lieven > Ok, given this patch I think the cluster_size is the right one to use > here---and also the way you used the optimal unmap granularity makes > sense; you could also use MAX(optimal unmap granularity, optimal > transfer length granularity). > > However, there is no need to write one cluster at a time. What matters, > I think, is to align the *end* of the transfer, so that the next > transfer can start aligned. > >> + if (align && cluster_sectors > 0) { >> + int64_t next_aligned_sector = (sector_num + cluster_sectors); > So this should be "+ n", not "+ cluster_sectors". > > Perhaps it could be conditional on "n > cluster_sectors" (small requests > happen when you have sparse region, and breaking them doesn't help). > > Finally, I believe there is no need for a separate "-a" knob. > > The patch looks fine to me with these small changes, though. > > Also, a couple of ideas for separate patches. Perhaps the default value > of "-S" could be cluster_size if specified? This would avoid making raw > images too fragmented, and compounding filesystem-level fragmentation > with qcow2-level fragmentation. And 4K is too small a default in my > opinion; it could be easily changed to 64K, though 4K was of course an > improvement compared to 512 before commit a22f123 (qemu-img: Require > larger zero areas for sparse handling, 2011-08-26). I would vote for 64K or 256K, we already use the first for some time. However, it turned out that (much) bigger values decrease performance. Setting it to cluster_size can be dangerous. As described in my case its 15MB and I think for vhd its 1MB. This can be a lot of zeros that have to be written. Peter > > Paolo > >> + next_aligned_sector -= next_aligned_sector % cluster_sectors; >> + if (sector_num + n > next_aligned_sector) { >> + n = next_aligned_sector - sector_num; >> + } >> + } >> + >> if (n > bs_offset + bs_sectors - sector_num) { >> n = bs_offset + bs_sectors - sector_num; >> } >> diff --git a/qemu-img.texi b/qemu-img.texi >> index 87f9d0f..9b1720f 100644 >> --- a/qemu-img.texi >> +++ b/qemu-img.texi >> @@ -179,11 +179,14 @@ Error on reading data >> >> @end table >> >> -@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] [-m @var{iobuf_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} >> +@item convert [-c] [-p] [-n] [-a] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] [-m @var{iobuf_size}] @var{filename} [@var{filename2} [...]] @var{output_filename} >> >> Convert the disk image @var{filename} or a snapshot @var{snapshot_name} to disk image @var{output_filename} >> using format @var{output_fmt}. It can be optionally compressed (@code{-c} >> option) or use any format specific options like encryption (@code{-o} option). >> +If the @code{-a} option is specified write requests will be aligned >> +to the cluster size of the output image if possible. This is the default >> +for compressed images. >> >> Only the formats @code{qcow} and @code{qcow2} support compression. The >> compression is read-only. It means that if a compressed sector is >> -- Mit freundlichen Grüßen Peter Lieven ........................................................... KAMP Netzwerkdienste GmbH Vestische Str. 89-91 | 46117 Oberhausen Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40 pl@kamp.de | http://www.kamp.de Geschäftsführer: Heiner Lante | Michael Lante Amtsgericht Duisburg | HRB Nr. 12154 USt-Id-Nr.: DE 120607556 ...........................................................