From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
tony@bakeyournoodle.com, stefanha@redhat.com,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/2] raw-posix: SEEK_HOLE suffices, get rid of FIEMAP
Date: Thu, 13 Nov 2014 13:00:22 +0100 [thread overview]
Message-ID: <20141113120022.GC3933@noname.redhat.com> (raw)
In-Reply-To: <546499F6.4050201@redhat.com>
Am 13.11.2014 um 12:45 hat Max Reitz geschrieben:
> On 2014-11-13 at 12:40, Kevin Wolf wrote:
> >Am 13.11.2014 um 00:25 hat Eric Blake geschrieben:
> >>On 11/12/2014 01:27 PM, Markus Armbruster wrote:
> >>>+ /* in hole, end not yet known */
> >>>+ offs = lseek(s->fd, start, SEEK_DATA);
> >>>+ if (offs < 0) {
> >>>+ /* no idea where the hole ends, give up (unlikely to happen) */
> >>>+ goto dunno;
> >>>+ }
> >>>+ assert(offs >= start);
> >>>+ *hole = start;
> >>>+ *data = offs;
> >>This assertion feels like an off-by-one. The same offset cannot be both
> >>a hole and data (except in some racy situation where some other process
> >>is writing data to that offset in between our two lseek calls, but
> >>that's already in no-man's land because no one else should be writing
> >>the file while qemu has it open). Is it worth using 'assert(offs >
> >>start)' instead?
> >As soon as you say "except", it's wrong to assert this at all. We can't
> >guarantee that the condition is true and it's not a programming error
> >in qemu if it's false. Sounds to me as if it should be a normal error
> >check rather than an assertion.
> >
> >Also, what happens after EOF? I haven't read the patch yet, maybe it
> >handles the situation already earlier, but if it doesn't, won't we get
> >offset == start then?
>
> raw_co_get_block_status() already bails out if start is at or beyond EOF.
Okay, so that's basically the same "except" as above.
Except that the window for the race is much larger because the
raw_co_get_block_status() check uses the cached value, so any file size
change in the background after qemu has opened the image would trigger
an assertion failure.
Kevin
next prev parent reply other threads:[~2014-11-13 12:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-12 19:27 [Qemu-devel] [PATCH 0/2] raw-posix: Get rid of FIEMAP Markus Armbruster
2014-11-12 19:27 ` [Qemu-devel] [PATCH 1/2] raw-posix: Fix comment for raw_co_get_block_status() Markus Armbruster
2014-11-12 23:18 ` Eric Blake
2014-11-13 1:46 ` Fam Zheng
2014-11-13 8:39 ` Max Reitz
2014-11-12 19:27 ` [Qemu-devel] [PATCH 2/2] raw-posix: SEEK_HOLE suffices, get rid of FIEMAP Markus Armbruster
2014-11-12 23:25 ` Eric Blake
2014-11-13 8:53 ` Markus Armbruster
2014-11-13 11:40 ` Kevin Wolf
2014-11-13 11:45 ` Max Reitz
2014-11-13 12:00 ` Kevin Wolf [this message]
2014-11-13 12:05 ` Max Reitz
2014-11-13 12:38 ` Markus Armbruster
2014-11-13 13:10 ` Kevin Wolf
2014-11-13 2:21 ` Fam Zheng
2014-11-13 8:26 ` Markus Armbruster
2014-11-13 8:39 ` Max Reitz
2014-11-13 9:25 ` Markus Armbruster
2014-11-12 22:14 ` [Qemu-devel] [PATCH 0/2] raw-posix: Get " Paolo Bonzini
2014-11-13 8:53 ` Markus Armbruster
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=20141113120022.GC3933@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=tony@bakeyournoodle.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).