From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com, jcody@redhat.com,
stefanha@redhat.com, qemu-block@nongnu.org,
qemu-stable@nongnu.org, Fam Zheng <famz@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 4/5] block: Perform copy-on-read in loop
Date: Thu, 5 Oct 2017 16:55:47 +0200 [thread overview]
Message-ID: <20171005145547.GB4416@localhost.localdomain> (raw)
In-Reply-To: <20171004014347.25099-5-eblake@redhat.com>
Am 04.10.2017 um 03:43 hat Eric Blake geschrieben:
> Improve our braindead copy-on-read implementation. Pre-patch,
> we have multiple issues:
> - we create a bounce buffer and perform a write for the entire
> request, even if the active image already has 99% of the
> clusters occupied, and really only needs to copy-on-read the
> remaining 1% of the clusters
> - our bounce buffer was as large as the read request, and can
> needlessly exhaust our memory by using double the memory of
> the request size (the original request plus our bounce buffer),
> rather than a capped maximum overhead beyond the original
> - if a driver has a max_transfer limit, we are bypassing the
> normal code in bdrv_aligned_preadv() that fragments to that
> limit, and instead attempt to read the entire buffer from the
> driver in one go, which some drivers may assert on
> - a client can request a large request of nearly 2G such that
> rounding the request out to cluster boundaries results in a
> byte count larger than 2G. While this cannot exceed 32 bits,
> it DOES have some follow-on problems:
> -- the call to bdrv_driver_pread() can assert for exceeding
> BDRV_REQUEST_MAX_BYTES, if the driver is old and lacks
> .bdrv_co_preadv
> -- if the buffer is all zeroes, the subsequent call to
> bdrv_co_do_pwrite_zeroes is a no-op due to a negative size,
> which means we did not actually copy on read
>
> Fix all of these issues by breaking up the action into a loop,
> where each iteration is capped to sane limits. Also, querying
> the allocation status allows us to optimize: when data is
> already present in the active layer, we don't need to bounce.
>
> Note that the code has a telling comment that copy-on-read
> should probably be a filter driver rather than a bolt-in hack
> in io.c; but that remains a task for another day.
>
> CC: qemu-stable@nongnu.org
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> ---
> v2: avoid uninit ret on 0-length op [patchew, Kevin]
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
next prev parent reply other threads:[~2017-10-05 14:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 1:43 [Qemu-devel] [PATCH v2 0/5] block: Avoid copy-on-read assertions Eric Blake
2017-10-04 1:43 ` [Qemu-devel] [PATCH v2 1/5] qemu-io: Add -C for opening with copy-on-read Eric Blake
2017-10-04 1:43 ` [Qemu-devel] [PATCH v2 2/5] block: Uniform handling of 0-length bdrv_get_block_status() Eric Blake
2017-10-05 14:35 ` Stefan Hajnoczi
2017-10-05 14:41 ` Eric Blake
2017-10-04 1:43 ` [Qemu-devel] [PATCH v2 3/5] block: Add blkdebug hook for copy-on-read Eric Blake
2017-10-04 1:43 ` [Qemu-devel] [PATCH v2 4/5] block: Perform copy-on-read in loop Eric Blake
2017-10-05 14:55 ` Kevin Wolf [this message]
2017-10-05 15:36 ` Stefan Hajnoczi
2017-10-04 1:43 ` [Qemu-devel] [PATCH v2 5/5] iotests: Add test 197 for covering copy-on-read Eric Blake
2017-10-05 14:41 ` Stefan Hajnoczi
2017-10-05 14:44 ` Eric Blake
2017-10-05 14:47 ` Eric Blake
2017-10-04 2:16 ` [Qemu-devel] [PATCH v2 0/5] block: Avoid copy-on-read assertions no-reply
2017-10-04 2:22 ` Eric Blake
2017-10-04 5:39 ` Fam Zheng
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=20171005145547.GB4416@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.