From patchwork Mon May 23 19:36:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 9132339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A421160761 for ; Mon, 23 May 2016 19:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FF5F2824C for ; Mon, 23 May 2016 19:47:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84E0828250; Mon, 23 May 2016 19:47:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE9042824C for ; Mon, 23 May 2016 19:47:33 +0000 (UTC) Received: from localhost ([::1]:50147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vp6-00058F-I9 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 May 2016 15:47:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vf6-0005Wi-Eo for qemu-devel@nongnu.org; Mon, 23 May 2016 15:37:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4vf4-0007Fo-AJ for qemu-devel@nongnu.org; Mon, 23 May 2016 15:37:11 -0400 Received: from chuckie.co.uk ([82.165.15.123]:55036 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vex-0007E0-Jr; Mon, 23 May 2016 15:37:03 -0400 Received: from host81-129-16-61.range81-129.btcentralplus.com ([81.129.16.61] helo=[192.168.1.65]) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1b4vel-0001YX-VY; Mon, 23 May 2016 20:36:53 +0100 To: Paolo Bonzini , qemu-devel@nongnu.org References: <1464008051-6429-1-git-send-email-pbonzini@redhat.com> From: Mark Cave-Ayland Message-ID: <57435BB8.3000600@ilande.co.uk> Date: Mon, 23 May 2016 20:36:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: <1464008051-6429-1-git-send-email-pbonzini@redhat.com> X-SA-Exim-Connect-IP: 81.129.16.61 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: Re: [Qemu-devel] [PATCH v2 0/7] dma-helpers, scsi-block: use SG_IO for all I/O on scsi-block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 23/05/16 13:54, Paolo Bonzini wrote: > scsi-block uses the block layer for reads and writes in order to avoid > allocating bounce buffers as big as the transferred data. We know how > to split a large transfer to multiple reads and writes, and thus we can > use scsi-disk.c's existing code to do I/O in multiple chunks (for non-s/g > SCSI hosts) or through the DMA helpers (for s/g SCSI hosts). > > Unfortunately, this has the side effect of eating the SCSI status except > in the very few cases where we can convert an errno code back to a SCSI > status. It puts a big wrench in persistent reservations support in the > guest, for example. > > Luckily, splitting a large transfer into multiple SBC commands is just as > easy, and this is what the last patch does. It takes the original CDB, > patches in a modified starting sector and sector count, and executes the > SCSI command through blk_aio_ioctl. It is also easy to pass a QEMUIOVector > to SG_IO, so that s/g SCSI hosts keep the performance. > > This rebases the patches on top of Eric's changes for byte-based > BlockBackend access and fixes a few bugs I knew about in the RFC. > > Patches 1, 5 and 6 are new. > > Paolo > > Paolo Bonzini (7): > dma-helpers: change interface to byte-based > dma-helpers: change BlockBackend to opaque value in DMAIOFunc > scsi-disk: introduce a common base class > scsi-disk: introduce dma_readv and dma_writev > scsi-disk: add need_fua_emulation to SCSIDiskClass > scsi-disk: introduce scsi_disk_req_check_error > scsi-block: always use SG_IO > > dma-helpers.c | 54 +++++-- > hw/block/nvme.c | 6 +- > hw/ide/ahci.c | 6 +- > hw/ide/core.c | 20 ++- > hw/ide/internal.h | 6 +- > hw/ide/macio.c | 2 +- > hw/scsi/scsi-disk.c | 409 +++++++++++++++++++++++++++++++++++++-------------- > include/sysemu/dma.h | 20 +-- > trace-events | 2 +- > 9 files changed, 371 insertions(+), 154 deletions(-) Hi Paolo, I thought I'd give this patchset a spin with a view to seeing whether I could switch the macio device back to the now byte-based dma-helpers, but came up with a couple of compile errors. Attached is the minor diff I applied in order to get a successful compile (apologies for not being inline, however I couldn't get my mail client to stop wrapping incorrectly). ATB, Mark. diff --git a/dma-helpers.c b/dma-helpers.c index 92c5d55..b521d84 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -192,7 +192,7 @@ static const AIOCBInfo dma_aiocb_info = { }; BlockAIOCB *dma_blk_io(AioContext *ctx, - QEMUSGList *sg, uint64_t opaque, + QEMUSGList *sg, uint64_t offset, DMAIOFunc *io_func, void *io_func_opaque, BlockCompletionFunc *cb, void *opaque, DMADirection dir) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 02faa3a..f7a23fc 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -540,7 +540,6 @@ static void scsi_write_data(SCSIRequest *req) if (r->req.sg) { dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE); r->req.resid -= r->req.sg->size; - scsi_dma_complete, r); r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk), r->req.sg, r->sector << BDRV_SECTOR_BITS, sdc->dma_writev, r, scsi_dma_complete, r,