qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@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, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block
Date: Mon, 26 Aug 2019 08:46:21 -0500	[thread overview]
Message-ID: <65085dba-f180-8a4e-8464-65e91323b69b@redhat.com> (raw)
In-Reply-To: <20190825220329.7942-2-nsoffer@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1518 bytes --]

On 8/25/19 5:03 PM, 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.
> 

> 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.

Nice justification.


> +/*
> + * Help alignment probing by allocating the first block.
> + *

> +    do {
> +        n = pwrite(fd, buf, write_size, 0);
> +    } while (n == -1 && errno == EINTR);
> +
> +    qemu_vfree(buf);

qemu_vfree() can corrupt errno...

> +
> +    return (n == -1) ? -errno : 0;

...which means you may be returning an unexpected value here.

Either we should patch qemu_vfree() to guarantee that errno is
preserved, or you locally capture errno before calling it here.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-08-26 13:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-25 22:03 [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing Nir Soffer
2019-08-25 22:03 ` [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block Nir Soffer
2019-08-26 12:31   ` Max Reitz
2019-08-26 13:49     ` Eric Blake
2019-08-26 15:23       ` Nir Soffer
2019-08-26 15:41     ` Nir Soffer
2019-08-26 16:20       ` Max Reitz
2019-08-26 13:46   ` Eric Blake [this message]
2019-08-26 15:19     ` Nir Soffer
2019-08-25 22:03 ` [Qemu-devel] [PATCH v2 2/2] iotests: Test allocate_first_block() with O_DIRECT Nir Soffer
2019-08-25 22:41   ` Nir Soffer
2019-08-26 12:38   ` Max Reitz
2019-08-25 22:19 ` [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing no-reply

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=65085dba-f180-8a4e-8464-65e91323b69b@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).