Sheepdog cleanups
cover Sheepdog cleanups
Cleaning up the code and removing duplication makes it simpler to later adapt it for the multiqueue work.
Tested against sheepdog 1.0. I also tested taking snapshots and reverting to older snapshots, but the latter only worked with "dog vdi rollback". Neither loadvm nor qemu-img worked for me.
Paolo Bonzini (5):
sheepdog: remove unused cancellation support
sheepdog: reorganize coroutine flow
sheepdog: do not use BlockAIOCB
sheepdog: simplify inflight_aio_head management
sheepdog: reorganize check for overlapping requests
block/sheepdog.c | 285 ++++++++++++++++--------------------------------------- 1 file changed, 81 insertions(+), 204 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/5 sheepdog: remove unused cancellation support
SheepdogAIOCB is internal to sheepdog.c, hence it is never canceled.
--- block/sheepdog.c | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-)
block/sheepdog.c +0 -52
@@ -347,7 +347,6 @@ struct SheepdogAIOCB {Coroutine *coroutine;void (*aio_done_func)(SheepdogAIOCB *); -bool cancelable;int nr_pending;uint32_t min_affect_data_idx;
@@ -486,7 +485,6 @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) {SheepdogAIOCB *acb = aio_req->aiocb; - acb->cancelable = false;QLIST_REMOVE (aio_req, aio_siblings);g_free (aio_req);
@@ -499,57 +497,8 @@ static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb)qemu_aio_unref (acb); } -/* -* Check whether the specified acb can be canceled -* -* We can cancel aio when any request belonging to the acb is: -* - Not processed by the sheepdog server. -* - Not linked to the inflight queue. -*/ -static bool sd_acb_cancelable (const SheepdogAIOCB *acb) -{ -BDRVSheepdogState *s = acb->common.bs->opaque; -AIOReq *aioreq; - -if (!acb->cancelable) { -return false; - } - - QLIST_FOREACH(aioreq, &s->inflight_aio_head, aio_siblings) { -if (aioreq->aiocb == acb) { -return false; - } - } - -return true; -} - -static void sd_aio_cancel (BlockAIOCB *blockacb) -{ -SheepdogAIOCB *acb = (SheepdogAIOCB *)blockacb; -BDRVSheepdogState *s = acb->common.bs->opaque; -AIOReq *aioreq, *next; - -if (sd_acb_cancelable (acb)) { -/* Remove outstanding requests from failed queue. */ -QLIST_FOREACH_SAFE (aioreq, &s->failed_aio_head, aio_siblings, - next) { -if (aioreq->aiocb == acb) { -free_aio_req (s, aioreq); - } - } - -assert (acb->nr_pending ==0 ); -if (acb->common.cb) { - acb->common.cb (acb->common.opaque, -ECANCELED ); - } -sd_finish_aiocb (acb); - } -} -static const AIOCBInfo sd_aiocb_info = { .aiocb_size =sizeof (SheepdogAIOCB), - .cancel_async = sd_aio_cancel, }; static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
@@ -569,7 +518,6 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov, acb->nb_sectors = nb_sectors; acb->aio_done_func =NULL ; - acb->cancelable = true; acb->coroutine =qemu_coroutine_self (); acb->ret =0 ; acb->nr_pending =0 ;
Signature · 1 line
2.9.3
PATCH 2/5 sheepdog: reorganize coroutine flow
In reply to Paolo BonziniDelimit co_recv's lifetime clearly in aio_read_response.
Do a simple qemu_coroutine_enter in aio_read_response, letting sd_co_writev call sd_write_done.
Handle nr_pending in the same way in sd_co_rw_vector, sd_write_done and sd_co_flush_to_disk.
Remove sd_co_rw_vector's return value; just leave with no pending requests.
--- block/sheepdog.c | 115 ++++++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 74 deletions(-)
block/sheepdog.c +41 -74
@@ -345,8 +345,6 @@ struct SheepdogAIOCB {enum AIOCBState aiocb_type;Coroutine *coroutine; -void (*aio_done_func)(SheepdogAIOCB *); -int nr_pending;uint32_t min_affect_data_idx;
@@ -449,14 +447,13 @@ static const char * sd_strerror(int err)* * 1. In sd_co_rw_vector, we send the I/O requests to the server and * link the requests to the inflight_list in the -* BDRVSheepdogState. The function exits without waiting for +* BDRVSheepdogState. The function yields while waiting for * receiving the response. * * 2. We receive the response in aio_read_response, the fd handler to -* the sheepdog connection. If metadata update is needed, we send -* the write request to the vdi object in sd_write_done, the write -* completion function. We switch back to sd_co_readv/writev after -* all the requests belonging to the AIOCB are finished. +* the sheepdog connection. We switch back to sd_co_readv/sd_writev +* after all the requests belonging to the AIOCB are finished. If +* needed, sd_co_writev will send another requests for the vdi object. */ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,
@@ -491,12 +488,6 @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) acb->nr_pending--; } -static void coroutine_fn sd_finish_aiocb(SheepdogAIOCB *acb) -{ -qemu_coroutine_enter (acb->coroutine); -qemu_aio_unref (acb); -} -static const AIOCBInfo sd_aiocb_info = { .aiocb_size =sizeof (SheepdogAIOCB), };
@@ -517,7 +508,6 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov, acb->sector_num = sector_num; acb->nb_sectors = nb_sectors; - acb->aio_done_func =NULL ; acb->coroutine =qemu_coroutine_self (); acb->ret =0 ; acb->nr_pending =0 ;
@@ -788,9 +778,6 @@ static void coroutine_fn aio_read_response(void *opaque)switch (acb->aiocb_type) {case AIOCB_WRITE_UDATA : -/* this coroutine context is no longer suitable for co_recv -* because we may send data to update vdi objects */ - s->co_recv =NULL ;if (!is_data_obj (aio_req->oid)) {break ; }
@@ -838,6 +825,11 @@ static void coroutine_fn aio_read_response(void *opaque) } } +/* No more data for this aio_req (reload_inode below uses its own file +* descriptor handler which doesn't use co_recv). +*/ + s->co_recv =NULL ; +switch (rsp.result) {case SD_RES_SUCCESS :break ;
@@ -855,7 +847,7 @@ static void coroutine_fn aio_read_response(void *opaque) aio_req->oid =vid_to_vdi_oid (s->inode.vdi_id); }resend_aioreq (s, aio_req); - goto out; +return ;default : acb->ret = -EIO ;error_report ("%s" ,sd_strerror (rsp.result));
@@ -868,13 +860,10 @@ static void coroutine_fn aio_read_response(void *opaque)* We've finished all requests which belong to the AIOCB, so * we can switch back to sd_co_readv/writev now. */ - acb->aio_done_func (acb); +qemu_coroutine_enter (acb->coroutine); } -out: - s->co_recv =NULL ; -return ; + err: - s->co_recv =NULL ;reconnect_to_sdog (opaque); }
@@ -1973,7 +1962,6 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset)/* * This function is called after writing data objects. If we need to * update metadata, this sends a write request to the vdi object. -* Otherwise, this switches back to sd_co_readv/writev. */ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) {
@@ -1986,6 +1974,7 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) mx = acb->max_dirty_data_idx;if (mn <= mx) {/* we need to update the vdi object. */ + ++acb->nr_pending; offset =sizeof (s->inode) -sizeof (s->inode.data_vdi_id) + mn *sizeof (s->inode.data_vdi_id[0 ]); data_len = (mx - mn +1 ) *sizeof (s->inode.data_vdi_id[0 ]);
@@ -1999,13 +1988,10 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) data_len, offset, 0, false, 0, offset);QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings);add_aio_request (s, aio_req, &iov,1 ,AIOCB_WRITE_UDATA ); - - acb->aio_done_func = sd_finish_aiocb; - acb->aiocb_type =AIOCB_WRITE_UDATA ; -return ; +if (--acb->nr_pending) { +qemu_coroutine_yield (); + } } - -sd_finish_aiocb (acb); }/* Delete current working VDI on the snapshot chain */
@@ -2117,7 +2103,7 @@ out:* Returns 1 when we need to wait a response, 0 when there is no sent * request and -errno in error cases. */ -static int coroutine_fn sd_co_rw_vector(void *p) +static void coroutine_fn sd_co_rw_vector(void *p) {SheepdogAIOCB *acb = p;int ret =0 ;
@@ -2138,7 +2124,7 @@ static int coroutine_fn sd_co_rw_vector(void *p) ret =sd_create_branch (s);if (ret) { acb->ret = -EIO ; - goto out; +return ; } }
@@ -2212,11 +2198,9 @@ static int coroutine_fn sd_co_rw_vector(void *p) idx++; done += len; } -out: -if (!--acb->nr_pending) { -return acb->ret; +if (--acb->nr_pending) { +qemu_coroutine_yield (); } -return 1 ; }static bool check_overlapping_aiocb (BDRVSheepdogState *s,SheepdogAIOCB *aiocb)
@@ -2249,7 +2233,6 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, } acb =sd_aio_setup (bs, qiov, sector_num, nb_sectors); - acb->aio_done_func = sd_write_done; acb->aiocb_type =AIOCB_WRITE_UDATA ; retry:
@@ -2258,20 +2241,14 @@ retry: goto retry; } - ret =sd_co_rw_vector (acb); -if (ret <=0 ) { -QLIST_REMOVE (acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue); -qemu_aio_unref (acb); -return ret; - } - -qemu_coroutine_yield (); +sd_co_rw_vector (acb); +sd_write_done (acb);QLIST_REMOVE (acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); - -return acb->ret; + ret = acb->ret; +qemu_aio_unref (acb); +return ret; } static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
@@ -2283,7 +2260,6 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num, acb =sd_aio_setup (bs, qiov, sector_num, nb_sectors); acb->aiocb_type =AIOCB_READ_UDATA ; - acb->aio_done_func = sd_finish_aiocb; retry:if (check_overlapping_aiocb (s, acb)) {
@@ -2291,25 +2267,20 @@ retry: goto retry; } - ret =sd_co_rw_vector (acb); -if (ret <=0 ) { -QLIST_REMOVE (acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue); -qemu_aio_unref (acb); -return ret; - } - -qemu_coroutine_yield (); +sd_co_rw_vector (acb);QLIST_REMOVE (acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); -return acb->ret; + ret = acb->ret; +qemu_aio_unref (acb); +return ret; } static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) {BDRVSheepdogState *s = bs->opaque;SheepdogAIOCB *acb; +int ret;AIOReq *aio_req;if (s->cache_flags !=SD_FLAG_CMD_CACHE ) {
@@ -2318,15 +2289,19 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) acb =sd_aio_setup (bs,NULL ,0 ,0 ); acb->aiocb_type =AIOCB_FLUSH_CACHE ; - acb->aio_done_func = sd_finish_aiocb; + acb->nr_pending++; aio_req =alloc_aio_req (s, acb,vid_to_vdi_oid (s->inode.vdi_id),0 ,0 ,0 , false,0 ,0 );QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings);add_aio_request (s, aio_req,NULL ,0 , acb->aiocb_type); -qemu_coroutine_yield (); -return acb->ret; +if (--acb->nr_pending) { +qemu_coroutine_yield (); + } + ret = acb->ret; +qemu_aio_unref (acb); +return ret; }static int sd_snapshot_create (BlockDriverState *bs,QEMUSnapshotInfo *sn_info)
@@ -2782,7 +2757,6 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset, acb =sd_aio_setup (bs, &discard_iov, offset >>BDRV_SECTOR_BITS , count >>BDRV_SECTOR_BITS ); acb->aiocb_type =AIOCB_DISCARD_OBJ ; - acb->aio_done_func = sd_finish_aiocb; retry:if (check_overlapping_aiocb (s, acb)) {
@@ -2790,20 +2764,13 @@ retry: goto retry; } - ret =sd_co_rw_vector (acb); -if (ret <=0 ) { -QLIST_REMOVE (acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue); -qemu_aio_unref (acb); -return ret; - } - -qemu_coroutine_yield (); +sd_co_rw_vector (acb);QLIST_REMOVE (acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); - -return acb->ret; + ret = acb->ret; +qemu_aio_unref (acb); +return ret; }static coroutine_fn int64_t
Signature · 1 line
2.9.3
PATCH 3/5 sheepdog: do not use BlockAIOCB
In reply to Paolo BonziniSheepdog's AIOCB are completely internal entities for a group of requests and do not need dynamic allocation.
--- block/sheepdog.c | 95 ++++++++++++++++++++++---------------------------------- 1 file changed, 37 insertions(+), 58 deletions(-)
block/sheepdog.c +37 -58
@@ -306,6 +306,7 @@ static inline size_t count_data_objs(const struct SheepdogInode *inode) }while (0 ) typedef struct SheepdogAIOCB SheepdogAIOCB; +typedef struct BDRVSheepdogState BDRVSheepdogState ; typedef struct AIOReq { SheepdogAIOCB *aiocb;
@@ -334,7 +335,7 @@ enum AIOCBState { || y->max_affect_data_idx < x->min_affect_data_idx)) struct SheepdogAIOCB { - BlockAIOCB common; + BDRVSheepdogState *s; QEMUIOVector *qiov;
@@ -488,20 +489,15 @@ static inline void free_aio_req(BDRVSheepdogState *s, AIOReq *aio_req) acb->nr_pending--; } -static const AIOCBInfo sd_aiocb_info = { - .aiocb_size =sizeof (SheepdogAIOCB), -}; - -static SheepdogAIOCB *sd_aio_setup (BlockDriverState *bs,QEMUIOVector *qiov, -int64_t sector_num,int nb_sectors) +static void sd_aio_setup (SheepdogAIOCB *acb,BDRVSheepdogState *s, +QEMUIOVector *qiov,int64_t sector_num,int nb_sectors, +int type) { -SheepdogAIOCB *acb;uint32_t object_size; -BDRVSheepdogState *s = bs->opaque; object_size = (UINT32_C (1 ) << s->inode.block_size_shift); - acb =qemu_aio_get (&sd_aiocb_info, bs,NULL ,NULL ); + acb->s = s; acb->qiov = qiov;
@@ -518,8 +514,7 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov, acb->min_dirty_data_idx =UINT32_MAX ; acb->max_dirty_data_idx =0 ; - -return acb; + acb->aiocb_type = type; }/* Return -EIO in case of error, file descriptor on success */
@@ -1965,7 +1960,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset)*/ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) { -BDRVSheepdogState *s = acb->common.bs->opaque; +BDRVSheepdogState *s = acb->s;struct iovec iov;AIOReq *aio_req;uint32_t offset, data_len, mn, mx;
@@ -2103,16 +2098,15 @@ out:* Returns 1 when we need to wait a response, 0 when there is no sent * request and -errno in error cases. */ -static void coroutine_fn sd_co_rw_vector(void *p) +static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) { -SheepdogAIOCB *acb = p;int ret =0 ;unsigned long len, done =0 , total = acb->nb_sectors *BDRV_SECTOR_SIZE ;unsigned long idx;uint32_t object_size;uint64_t oid;uint64_t offset; -BDRVSheepdogState *s = acb->common.bs->opaque; +BDRVSheepdogState *s = acb->s;SheepdogInode *inode = &s->inode;AIOReq *aio_req;
@@ -2220,7 +2214,7 @@ static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb) static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) { -SheepdogAIOCB *acb; +SheepdogAIOCB acb;int ret;int64_t offset = (sector_num + nb_sectors) *BDRV_SECTOR_SIZE ;BDRVSheepdogState *s = bs->opaque;
@@ -2232,76 +2226,65 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, } } - acb =sd_aio_setup (bs, qiov, sector_num, nb_sectors); - acb->aiocb_type =AIOCB_WRITE_UDATA ; +sd_aio_setup (&acb, s, qiov, sector_num, nb_sectors,AIOCB_WRITE_UDATA ); retry: -if (check_overlapping_aiocb (s, acb)) { +if (check_overlapping_aiocb (s, &acb)) {qemu_co_queue_wait (&s->overlapping_queue); goto retry; } -sd_co_rw_vector (acb); -sd_write_done (acb); +sd_co_rw_vector (&acb); +sd_write_done (&acb); -QLIST_REMOVE (acb, aiocb_siblings); +QLIST_REMOVE (&acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); - ret = acb->ret; -qemu_aio_unref (acb); -return ret; +return acb.ret; } static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,int nb_sectors,QEMUIOVector *qiov) { -SheepdogAIOCB *acb; -int ret; +SheepdogAIOCB acb;BDRVSheepdogState *s = bs->opaque; - acb =sd_aio_setup (bs, qiov, sector_num, nb_sectors); - acb->aiocb_type =AIOCB_READ_UDATA ; +sd_aio_setup (&acb, s, qiov, sector_num, nb_sectors,AIOCB_READ_UDATA ); retry: -if (check_overlapping_aiocb (s, acb)) { +if (check_overlapping_aiocb (s, &acb)) {qemu_co_queue_wait (&s->overlapping_queue); goto retry; } -sd_co_rw_vector (acb); +sd_co_rw_vector (&acb); -QLIST_REMOVE (acb, aiocb_siblings); +QLIST_REMOVE (&acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); - ret = acb->ret; -qemu_aio_unref (acb); -return ret; +return acb.ret; } static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) {BDRVSheepdogState *s = bs->opaque; -SheepdogAIOCB *acb; -int ret; +SheepdogAIOCB acb;AIOReq *aio_req;if (s->cache_flags !=SD_FLAG_CMD_CACHE ) {return 0 ; } - acb =sd_aio_setup (bs,NULL ,0 ,0 ); - acb->aiocb_type =AIOCB_FLUSH_CACHE ; +sd_aio_setup (&acb, s,NULL ,0 ,0 ,AIOCB_FLUSH_CACHE ); - acb->nr_pending++; - aio_req =alloc_aio_req (s, acb,vid_to_vdi_oid (s->inode.vdi_id), + acb.nr_pending++; + aio_req =alloc_aio_req (s, &acb,vid_to_vdi_oid (s->inode.vdi_id),0 ,0 ,0 , false,0 ,0 );QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings); -add_aio_request (s, aio_req,NULL ,0 , acb->aiocb_type); +add_aio_request (s, aio_req,NULL ,0 , acb.aiocb_type); -if (--acb->nr_pending) { +if (--acb.nr_pending) {qemu_coroutine_yield (); } - ret = acb->ret; -qemu_aio_unref (acb); -return ret; +return acb.ret; }static int sd_snapshot_create (BlockDriverState *bs,QEMUSnapshotInfo *sn_info)
@@ -2735,9 +2718,8 @@ static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,int count) { -SheepdogAIOCB *acb; +SheepdogAIOCB acb;BDRVSheepdogState *s = bs->opaque; -int ret;QEMUIOVector discard_iov;struct iovec iov;uint32_t zero =0 ;
@@ -2754,23 +2736,20 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset, discard_iov.niov =1 ;assert ((offset & (BDRV_SECTOR_SIZE -1 )) ==0 );assert ((count & (BDRV_SECTOR_SIZE -1 )) ==0 ); - acb =sd_aio_setup (bs, &discard_iov, offset >>BDRV_SECTOR_BITS , - count >>BDRV_SECTOR_BITS ); - acb->aiocb_type =AIOCB_DISCARD_OBJ ; +sd_aio_setup (&acb, s, &discard_iov, offset >>BDRV_SECTOR_BITS , + count >>BDRV_SECTOR_BITS ,AIOCB_DISCARD_OBJ ); retry: -if (check_overlapping_aiocb (s, acb)) { +if (check_overlapping_aiocb (s, &acb)) {qemu_co_queue_wait (&s->overlapping_queue); goto retry; } -sd_co_rw_vector (acb); +sd_co_rw_vector (&acb); -QLIST_REMOVE (acb, aiocb_siblings); +QLIST_REMOVE (&acb, aiocb_siblings);qemu_co_queue_restart_all (&s->overlapping_queue); - ret = acb->ret; -qemu_aio_unref (acb); -return ret; +return acb.ret; }static coroutine_fn int64_t
Signature · 1 line
2.9.3
PATCH 4/5 sheepdog: simplify inflight_aio_head management
In reply to Paolo BonziniAdd to the list in add_aio_request and, indirectly, resend_aioreq. Inline free_aio_req in the caller, it does not simply undo alloc_aio_req's job.
--- block/sheepdog.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
block/sheepdog.c +6 -17
@@ -479,16 +479,6 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,return aio_req; } -static inline void free_aio_req (BDRVSheepdogState *s,AIOReq *aio_req) -{ -SheepdogAIOCB *acb = aio_req->aiocb; - -QLIST_REMOVE (aio_req, aio_siblings); -g_free (aio_req); - - acb->nr_pending--; -} -static void sd_aio_setup (SheepdogAIOCB *acb,BDRVSheepdogState *s,QEMUIOVector *qiov,int64_t sector_num,int nb_sectors,int type)
@@ -730,7 +720,6 @@ static coroutine_fn void reconnect_to_sdog(void *opaque)while (!QLIST_EMPTY (&s->failed_aio_head)) { aio_req =QLIST_FIRST (&s->failed_aio_head);QLIST_REMOVE (aio_req, aio_siblings); -QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings);resend_aioreq (s, aio_req); } }
@@ -825,6 +814,7 @@ static void coroutine_fn aio_read_response(void *opaque)*/ s->co_recv =NULL ; +QLIST_REMOVE (aio_req, aio_siblings);switch (rsp.result) {case SD_RES_SUCCESS :break ;
@@ -849,8 +839,9 @@ static void coroutine_fn aio_read_response(void *opaque)break ; } -free_aio_req (s, aio_req); -if (!acb->nr_pending) { +g_free (aio_req); + +if (!--acb->nr_pending) {/* * We've finished all requests which belong to the AIOCB, so * we can switch back to sd_co_readv/writev now.
@@ -1108,6 +1099,8 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,uint64_t old_oid = aio_req->base_oid;bool create = aio_req->create; +QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings); +if (!nr_copies) {error_report ("bug" ); }
@@ -1981,7 +1974,6 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) iov.iov_len =sizeof (s->inode); aio_req =alloc_aio_req (s, acb,vid_to_vdi_oid (s->inode.vdi_id), data_len, offset,0 , false,0 , offset); -QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings);add_aio_request (s, aio_req, &iov,1 ,AIOCB_WRITE_UDATA );if (--acb->nr_pending) {qemu_coroutine_yield ();
@@ -2183,8 +2175,6 @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) old_oid, acb->aiocb_type ==AIOCB_DISCARD_OBJ ? 0 : done); -QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings); -add_aio_request (s, aio_req, acb->qiov->iov, acb->qiov->niov, acb->aiocb_type); done:
@@ -2278,7 +2268,6 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) acb.nr_pending++; aio_req =alloc_aio_req (s, &acb,vid_to_vdi_oid (s->inode.vdi_id),0 ,0 ,0 , false,0 ,0 ); -QLIST_INSERT_HEAD (&s->inflight_aio_head, aio_req, aio_siblings);add_aio_request (s, aio_req,NULL ,0 , acb.aiocb_type);if (--acb.nr_pending) {
Signature · 1 line
2.9.3
PATCH 5/5 sheepdog: reorganize check for overlapping requests
In reply to Paolo BonziniWrap the code that was copied repeatedly in the two functions, sd_aio_setup and sd_aio_complete.
--- block/sheepdog.c | 66 ++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 36 deletions(-)
block/sheepdog.c +30 -36
@@ -479,6 +479,19 @@ static inline AIOReq *alloc_aio_req(BDRVSheepdogState *s, SheepdogAIOCB *acb,return aio_req; } +static void wait_for_overlapping_aiocb (BDRVSheepdogState *s,SheepdogAIOCB *acb) +{ +SheepdogAIOCB *cb; + +retry: + QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) { +if (AIOCBOverlapping (acb, cb)) { +qemu_co_queue_wait (&s->overlapping_queue); + goto retry; + } + } +} +static void sd_aio_setup (SheepdogAIOCB *acb,BDRVSheepdogState *s,QEMUIOVector *qiov,int64_t sector_num,int nb_sectors,int type)
@@ -505,6 +518,13 @@ static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s, acb->min_dirty_data_idx =UINT32_MAX ; acb->max_dirty_data_idx =0 ; acb->aiocb_type = type; + +if (type ==AIOCB_FLUSH_CACHE ) { +return ; + } + +wait_for_overlapping_aiocb (s, acb); +QLIST_INSERT_HEAD (&s->inflight_aiocb_head, acb, aiocb_siblings); }/* Return -EIO in case of error, file descriptor on success */
@@ -2187,18 +2207,14 @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) } } -static bool check_overlapping_aiocb (BDRVSheepdogState *s,SheepdogAIOCB *aiocb) +static void sd_aio_complete (SheepdogAIOCB *acb) { -SheepdogAIOCB *cb; - - QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) { -if (AIOCBOverlapping (aiocb, cb)) { -return true; - } +if (acb->aiocb_type ==AIOCB_FLUSH_CACHE ) { +return ; } -QLIST_INSERT_HEAD (&s->inflight_aiocb_head, aiocb, aiocb_siblings); -return false; +QLIST_REMOVE (acb, aiocb_siblings); +qemu_co_queue_restart_all (&acb->s->overlapping_queue); } static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
@@ -2217,18 +2233,10 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, }sd_aio_setup (&acb, s, qiov, sector_num, nb_sectors,AIOCB_WRITE_UDATA ); - -retry: -if (check_overlapping_aiocb (s, &acb)) { -qemu_co_queue_wait (&s->overlapping_queue); - goto retry; - } -sd_co_rw_vector (&acb);sd_write_done (&acb); +sd_aio_complete (&acb); -QLIST_REMOVE (&acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue);return acb.ret; }
@@ -2239,17 +2247,9 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,BDRVSheepdogState *s = bs->opaque;sd_aio_setup (&acb, s, qiov, sector_num, nb_sectors,AIOCB_READ_UDATA ); - -retry: -if (check_overlapping_aiocb (s, &acb)) { -qemu_co_queue_wait (&s->overlapping_queue); - goto retry; - } -sd_co_rw_vector (&acb); +sd_aio_complete (&acb); -QLIST_REMOVE (&acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue);return acb.ret; }
@@ -2273,6 +2273,8 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)if (--acb.nr_pending) {qemu_coroutine_yield (); } + +sd_aio_complete (&acb);return acb.ret; }
@@ -2727,17 +2729,9 @@ static coroutine_fn int sd_co_pdiscard(BlockDriverState *bs, int64_t offset,assert ((count & (BDRV_SECTOR_SIZE -1 )) ==0 );sd_aio_setup (&acb, s, &discard_iov, offset >>BDRV_SECTOR_BITS , count >>BDRV_SECTOR_BITS ,AIOCB_DISCARD_OBJ ); - -retry: -if (check_overlapping_aiocb (s, &acb)) { -qemu_co_queue_wait (&s->overlapping_queue); - goto retry; - } -sd_co_rw_vector (&acb); +sd_aio_complete (&acb); -QLIST_REMOVE (&acb, aiocb_siblings); -qemu_co_queue_restart_all (&s->overlapping_queue);return acb.ret; }
Signature · 1 line
2.9.3
Your series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.
Hi,
Your series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.
Subject: [Qemu-devel] [PATCH for-2.9 0/5] Sheepdog cleanups
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=16
make docker-test-quick@centos6
make docker-test-mingw@fedora
make docker-test-build@min-glib
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
9c884e7 sheepdog: reorganize check for overlapping requests de86cde sheepdog: simplify inflight_aio_head management 36a2558 sheepdog: do not use BlockAIOCB
1fd9950 sheepdog: reorganize coroutine flow b7f8f7b sheepdog: remove unused cancellation support
=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into 'dtc'...
Submodule path 'dtc': checked out '65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf'
BUILD centos6
make[1]: Entering directory `/var/tmp/patchew-tester-tmp-pdjhtmz8/src'
ARCHIVE qemu.tgz
ARCHIVE dtc.tgz
COPY RUNNER
RUN test-quick in qemu:centos6
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64
Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ zlib-devel glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=9b45bd20533a
TERM=xterm
MAKEFLAGS= -j16
HISTSIZE=1000
J=16
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env
Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install No C++ compiler available; disabling C++ specific optional code
Install prefix /var/tmp/qemu-build/install BIOS directory /var/tmp/qemu-build/install/share/qemu binary directory /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib module directory /var/tmp/qemu-build/install/lib/qemu libexec directory /var/tmp/qemu-build/install/libexec include directory /var/tmp/qemu-build/install/include config directory /var/tmp/qemu-build/install/etc
local state directory /var/tmp/qemu-build/install/var
Manual directory /var/tmp/qemu-build/install/share/man ELF interp prefix /usr/gnemul/qemu-%M
Source path /tmp/qemu-test/src C compiler cc Host C compiler cc C++ compiler Objective-C compiler cc ARFLAGS rv CFLAGS -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g QEMU_CFLAGS -I/usr/include/pixman-1 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all LDFLAGS -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g make make install install python python -B smbd /usr/sbin/smbd module support no host CPU x86_64 host big endian no target list x86_64-softmmu aarch64-softmmu tcg debug enabled no gprof enabled no sparse enabled no strip binaries yes profiler no static build no pixman system SDL support yes (1.2.14) GTK support no GTK GL support no VTE support no TLS priority NORMAL GNUTLS support no GNUTLS rnd no libgcrypt no libgcrypt kdf no nettle no nettle kdf no libtasn1 no curses support no virgl support no curl support no mingw32 support no Audio drivers oss Block whitelist (rw) Block whitelist (ro) VirtFS support no VNC support yes VNC SASL support no VNC JPEG support no VNC PNG support no xen support no brlapi support no bluez support no Documentation no PIE yes vde support no netmap support no Linux AIO support no ATTR/XATTR support yes Install blobs yes KVM support yes COLO support yes RDMA support no TCG interpreter no fdt support yes preadv support yes fdatasync yes madvise yes posix_madvise yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
Trace backends log spice support no rbd support no xfsctl support no smartcard support no libusb no usb net redir no OpenGL support no OpenGL dmabufs no libiscsi support no libnfs support no
build guest agent yes
QGA VSS support no
QGA w32 disk info no
QGA MSI support no
seccomp support no
coroutine backend ucontext
coroutine pool yes
debug stack usage no
GlusterFS support no
Archipelago support no
gcov gcov gcov enabled no TPM support yes libssh2 support no TPM passthrough yes QOM debugging yes lzo support no snappy support no bzip2 support no
NUMA host support no
tcmalloc support no
jemalloc support no
avx2 optimization no
replication support yes
GEN x86_64-softmmu/config-devices.mak.tmp GEN aarch64-softmmu/config-devices.mak.tmp GEN config-host.h GEN qemu-options.def GEN qmp-commands.h GEN qapi-types.h GEN qapi-visit.h GEN qapi-event.h GEN qmp-introspect.h GEN x86_64-softmmu/config-devices.mak GEN aarch64-softmmu/config-devices.mak GEN module_block.h GEN tests/test-qapi-types.h GEN tests/test-qapi-visit.h GEN tests/test-qmp-commands.h GEN tests/test-qapi-event.h GEN tests/test-qmp-introspect.h GEN config-all-devices.mak GEN trace/generated-tracers.h GEN trace/generated-tcg-tracers.h GEN trace/generated-helpers-wrappers.h GEN trace/generated-helpers.h CC tests/qemu-iotests/socket_scm_helper.o GEN qga/qapi-generated/qga-qmp-commands.h GEN qga/qapi-generated/qga-qapi-types.h GEN qga/qapi-generated/qga-qapi-visit.h GEN qga/qapi-generated/qga-qapi-types.c GEN qapi-types.c GEN qga/qapi-generated/qga-qapi-visit.c GEN qga/qapi-generated/qga-qmp-marshal.c GEN qmp-introspect.c GEN qapi-visit.c GEN qapi-event.c CC qapi/qapi-visit-core.o CC qapi/qapi-dealloc-visitor.o CC qapi/qobject-input-visitor.o CC qapi/qobject-output-visitor.o CC qapi/qmp-registry.o CC qapi/qmp-dispatch.o CC qapi/string-input-visitor.o CC qapi/string-output-visitor.o CC qapi/opts-visitor.o CC qapi/qapi-clone-visitor.o CC qapi/qmp-event.o CC qapi/qapi-util.o CC qobject/qnull.o CC qobject/qint.o CC qobject/qstring.o CC qobject/qdict.o CC qobject/qlist.o CC qobject/qfloat.o CC qobject/qbool.o CC qobject/qjson.o CC qobject/qobject.o CC qobject/json-lexer.o CC qobject/json-streamer.o CC qobject/json-parser.o GEN trace/generated-tracers.c CC trace/control.o CC trace/qmp.o CC util/osdep.o CC util/cutils.o CC util/unicode.o CC util/qemu-timer-common.o CC util/bufferiszero.o CC util/event_notifier-posix.o CC util/compatfd.o CC util/mmap-alloc.o CC util/oslib-posix.o CC util/qemu-openpty.o CC util/qemu-thread-posix.o CC util/memfd.o CC util/envlist.o CC util/path.o CC util/module.o CC util/bitmap.o CC util/bitops.o CC util/hbitmap.o CC util/acl.o CC util/fifo8.o CC util/error.o CC util/qemu-error.o CC util/id.o CC util/iov.o CC util/qemu-config.o CC util/qemu-sockets.o CC util/notify.o CC util/uri.o CC util/qemu-option.o CC util/qemu-progress.o CC util/crc32c.o CC util/uuid.o CC util/hexdump.o CC util/throttle.o CC util/getauxval.o CC util/readline.o CC util/rcu.o CC util/qemu-coroutine.o CC util/qemu-coroutine-lock.o CC util/qemu-coroutine-io.o CC util/qemu-coroutine-sleep.o CC util/coroutine-ucontext.o CC util/buffer.o CC util/timed-average.o CC util/base64.o CC util/log.o CC util/qht.o CC util/qdist.o CC util/range.o CC stubs/arch-query-cpu-def.o CC crypto/pbkdf-stub.o CC stubs/arch-query-cpu-model-comparison.o CC stubs/arch-query-cpu-model-expansion.o CC stubs/arch-query-cpu-model-baseline.o CC stubs/blk-commit-all.o CC stubs/bdrv-next-monitor-owned.o CC stubs/blockdev-close-all-bdrv-states.o CC stubs/clock-warp.o CC stubs/cpu-get-clock.o CC stubs/cpu-get-icount.o CC stubs/dump.o CC stubs/error-printf.o CC stubs/fdset-add-fd.o CC stubs/fdset-find-fd.o CC stubs/fdset-get-fd.o CC stubs/fdset-remove-fd.o CC stubs/gdbstub.o CC stubs/get-fd.o CC stubs/get-next-serial.o CC stubs/get-vm-name.o CC stubs/iothread.o CC stubs/iothread-lock.o CC stubs/is-daemonized.o CC stubs/machine-init-done.o CC stubs/migr-blocker.o CC stubs/mon-is-qmp.o CC stubs/monitor-init.o CC stubs/notify-event.o CC stubs/qtest.o CC stubs/replay.o CC stubs/replay-user.o CC stubs/reset.o CC stubs/runstate-check.o CC stubs/set-fd-handler.o CC stubs/slirp.o CC stubs/sysbus.o CC stubs/trace-control.o CC stubs/uuid.o CC stubs/vm-stop.o CC stubs/vmstate.o CC stubs/cpus.o CC stubs/qmp_pc_dimm_device_list.o CC stubs/kvm.o CC stubs/target-monitor-defs.o CC stubs/target-get-monitor-def.o CC stubs/vhost.o CC stubs/iohandler.o CC stubs/smbios_type_38.o CC stubs/ipmi.o CC stubs/pc_madt_cpu_entry.o CC stubs/migration-colo.o CC contrib/ivshmem-client/ivshmem-client.o CC contrib/ivshmem-client/main.o CC contrib/ivshmem-server/ivshmem-server.o CC contrib/ivshmem-server/main.o CC qemu-nbd.o CC thread-pool.o CC async.o CC block.o CC blockjob.o CC main-loop.o CC iohandler.o CC qemu-timer.o CC aio-posix.o CC qemu-io-cmds.o CC replication.o CC block/raw_bsd.o CC block/qcow.o CC block/vdi.o CC block/vmdk.o CC block/cloop.o CC block/vpc.o CC block/bochs.o CC block/vvfat.o CC block/dmg.o CC block/qcow2.o CC block/qcow2-refcount.o CC block/qcow2-snapshot.o CC block/qcow2-cluster.o CC block/qcow2-cache.o CC block/qed.o CC block/qed-gencb.o CC block/qed-l2-cache.o CC block/qed-table.o CC block/qed-cluster.o CC block/vhdx.o CC block/qed-check.o CC block/vhdx-endian.o CC block/vhdx-log.o CC block/quorum.o CC block/parallels.o CC block/blkdebug.o CC block/blkverify.o CC block/block-backend.o CC block/blkreplay.o CC block/snapshot.o CC block/qapi.o CC block/raw-posix.o CC block/null.o CC block/mirror.o CC block/commit.o CC block/io.o CC block/throttle-groups.o CC block/nbd.o CC block/nbd-client.o CC block/sheepdog.o CC block/accounting.o CC block/dirty-bitmap.o CC block/write-threshold.o CC block/replication.o CC block/backup.o CC block/crypto.o CC nbd/server.o CC nbd/client.o CC nbd/common.o CC crypto/init.o CC crypto/hash.o CC crypto/hash-glib.o CC crypto/aes.o CC crypto/cipher.o CC crypto/desrfb.o CC crypto/tlscreds.o CC crypto/tlscredsanon.o CC crypto/tlscredsx509.o CC crypto/tlssession.o CC crypto/secret.o CC crypto/random-platform.o CC crypto/pbkdf.o CC crypto/ivgen.o CC crypto/ivgen-essiv.o CC crypto/ivgen-plain.o CC crypto/ivgen-plain64.o CC crypto/afsplit.o CC crypto/xts.o CC crypto/block.o CC crypto/block-qcow.o CC crypto/block-luks.o CC io/channel.o CC io/channel-buffer.o CC io/channel-command.o CC io/channel-file.o CC io/channel-socket.o CC io/channel-tls.o CC io/channel-watch.o CC io/channel-util.o CC io/channel-websock.o CC io/task.o CC qom/object.o CC qom/container.o CC qom/qom-qobject.o CC qom/object_interfaces.o GEN qemu-img-cmds.h CC qemu-io.o CC qemu-bridge-helper.o CC blockdev.o CC blockdev-nbd.o CC iothread.o CC qdev-monitor.o CC device-hotplug.o CC os-posix.o CC qemu-char.o CC page_cache.o CC accel.o CC bt-host.o CC bt-vhci.o CC dma-helpers.o CC vl.o CC tpm.o GEN qmp-marshal.c CC device_tree.o CC qmp.o CC hmp.o CC cpus-common.o CC audio/audio.o CC audio/noaudio.o CC audio/wavaudio.o CC audio/mixeng.o
/tmp/qemu-test/src/block/sheepdog.c:393: error: redefinition of typedef ‘BDRVSheepdogState’ /tmp/qemu-test/src/block/sheepdog.c:309: note: previous declaration of ‘BDRVSheepdogState’ was here
make: *** [block/sheepdog.o] Error 1
make: *** Waiting for unfinished jobs....
CC audio/sdlaudio.o
make[1]: *** [docker-run] Error 2
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-pdjhtmz8/src'
make: *** [docker-run-test-quick@centos6] Error 2
=== OUTPUT END ===
Test command exited with code: 2
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]