From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th4V1-0006GC-RS for qemu-devel@nongnu.org; Fri, 07 Dec 2012 15:26:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Th4Ux-0001EH-KC for qemu-devel@nongnu.org; Fri, 07 Dec 2012 15:26:19 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:42423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Th4Ux-0001D2-Cc for qemu-devel@nongnu.org; Fri, 07 Dec 2012 15:26:15 -0500 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Dec 2012 13:26:10 -0700 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id AD7A7C40002 for ; Fri, 7 Dec 2012 13:25:58 -0700 (MST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qB7KQ4n9131620 for ; Fri, 7 Dec 2012 13:26:04 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qB7KQ4LJ011426 for ; Fri, 7 Dec 2012 13:26:04 -0700 Message-ID: <1354911963.3635.4.camel@br8hfpp0.de.ibm.com> From: Heinz Graalfs Date: Fri, 07 Dec 2012 21:26:03 +0100 In-Reply-To: <50AC9B96.9070908@redhat.com> References: <1353488287-47077-1-git-send-email-borntraeger@de.ibm.com> <50AC9B96.9070908@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH/RFC] block: Ensure that block size constraints are considered List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Christian Borntraeger , jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org, Stefan Hajnoczi , agraf@suse.de Hello Kevin, I'm resending my answer as of Nov 23rd. Is this still on your queue? Heinz On Wed, 2012-11-21 at 10:15 +0100, Kevin Wolf wrote: > Am 21.11.2012 09:58, schrieb Christian Borntraeger: > > From: Heinz Graalfs > > > > While testing IPL code (booting) for s390x we faced some problems > > with cache=none on dasds (4k block size) on bdrv_preads with length > > values != block size. > > > > This patch makes sure that bdrv_pread and friends work fine with > > unaligned access even with cache=none > > - propagate alignment value also into bs->file struct > > - modify the size in case of no cache to avoid EINVAL on > > pread() etc. (file was opened with O_DIRECT). > > > > This patch seems to cure the problems. > > > > CC: Kevin Wolf > > CC: Stefan Hajnoczi > > Signed-off-by: Heinz Graalfs > > Signed-off-by: Christian Borntraeger > > --- > > block.c | 3 +++ > > block/raw-posix.c | 6 ++++++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/block.c b/block.c > > index 854ebd6..f23c562 100644 > > --- a/block.c > > +++ b/block.c > > @@ -4242,6 +4242,9 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, > > void bdrv_set_buffer_alignment(BlockDriverState *bs, int align) > > { > > bs->buffer_alignment = align; > > + if ((bs->open_flags & BDRV_O_NOCACHE)) { > > + bs->file->buffer_alignment = align; > > + } > > Any reason to restrict this to BDRV_O_NOCACHE? OK, can be removed > There have been patches to change the BDRV_O_NOCACHE flag from the > monitor, in which case bdrv_set_buffer_alignment() wouldn't be called > anew and O_DIRECT requests start to fail again. > > } > > > > void *qemu_blockalign(BlockDriverState *bs, size_t size) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > > index f2f0404..baebf1d 100644 > > --- a/block/raw-posix.c > > +++ b/block/raw-posix.c > > @@ -700,6 +700,12 @@ static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, > > acb->aio_nbytes = nb_sectors * 512; > > acb->aio_offset = sector_num * 512; > > > > + /* O_DIRECT also requires an aligned length */ > > + if (bs->open_flags & BDRV_O_NOCACHE) { > > + acb->aio_nbytes += acb->bs->buffer_alignment - 1; > > + acb->aio_nbytes &= ~(acb->bs->buffer_alignment - 1); > > + } > > Modifying aio_nbytes, but not the iov looks wrong to me. This may work > in the handle_aiocb_rw_linear() code path, but not with actual vectored I/O. Current coding ensures that read IO buffers always seem to be aligned correctly. Whereas read length values are not always appropriate for an O_DIRECT scenario. For a 2048 formatted disk I verified that 1. non vectored IO - the length needs to be adapted several times, which is accomplished now by the patch. 2. vectored IO - the qiov's total length is always a multiple of the logical block size (which is also verified in virtio_blk_handle_read()) The particular iov length fields are already correctly setup as a multiple of the logical block size when processed in virtio_blk_handle_request(). > > Kevin >