From: Jeff Cody <jcody@redhat.com>
To: qemu-block@nongnu.org
Cc: peter.maydell@linaro.org, jcody@redhat.com,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: [Qemu-devel] [PULL 12/12] block/gluster: glfs_lseek() workaround
Date: Fri, 26 May 2017 15:24:04 -0400 [thread overview]
Message-ID: <20170526192404.32186-13-jcody@redhat.com> (raw)
In-Reply-To: <20170526192404.32186-1-jcody@redhat.com>
On current released versions of glusterfs, glfs_lseek() will sometimes
return invalid values for SEEK_DATA or SEEK_HOLE. For SEEK_DATA and
SEEK_HOLE, the returned value should be >= the passed offset, or < 0 in
the case of error:
LSEEK(2):
off_t lseek(int fd, off_t offset, int whence);
[...]
SEEK_HOLE
Adjust the file offset to the next hole in the file greater
than or equal to offset. If offset points into the middle of
a hole, then the file offset is set to offset. If there is no
hole past offset, then the file offset is adjusted to the end
of the file (i.e., there is an implicit hole at the end of
any file).
[...]
RETURN VALUE
Upon successful completion, lseek() returns the resulting
offset location as measured in bytes from the beginning of the
file. On error, the value (off_t) -1 is returned and errno is
set to indicate the error
However, occasionally glfs_lseek() for SEEK_HOLE/DATA will return a
value less than the passed offset, yet greater than zero.
For instance, here are example values observed from this call:
offs = glfs_lseek(s->fd, start, SEEK_HOLE);
if (offs < 0) {
return -errno; /* D1 and (H3 or H4) */
}
start == 7608336384
offs == 7607877632
This causes QEMU to abort on the assert test. When this value is
returned, errno is also 0.
This is a reported and known bug to glusterfs:
https://bugzilla.redhat.com/show_bug.cgi?id=1425293
Although this is being fixed in gluster, we still should work around it
in QEMU, given that multiple released versions of gluster behave this
way.
This patch treats the return case of (offs < start) the same as if an
error value other than ENXIO is returned; we will assume we learned
nothing, and there are no holes in the file.
Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Message-id: 87c0140e9407c08f6e74b04131b610f2e27c014c.1495560397.git.jcody@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
block/gluster.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index 7c76cd0..8ba3bcc 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1275,7 +1275,14 @@ static int find_allocation(BlockDriverState *bs, off_t start,
if (offs < 0) {
return -errno; /* D3 or D4 */
}
- assert(offs >= start);
+
+ if (offs < start) {
+ /* This is not a valid return by lseek(). We are safe to just return
+ * -EIO in this case, and we'll treat it like D4. Unfortunately some
+ * versions of gluster server will return offs < start, so an assert
+ * here will unnecessarily abort QEMU. */
+ return -EIO;
+ }
if (offs > start) {
/* D2: in hole, next data at offs */
@@ -1307,7 +1314,14 @@ static int find_allocation(BlockDriverState *bs, off_t start,
if (offs < 0) {
return -errno; /* D1 and (H3 or H4) */
}
- assert(offs >= start);
+
+ if (offs < start) {
+ /* This is not a valid return by lseek(). We are safe to just return
+ * -EIO in this case, and we'll treat it like H4. Unfortunately some
+ * versions of gluster server will return offs < start, so an assert
+ * here will unnecessarily abort QEMU. */
+ return -EIO;
+ }
if (offs > start) {
/*
--
2.9.3
next prev parent reply other threads:[~2017-05-26 19:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 19:23 [Qemu-devel] [PULL 00/12] Block patches Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 01/12] blockjob: remove unnecessary check Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 02/12] blockjob: remove iostatus_reset callback Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 03/12] blockjob: introduce block_job_early_fail Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 04/12] blockjob: introduce block_job_pause/resume_all Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 05/12] blockjob: separate monitor and blockjob APIs Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 06/12] blockjob: move iostatus reset inside block_job_user_resume Jeff Cody
2017-05-26 19:23 ` [Qemu-devel] [PULL 07/12] blockjob: introduce block_job_cancel_async, check iostatus invariants Jeff Cody
2017-05-26 19:24 ` [Qemu-devel] [PULL 08/12] blockjob: group BlockJob transaction functions together Jeff Cody
2017-05-26 19:24 ` [Qemu-devel] [PULL 09/12] blockjob: strengthen a bit test-blockjob-txn Jeff Cody
2017-05-26 19:24 ` [Qemu-devel] [PULL 10/12] blockjob: reorganize block_job_completed_txn_abort Jeff Cody
2017-05-26 19:24 ` [Qemu-devel] [PULL 11/12] blockjob: use deferred_to_main_loop to indicate the coroutine has ended Jeff Cody
2017-05-26 19:24 ` Jeff Cody [this message]
2017-05-30 9:25 ` [Qemu-devel] [Qemu-block] [PULL 00/12] Block patches Stefan Hajnoczi
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=20170526192404.32186-13-jcody@redhat.com \
--to=jcody@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--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 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).