From 826daa6c1fb37846177112b73b515357e4583990 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 14 Feb 2012 11:14:41 +0100 Subject: [PATCH 76/99] block: split out bdrv_co_do_readv() and bdrv_co_do_writev() RH-Author: Kevin Wolf Message-id: <1329218101-24213-77-git-send-email-kwolf@redhat.com> Patchwork-id: 37267 O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 76/96] block: split out bdrv_co_do_readv() and bdrv_co_do_writev() Bugzilla: 783950 RH-Acked-by: Paolo Bonzini RH-Acked-by: Marcelo Tosatti RH-Acked-by: Laszlo Ersek From: Stefan Hajnoczi Bugzilla: 783950 The public interface for I/O in coroutine context is bdrv_co_readv() and bdrv_co_writev(). Split out the request processing code into bdrv_co_do_readv() and bdrv_co_writev() so that it can be called internally when we refactor all request processing to use coroutines. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf (cherry picked from commit c5fbe57111ef59c315a71cd80e8b0af59e36ff21) --- block.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-) Signed-off-by: Michal Novotny --- block.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index b7c90e5..1d5d8cc 100644 --- a/block.c +++ b/block.c @@ -72,6 +72,8 @@ static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov); static int coroutine_fn bdrv_co_flush_em(BlockDriverState *bs); +static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); static QTAILQ_HEAD(, BlockDriverState) bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); @@ -1202,13 +1204,14 @@ int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, return 0; } -int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, QEMUIOVector *qiov) +/* + * Handle a read request in coroutine context + */ +static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BlockDriver *drv = bs->drv; - trace_bdrv_co_readv(bs, sector_num, nb_sectors); - if (!drv) { return -ENOMEDIUM; } @@ -1219,12 +1222,21 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); } -int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, +int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { - BlockDriver *drv = bs->drv; + trace_bdrv_co_readv(bs, sector_num, nb_sectors); - trace_bdrv_co_writev(bs, sector_num, nb_sectors); + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov); +} + +/* + * Handle a write request in coroutine context + */ +static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) +{ + BlockDriver *drv = bs->drv; if (!bs->drv) { return -ENOMEDIUM; @@ -1247,6 +1259,14 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, return drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } +int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, QEMUIOVector *qiov) +{ + trace_bdrv_co_writev(bs, sector_num, nb_sectors); + + return bdrv_co_do_writev(bs, sector_num, nb_sectors, qiov); +} + /** * Truncate file to 'offset' bytes (needed only for file protocols) */ -- 1.7.7.5