From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKWDB-0002ic-NG for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:31:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKWD6-00067R-ID for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:31:45 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:59056 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKWD6-00066u-Cl for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:31:40 -0400 Date: Thu, 21 Aug 2014 19:30:51 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140821173051.GA26320@irqsave.net> References: <1408625048-21994-1-git-send-email-stefanha@redhat.com> <1408625048-21994-2-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1408625048-21994-2-git-send-email-stefanha@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] raw-posix: fix O_DIRECT short reads List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster The Thursday 21 Aug 2014 =E0 13:44:07 (+0100), Stefan Hajnoczi wrote : > The following O_DIRECT read from a <512 byte file fails: >=20 > $ truncate -s 320 test.img > $ qemu-io -n -c 'read -P 0 0 512' test.img > qemu-io: can't open device test.img: Could not read image for determi= ning its format: Invalid argument >=20 > Note that qemu-io completes successfully without the -n (O_DIRECT) > option. >=20 > This patch fixes qemu-iotests ./check -nocache -vmdk 059. >=20 > Suggested-by: Kevin Wolf > Reported-by: Markus Armbruster > Signed-off-by: Stefan Hajnoczi > --- > block/raw-posix.c | 9 +++++++++ > 1 file changed, 9 insertions(+) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 1194eb0..a48ce91 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -747,6 +747,15 @@ static ssize_t handle_aiocb_rw_linear(RawPosixAIOD= ata *aiocb, char *buf) > } > if (len =3D=3D -1 && errno =3D=3D EINTR) { > continue; > + } else if (len =3D=3D -1 && errno =3D=3D EINVAL && > + (aiocb->bs->open_flags & BDRV_O_NOCACHE) && > + !(aiocb->aio_type & QEMU_AIO_WRITE) && > + offset > 0) { > + /* O_DIRECT pread() may fail with EINVAL when offset is un= aligned > + * after a short read. Assume that O_DIRECT short reads o= nly occur > + * at EOF. Therefore this is a short read, not an I/O err= or. > + */ > + break; > } else if (len =3D=3D -1) { > offset =3D -errno; > break; > --=20 > 1.9.3 >=20 >=20 Reviewed-by: Beno=EEt Canet