From: Max Reitz <mreitz@redhat.com>
To: Nir Soffer <nirsof@gmail.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Nir Soffer <nsoffer@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/2] block: posix: Always allocate the first block
Date: Tue, 27 Aug 2019 19:10:48 +0200 [thread overview]
Message-ID: <999ec4b9-7f7c-ab4f-0ee5-04a4eb9be4ad@redhat.com> (raw)
In-Reply-To: <a2073695-e146-ffa3-7707-4e1f15d309cd@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 3433 bytes --]
On 27.08.19 18:58, Max Reitz wrote:
> On 27.08.19 03:05, Nir Soffer wrote:
>> When creating an image with preallocation "off" or "falloc", the first
>> block of the image is typically not allocated. When using Gluster
>> storage backed by XFS filesystem, reading this block using direct I/O
>> succeeds regardless of request length, fooling alignment detection.
>>
>> In this case we fallback to a safe value (4096) instead of the optimal
>> value (512), which may lead to unneeded data copying when aligning
>> requests. Allocating the first block avoids the fallback.
>>
>> Since we allocate the first block even with preallocation=off, we no
>> longer create images with zero disk size:
>>
>> $ ./qemu-img create -f raw test.raw 1g
>> Formatting 'test.raw', fmt=raw size=1073741824
>>
>> $ ls -lhs test.raw
>> 4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
>>
>> And converting the image requires additional cluster:
>>
>> $ ./qemu-img measure -f raw -O qcow2 test.raw
>> required size: 458752
>> fully allocated size: 1074135040
>>
>> When using format like vmdk with multiple files per image, we allocate
>> one block per file:
>>
>> $ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
>> Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
>>
>> $ ls -lhs test*.vmdk
>> 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk
>> 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk
>> 4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk
>>
>> I did quick performance test for copying disks with qemu-img convert to
>> new raw target image to Gluster storage with sector size of 512 bytes:
>>
>> for i in $(seq 10); do
>> rm -f dst.raw
>> sleep 10
>> time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw
>> done
>>
>> Here is a table comparing the total time spent:
>>
>> Type Before(s) After(s) Diff(%)
>> ---------------------------------------
>> real 530.028 469.123 -11.4
>> user 17.204 10.768 -37.4
>> sys 17.881 7.011 -60.7
>>
>> We can see very clear improvement in CPU usage.
>>
>> Signed-off-by: Nir Soffer <nsoffer@redhat.com>
>> ---
>> block/file-posix.c | 51 +++++++++++++++++++
>> tests/qemu-iotests/059.out | 2 +-
>> tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
>> tests/qemu-iotests/150.out.raw | 12 +++++
>> tests/qemu-iotests/175 | 19 ++++---
>> tests/qemu-iotests/175.out | 8 +--
>> tests/qemu-iotests/178.out.qcow2 | 4 +-
>> tests/qemu-iotests/221.out | 12 +++--
>> tests/qemu-iotests/253.out | 12 +++--
>> 9 files changed, 99 insertions(+), 21 deletions(-)
>> rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
>> create mode 100644 tests/qemu-iotests/150.out.raw
>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
>
> Maybe it’ll break the vmdk iotests when using a non-default subformat;
> but currently running the iotests for non-default VMDK subformats is
> broken anyway, so it doesn’t matter.
(Good news, 059 really was the only issue for VMDK.)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-08-27 17:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 1:05 [Qemu-devel] [PATCH v3 0/2] Optimize alignment probing Nir Soffer
2019-08-27 1:05 ` [Qemu-devel] [PATCH v3 1/2] block: posix: Always allocate the first block Nir Soffer
2019-08-27 16:58 ` Max Reitz
2019-08-27 17:10 ` Max Reitz [this message]
2019-08-27 1:05 ` [Qemu-devel] [PATCH v3 2/2] iotests: Test allocate_first_block() with O_DIRECT Nir Soffer
2019-08-27 15:06 ` [Qemu-devel] [PATCH v3 0/2] Optimize alignment probing Nir Soffer
2019-08-27 17:00 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=999ec4b9-7f7c-ab4f-0ee5-04a4eb9be4ad@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=nirsof@gmail.com \
--cc=nsoffer@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).