From patchwork Wed May 4 09:39:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9011901 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1AD78BF29F for ; Wed, 4 May 2016 09:45:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70B1420395 for ; Wed, 4 May 2016 09:45:06 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id B238920394 for ; Wed, 4 May 2016 09:45:05 +0000 (UTC) Received: from localhost ([::1]:46660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtMb-0005cm-PZ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 May 2016 05:45:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtIO-0005on-9x for qemu-devel@nongnu.org; Wed, 04 May 2016 05:40:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axtIC-0005uD-LU for qemu-devel@nongnu.org; Wed, 04 May 2016 05:40:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtHu-0005cS-78; Wed, 04 May 2016 05:40:10 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD968C05E17E; Wed, 4 May 2016 09:39:53 +0000 (UTC) Received: from noname.str.redhat.com. (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u449dYe9000875; Wed, 4 May 2016 05:39:52 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 4 May 2016 11:39:22 +0200 Message-Id: <1462354765-14037-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1462354765-14037-1-git-send-email-kwolf@redhat.com> References: <1462354765-14037-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/14] block: Add blk_co_readv/writev() 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: kwolf@redhat.com, berto@igalia.com, jcody@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Kevin Wolf --- block/block-backend.c | 26 ++++++++++++++++++++++++++ include/sysemu/block-backend.h | 4 ++++ trace-events | 2 ++ 3 files changed, 32 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 25bb5ca..8dc3aa5 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -794,6 +794,19 @@ static int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, return bdrv_co_pwritev(blk_bs(blk), offset, bytes, qiov, flags); } +int coroutine_fn blk_co_readv(BlockBackend *blk, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov) +{ + trace_blk_co_readv(blk, blk_bs(blk), sector_num, nb_sectors); + + if (nb_sectors < 0 || nb_sectors > BDRV_REQUEST_MAX_SECTORS) { + return -EINVAL; + } + + return blk_co_preadv(blk, sector_num << BDRV_SECTOR_BITS, + nb_sectors << BDRV_SECTOR_BITS, qiov, 0); +} + int coroutine_fn blk_co_copy_on_readv(BlockBackend *blk, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { @@ -808,6 +821,19 @@ int coroutine_fn blk_co_copy_on_readv(BlockBackend *blk, BDRV_REQ_COPY_ON_READ); } +int coroutine_fn blk_co_writev(BlockBackend *blk, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov) +{ + trace_blk_co_writev(blk, blk_bs(blk), sector_num, nb_sectors); + + if (nb_sectors < 0 || nb_sectors > BDRV_REQUEST_MAX_SECTORS) { + return -EINVAL; + } + + return blk_co_pwritev(blk, sector_num << BDRV_SECTOR_BITS, + nb_sectors << BDRV_SECTOR_BITS, qiov, 0); +} + typedef struct BlkRwCo { BlockBackend *blk; int64_t offset; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index eac4d88..d98552c 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -116,8 +116,12 @@ int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf, int nb_sectors); int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf, int nb_sectors); +int coroutine_fn blk_co_readv(BlockBackend *blk, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov); int coroutine_fn blk_co_copy_on_readv(BlockBackend *blk, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); +int coroutine_fn blk_co_writev(BlockBackend *blk, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov); int blk_write(BlockBackend *blk, int64_t sector_num, const uint8_t *buf, int nb_sectors); int blk_write_zeroes(BlockBackend *blk, int64_t sector_num, diff --git a/trace-events b/trace-events index 9beb588..3b5cce3 100644 --- a/trace-events +++ b/trace-events @@ -62,6 +62,8 @@ bdrv_open_common(void *bs, const char *filename, int flags, const char *format_n bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" # block/block-backend.c +blk_co_readv(void *blk, void *bs, int64_t sector_num, int nb_sector) "blk %p bs %p sector_num %"PRId64" nb_sectors %d" +blk_co_writev(void *blk, void *bs, int64_t sector_num, int nb_sector) "blk %p bs %p sector_num %"PRId64" nb_sectors %d" blk_co_copy_on_readv(void *blk, void *bs, int64_t sector_num, int nb_sector) "blk %p bs %p sector_num %"PRId64" nb_sectors %d" # block/io.c