From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Kevin Wolf 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> Subject: [Qemu-devel] [PATCH 11/14] block: Add blk_co_readv/writev() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, jcody@redhat.com, jsnow@redhat.com, berto@igalia.com, qemu-devel@nongnu.org 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 -- 1.8.3.1