From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block/raw-posix: Fall back to SEEK_HOLE/SEEK_DATA
Date: Tue, 06 May 2014 19:46:56 +0200 [thread overview]
Message-ID: <53692010.1000302@redhat.com> (raw)
In-Reply-To: <5368D518.9000007@redhat.com>
On 06.05.2014 14:27, Eric Blake wrote:
> On 05/06/2014 05:49 AM, Stefan Hajnoczi wrote:
>> On Mon, May 05, 2014 at 10:01:39PM +0200, Max Reitz wrote:
>>> The current version of raw-posix always uses ioctl(FS_IOC_FIEMAP) if
>>> FIEMAP is available; lseek with SEEK_HOLE/SEEK_DATA are not even
>>> compiled in in this case. However, there may be implementations which
>>> support the latter but not the former (e.g., NFSv4.2). In this case,
>>> raw-posix should fall back to lseek with SEEK_HOLE/SEEK_DATA if FIEMAP
>>> does not work.
>>>
>> A bigger cleanup is extracting the FIEMAP and SEEK_HOLE/SEEK_DATA
>> implementations into their own static functions. Then
>> raw_co_get_block_status() becomes simpler and doesn't need ifdefs:
>>
>> ret = try_fiemap(...);
>> if (ret < 0) {
>> ret = try_seekhole(...);
>> }
>> if (ret < 0) {
>> ...report every block allocated by default....
>> }
>>
>> In other words, let normal C control flow describe the relationships
>> between these code paths. Use ifdef only to nop out try_fiemap() and
>> try_seekhole().
>>
>> What do you think?
> I like the idea - separating control flow from #ifdefs (by having stubs
> on the other end of the ifdef) definitely makes algorithms easier to
> understand.
>
> More things to consider: GNU Coreutils has support for both fiemap and
> seek_hole, but favors seek_hole first, for a couple reasons. First,
> FIEMAP has not always been reliable: on some older kernel/filesystem
> pairs, fiemap could return stale results, which led cp(1) to cause data
> loss unless it did an fsync() first to get the fiemap to be stable - but
> the cost of the fsync() made the operation slower than if fiemap were
> never used. Second, POSIX will be standardizing seek_hole in its next
> revision [1] (still several years out, but the fact that it is an
> announced intention means people are starting to implement it now).
> fiemap, on the other hand, remains a Linux-only extension. Yes, fiemap
> provides more details than seek_hole (and is the ONLY way to know the
> difference between a hole that has reserved space on the disk vs a hole
> that will require allocation if is written to), but if all you need to
> know is whether a hole exists (rather than what type of hole), then
> seek_hole is MUCH simpler.
>
> [1] http://austingroupbugs.net/view.php?id=415
Okay, then I'll put the functionality in own functions and reverse the
order in v2 while keeping the fallback idea, as I think there may exist
systems where the reverse of what this patch tries to fix is true:
SEEK_HOLE/SEEK_DATA is not supported, but FIEMAP is.
Max
next prev parent reply other threads:[~2014-05-06 17:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 20:01 [Qemu-devel] [PATCH] block/raw-posix: Fall back to SEEK_HOLE/SEEK_DATA Max Reitz
2014-05-06 11:49 ` Stefan Hajnoczi
2014-05-06 12:27 ` Eric Blake
2014-05-06 17:46 ` Max Reitz [this message]
2014-05-06 17:55 ` Eric Blake
2014-05-06 17:45 ` 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=53692010.1000302@redhat.com \
--to=mreitz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@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.