* [Qemu-devel] [PATCH] block/raw-posix: fix launching with failed disks
@ 2015-03-04 22:48 Stefan Hajnoczi
2015-03-05 12:53 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-03-04 22:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, hare, Stefan Hajnoczi
Since commit c25f53b06eba1575d5d0e92a0132455c97825b83 ("raw: Probe
required direct I/O alignment") QEMU has failed to launch if image files
produce I/O errors.
Previously, QEMU would launch successfully and the guest would see the
errors when attempting I/O.
This is a regression and may prevent multipath I/O inside the guest,
where QEMU must launch and let the guest figure out by itself which
disks are online.
Tweak the alignment probing code in raw-posix.c to explicitly look for
EINVAL on Linux instead of bailing. The kernel refuses misaligned
requests with this error code and other error codes can be ignored.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/raw-posix.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index b5f077a..6eb3925 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -218,6 +218,31 @@ static int raw_normalize_devicepath(const char **filename)
}
#endif
+/* Check if read is allowed with given memory buffer and length.
+ *
+ * This function is used to check O_DIRECT memory buffer and request alignment.
+ */
+static bool raw_is_io_aligned(int fd, void *buf, size_t len)
+{
+ ssize_t ret = pread(fd, buf, len, 0);
+
+ if (ret >= 0) {
+ return true;
+ }
+
+#ifdef __linux__
+ /* The Linux kernel returns EINVAL for misaligned O_DIRECT reads. Ignore
+ * other errors (e.g. real I/O error), which could happen on a failed
+ * drive, since we only care about probing alignment.
+ */
+ if (errno != EINVAL) {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
{
BDRVRawState *s = bs->opaque;
@@ -267,7 +292,7 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
size_t align;
buf = qemu_memalign(MAX_BLOCKSIZE, 2 * MAX_BLOCKSIZE);
for (align = 512; align <= MAX_BLOCKSIZE; align <<= 1) {
- if (pread(fd, buf + align, MAX_BLOCKSIZE, 0) >= 0) {
+ if (raw_is_io_aligned(fd, buf + align, MAX_BLOCKSIZE)) {
s->buf_align = align;
break;
}
@@ -279,7 +304,7 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
size_t align;
buf = qemu_memalign(s->buf_align, MAX_BLOCKSIZE);
for (align = 512; align <= MAX_BLOCKSIZE; align <<= 1) {
- if (pread(fd, buf, align, 0) >= 0) {
+ if (raw_is_io_aligned(fd, buf, align)) {
bs->request_alignment = align;
break;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block/raw-posix: fix launching with failed disks
2015-03-04 22:48 [Qemu-devel] [PATCH] block/raw-posix: fix launching with failed disks Stefan Hajnoczi
@ 2015-03-05 12:53 ` Kevin Wolf
2015-03-05 17:45 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2015-03-05 12:53 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Paolo Bonzini, qemu-devel, hare
Am 04.03.2015 um 23:48 hat Stefan Hajnoczi geschrieben:
> Since commit c25f53b06eba1575d5d0e92a0132455c97825b83 ("raw: Probe
> required direct I/O alignment") QEMU has failed to launch if image files
> produce I/O errors.
>
> Previously, QEMU would launch successfully and the guest would see the
> errors when attempting I/O.
>
> This is a regression and may prevent multipath I/O inside the guest,
> where QEMU must launch and let the guest figure out by itself which
> disks are online.
>
> Tweak the alignment probing code in raw-posix.c to explicitly look for
> EINVAL on Linux instead of bailing. The kernel refuses misaligned
> requests with this error code and other error codes can be ignored.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This seems to conflict with the geometry series. Please rebase on the
current block branch.
Also, I would be surprised if this had been working by design. It's
probably more by chance. If we want to make this a supported case, we
need to add a qemu-iotests case, as this seems to be easy to break
accidentally.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block/raw-posix: fix launching with failed disks
2015-03-05 12:53 ` Kevin Wolf
@ 2015-03-05 17:45 ` Stefan Hajnoczi
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-03-05 17:45 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Paolo Bonzini, qemu-devel, hare
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
On Thu, Mar 05, 2015 at 01:53:57PM +0100, Kevin Wolf wrote:
> Am 04.03.2015 um 23:48 hat Stefan Hajnoczi geschrieben:
> > Since commit c25f53b06eba1575d5d0e92a0132455c97825b83 ("raw: Probe
> > required direct I/O alignment") QEMU has failed to launch if image files
> > produce I/O errors.
> >
> > Previously, QEMU would launch successfully and the guest would see the
> > errors when attempting I/O.
> >
> > This is a regression and may prevent multipath I/O inside the guest,
> > where QEMU must launch and let the guest figure out by itself which
> > disks are online.
> >
> > Tweak the alignment probing code in raw-posix.c to explicitly look for
> > EINVAL on Linux instead of bailing. The kernel refuses misaligned
> > requests with this error code and other error codes can be ignored.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> This seems to conflict with the geometry series. Please rebase on the
> current block branch.
>
> Also, I would be surprised if this had been working by design. It's
> probably more by chance. If we want to make this a supported case, we
> need to add a qemu-iotests case, as this seems to be easy to break
> accidentally.
Will send v2.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-05 17:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-04 22:48 [Qemu-devel] [PATCH] block/raw-posix: fix launching with failed disks Stefan Hajnoczi
2015-03-05 12:53 ` Kevin Wolf
2015-03-05 17:45 ` Stefan Hajnoczi
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).