From patchwork Wed Nov 21 08:58:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 200609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 212C22C008F for ; Wed, 21 Nov 2012 19:58:18 +1100 (EST) Received: from localhost ([::1]:50386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb68O-0003xk-Cb for incoming@patchwork.ozlabs.org; Wed, 21 Nov 2012 03:58:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb689-0003vL-EX for qemu-devel@nongnu.org; Wed, 21 Nov 2012 03:58:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tb683-0007Wl-B7 for qemu-devel@nongnu.org; Wed, 21 Nov 2012 03:58:01 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:59852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tb683-0007WT-1w for qemu-devel@nongnu.org; Wed, 21 Nov 2012 03:57:55 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2012 08:57:53 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Nov 2012 08:57:52 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qAL8vhOB52756640 for ; Wed, 21 Nov 2012 08:57:43 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qAL8voDd029125 for ; Wed, 21 Nov 2012 01:57:51 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qAL8vokU029119; Wed, 21 Nov 2012 01:57:50 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id B14F21224437; Wed, 21 Nov 2012 09:57:50 +0100 (CET) From: Christian Borntraeger To: qemu-devel@nongnu.org Date: Wed, 21 Nov 2012 09:58:07 +0100 Message-Id: <1353488287-47077-1-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.10.1 x-cbid: 12112108-2966-0000-0000-000005F10998 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.109 Cc: Kevin Wolf , Heinz Graalfs , agraf@suse.de, Christian Borntraeger , jfrei@linux.vnet.ibm.com, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH/RFC] block: Ensure that block size constraints are considered X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; + } } 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); + } + trace_paio_submit(acb, opaque, sector_num, nb_sectors, type); return thread_pool_submit_aio(aio_worker, acb, cb, opaque); }