From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] file-posix: Cache next hole
Date: Fri, 12 Feb 2021 10:25:12 +0100 [thread overview]
Message-ID: <176f890a-5df5-2e68-c29c-b22d312bf977@redhat.com> (raw)
In-Reply-To: <f86be907-ddc3-9629-1179-ccf585c013ae@redhat.com>
On 11.02.21 21:00, Eric Blake wrote:
> On 2/11/21 11:22 AM, Max Reitz wrote:
>> We have repeatedly received reports that SEEK_HOLE and SEEK_DATA are
>> slow on certain filesystems and/or under certain circumstances. That is
>> why we generally try to avoid it (which is why bdrv_co_block_status()
>> has the @want_zero parameter, and which is why qcow2 has a metadata
>> preallocation detection, so we do not fall through to the protocol layer
>> to discover which blocks are zero, unless that is really necessary
>> (i.e., for metadata-preallocated images)).
>>
>> In addition to those measures, we can also try to speed up zero
>> detection by letting file-posix cache some hole location information,
>> namely where the next hole after the most recently queried offset is.
>> This helps especially for images that are (nearly) fully allocated,
>> which is coincidentally also the case where querying for zero
>> information cannot gain us much.
>>
>> Note that this of course only works so long as we have no concurrent
>> writers to the image, which is the case when the WRITE capability is not
>> shared.
>>
>> Alternatively (or perhaps as an improvement in the future), we could let
>> file-posix keep track of what it knows is zero and what it knows is
>> non-zero with bitmaps, which would help images that actually have a
>> significant number of holes (where this implementation here cannot do
>> much). But for such images, SEEK_HOLE/DATA are generally faster (they
>> do not need to seek through the whole file), and the performance lost by
>> querying the block status does not feel as bad because it is outweighed
>> by the performance that can be saved by special-cases zeroed areas, so
>> focussing on images that are (nearly) fully allocated is more important.
>
> focusing
Wiktionary lists both as valid. *shrug*
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> block/file-posix.c | 81 +++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 80 insertions(+), 1 deletion(-)
>>
>
>> static int find_allocation(BlockDriverState *bs, off_t start,
>> off_t *data, off_t *hole)
>> {
>> -#if defined SEEK_HOLE && defined SEEK_DATA
>> BDRVRawState *s = bs->opaque;
>> +
>> + if (s->next_zero_offset_valid) {
>> + if (start >= s->next_zero_offset_from && start < s->next_zero_offset) {
>> + *data = start;
>> + *hole = s->next_zero_offset;
>> + return 0;
>> + }
>> + }
>> +
>> +#if defined SEEK_HOLE && defined SEEK_DATA
>
> Why move the #if? If SEEK_HOLE is not defined, s->next_zero_offset_valid
> should never be set, because we'll treat the entire image as data. But
> at the same time, it doesn't hurt, so doesn't stop my review.
I found it better to put it outside the SEEK_HOLE/DATA section, because
while it won’t work when neither are defined, the code is still valid.
I don’t know. :)
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks!
Max
next prev parent reply other threads:[~2021-02-12 9:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 17:22 [PATCH 0/2] file-posix: Cache next hole Max Reitz
2021-02-11 17:22 ` [PATCH 1/2] block/mirror: Fix mirror_top's permissions Max Reitz
2021-02-11 19:33 ` Eric Blake
2021-02-12 9:04 ` Vladimir Sementsov-Ogievskiy
2021-02-12 9:23 ` Max Reitz
2021-02-12 10:48 ` Vladimir Sementsov-Ogievskiy
2021-02-11 17:22 ` [PATCH 2/2] file-posix: Cache next hole Max Reitz
2021-02-11 20:00 ` Eric Blake
2021-02-12 9:25 ` Max Reitz [this message]
2021-02-11 20:38 ` Vladimir Sementsov-Ogievskiy
2021-02-12 9:14 ` Max Reitz
2021-02-12 10:25 ` Kevin Wolf
2021-02-12 12:11 ` Max Reitz
2021-03-29 16:21 ` [PATCH 0/2] " 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=176f890a-5df5-2e68-c29c-b22d312bf977@redhat.com \
--to=mreitz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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 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).