From patchwork Mon May 30 11:47:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 9141047 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 9087360759 for ; Mon, 30 May 2016 11:48:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 816E527C23 for ; Mon, 30 May 2016 11:48:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73437281C2; Mon, 30 May 2016 11:48:20 +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 0D88C27C23 for ; Mon, 30 May 2016 11:48:19 +0000 (UTC) Received: from localhost ([::1]:59501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7Lg9-0003lL-Pr for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 May 2016 07:48:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7Lfp-0003lF-Qy for qemu-devel@nongnu.org; Mon, 30 May 2016 07:47:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7Lfm-0005Ih-NO for qemu-devel@nongnu.org; Mon, 30 May 2016 07:47:57 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:50262 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7Lfm-0005GW-Dy for qemu-devel@nongnu.org; Mon, 30 May 2016 07:47:54 -0400 Received: (qmail 10111 invoked by uid 89); 30 May 2016 11:47:50 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.99.2/21638. hbedv: 8.3.40.22/7.12.95.236. avast: 1.2.2/16053000. spamassassin: 3.4.1. Clear:RC:1(195.62.97.28):. Processed in 0.067474 secs); 30 May 2016 11:47:50 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted); 30 May 2016 11:47:49 -0000 X-GL_Whitelist: yes Received: (qmail 30473 invoked from network); 30 May 2016 11:47:49 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 30 May 2016 11:47:49 -0000 Received: by lieven-pc (Postfix, from userid 1000) id 2C9A620A6A; Mon, 30 May 2016 13:47:49 +0200 (CEST) From: Peter Lieven To: qemu-block@nongnu.org Date: Mon, 30 May 2016 13:47:44 +0200 Message-Id: <1464608864-7115-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:248:0:51::16 Subject: [Qemu-devel] [PATCH] block/nfs: Implement .bdrv_co_preadv/pwritev interfaces 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: Peter Lieven , jcody@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, ronniesahlberg@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP the libnfs read and write functions already take byte arguments so thats an easy change. Signed-off-by: Peter Lieven Reviewed-by: Eric Blake Reviewed-by: Jeff Cody --- block/nfs.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index 9f51cc3..386f846 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -133,20 +133,19 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data, } } -static int coroutine_fn nfs_co_readv(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, - QEMUIOVector *iov) +static int coroutine_fn +nfs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) { NFSClient *client = bs->opaque; NFSRPC task; nfs_co_init_task(client, &task); - task.iov = iov; + task.iov = qiov; if (nfs_pread_async(client->context, client->fh, - sector_num * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE, - nfs_co_generic_cb, &task) != 0) { + offset, bytes, nfs_co_generic_cb, + &task) != 0) { return -ENOMEM; } @@ -160,16 +159,16 @@ static int coroutine_fn nfs_co_readv(BlockDriverState *bs, } /* zero pad short reads */ - if (task.ret < iov->size) { - qemu_iovec_memset(iov, task.ret, 0, iov->size - task.ret); + if (task.ret < qiov->size) { + qemu_iovec_memset(qiov, task.ret, 0, qiov->size - task.ret); } return 0; } -static int coroutine_fn nfs_co_writev(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, - QEMUIOVector *iov) +static int coroutine_fn +nfs_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) { NFSClient *client = bs->opaque; NFSRPC task; @@ -177,17 +176,16 @@ static int coroutine_fn nfs_co_writev(BlockDriverState *bs, nfs_co_init_task(client, &task); - buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE); - if (nb_sectors && buf == NULL) { + buf = g_try_malloc(bytes); + if (bytes && buf == NULL) { return -ENOMEM; } - qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE); + qemu_iovec_to_buf(qiov, 0, buf, bytes); if (nfs_pwrite_async(client->context, client->fh, - sector_num * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE, - buf, nfs_co_generic_cb, &task) != 0) { + offset, bytes, buf, + nfs_co_generic_cb, &task) != 0) { g_free(buf); return -ENOMEM; } @@ -199,7 +197,7 @@ static int coroutine_fn nfs_co_writev(BlockDriverState *bs, g_free(buf); - if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) { + if (task.ret != bytes) { return task.ret < 0 ? task.ret : -EIO; } @@ -547,8 +545,8 @@ static BlockDriver bdrv_nfs = { .bdrv_create = nfs_file_create, .bdrv_reopen_prepare = nfs_reopen_prepare, - .bdrv_co_readv = nfs_co_readv, - .bdrv_co_writev = nfs_co_writev, + .bdrv_co_preadv = nfs_co_preadv, + .bdrv_co_pwritev = nfs_co_pwritev, .bdrv_co_flush_to_disk = nfs_co_flush, .bdrv_detach_aio_context = nfs_detach_aio_context,