From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfnzJ-0003T3-Cf for qemu-devel@nongnu.org; Fri, 24 May 2013 05:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfnzE-0004vY-B4 for qemu-devel@nongnu.org; Fri, 24 May 2013 05:08:37 -0400 Received: from smtp.citrix.com ([66.165.176.89]:17349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfnzE-0004vU-5N for qemu-devel@nongnu.org; Fri, 24 May 2013 05:08:32 -0400 Date: Fri, 24 May 2013 10:08:18 +0100 From: Stefano Stabellini In-Reply-To: <33183CC9F5247A488A2544077AF190206C8FFCF4@szxeml538-mbx.china.huawei.com> Message-ID: References: <33183CC9F5247A488A2544077AF190206C8FCB9B@szxeml538-mbx.china.huawei.com> <33183CC9F5247A488A2544077AF190206C8FFCF4@szxeml538-mbx.china.huawei.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1342847746-2141807181-1369386271=:4799" Content-ID: Subject: Re: [Qemu-devel] use O_DIRECT to open disk images for IDE failed under xen-4.1.2 and qemu upstream List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: kwolf@redhat.com, Hanweidong , Stefano Stabellini , Luonengjun , "qemu-devel@nongnu.org" , "xen-devel@lists.xen.org" , Wangzhenguo , afaerber@suse.de, "Huangweidong (Hardware)" --1342847746-2141807181-1369386271=:4799 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: On Fri, 24 May 2013, Gonglei (Arei) wrote: > Hi, >=20 > >=20 > > On Thu, 23 May 2013, Gonglei (Arei) wrote: > > > Hi, all > > > > > > I use O_DIRECT to open disk images for IDE, but I'm failed. After deb= ug, I get > > the below logs: > > > [2013-05-22 23:25:46] ide: CMD=3Dc8 > > > [2013-05-22 23:25:46] bmdma: readb 0x00 : 0x08 > > > [2013-05-22 23:25:46] bmdma: writeb 0x00 : 0x09 > > > [2013-05-22 23:25:46] bmdma_cmd_writeb: 0x00000009 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:25:46] bmdma: readb 0x02 : 0x01 > > > [2013-05-22 23:26:39] bmdma: writeb 0x00 : 0x08 > > > [2013-05-22 23:26:39] bmdma_cmd_writeb: 0x00000008 > > > [2013-05-22 23:26:56] =3D=3D=3D=3D=3D=3D offset:0 buf:0x7ff100f21c00 = count:512 > > aio_offset:0 > > > [2013-05-22 23:31:30] =3D=3D=3D=3D=3D=3D offset:0 buf:0x7ff100f21c00 = count:512 > > aio_offset:0 > > > [2013-05-22 23:31:30] =3D=3D=3D=3D=3D=3D handle_aiocb_rw_linear errno= : -14 > > > [2013-05-22 23:31:30] =3D=3D=3D=3D=3D=3D paio_complete errno=3D14 > > > [2013-05-22 23:31:30] =3D=3D=3D=3D=3D=3D ide_dma_error!!! > > > [2013-05-22 23:31:30] ide: read status addr=3D0x3f6 val=3D41 > > > > > > QEMU command line : > > > qemu-system-i386 -xen-domid 837 -chardev > > socket,id=3Dlibxl-cmd,path=3D/var/run/xen/qmp-libxl-837,server,nowait -= mon > > chardev=3Dlibxl-cmd,mode=3Dcontrol -name suse11 -vnc 0.0.0.0:1 -serial = pty -boot > > order=3Dc -usb -usbdevice tablet -smp 2,maxcpus=3D2 -device > > rtl8139,id=3Dnic0,netdev=3Dnet0,mac=3D00:16:3e:13:d3:72 -netdev > > type=3Dtap,id=3Dnet0,ifname=3Dtap837.0,downscript=3Dno -M xenfv -m 2040= -drive > > file=3D/mnt/sdd/image/suse.image,if=3Dide,index=3D0,media=3Ddisk,format= =3Draw,cache > > =3Dnone > > > > > > errno 14 shows Bad Address. And I find QEMU_AIO_MISALIGNED flag bit i= s > > not set through debug. > > > > > > /* > > > * If O_DIRECT is used the buffer needs to be aligned on a sector > > > * boundary. Check if this is the case or tell the low-level > > > * driver that it needs to copy the buffer. > > > */ > > > if ((bs->open_flags & BDRV_O_NOCACHE)) { > > > if (!bdrv_qiov_is_aligned(bs, qiov)) { //if the address is > > aligned-512, will no meet the conditions > > > type |=3D QEMU_AIO_MISALIGNED; > > > #ifdef CONFIG_LINUX_AIO > > > } else if (s->use_aio) { > > > return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qio= v, > > > nb_sectors, cb, opaque, type); > > > #endif > > > > > > Next process: > > > static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb) > > > { > > > ssize_t nbytes; > > > char *buf; > > > > > > if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) { > > > /* > > > * If there is just a single buffer, and it is properly align= ed > > > * we can just use plain pread/pwrite without any problems. > > > */ > > > if (aiocb->aio_niov =3D=3D 1) > > > return handle_aiocb_rw_linear(aiocb, > > aiocb->aio_iov->iov_base); //this way, and reports errno 14 next > > > > > > Anyone have a good method to resolve this bug? Thanks! > >=20 > > I know that this is not the answer you are looking for but why do you > > want to use O_DIRECT with IDE? > > It should be perfectly safe to use write-back. >=20 > A few days ago, I asked a question about the IDE FLUSH time of guest=EF= =BC=9A=20 > http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg02642.html >=20 > finally I found that because Qemu use write-back flag to open disk images= by default.=20 > so I hope to use O_DIRECT to avoid meeting that problem, but I'm failed u= nder Xen platform with Qemu upstream. =20 I don't think that switching opening flags is the right way to approach this issue. Reading back your original email, it seems reasonable to me to return BSY to the guest. Probably nobody has seen this problem before because fdatasync is not usually that slow. I imagine the your bug could be reproduced by replacing the call to fdatasync with a sleep? --1342847746-2141807181-1369386271=:4799--