From patchwork Tue Jul 23 08:30:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 260984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 97FA22C0095 for ; Tue, 23 Jul 2013 18:35:08 +1000 (EST) Received: from localhost ([::1]:58496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y3l-0002Sk-SF for incoming@patchwork.ozlabs.org; Tue, 23 Jul 2013 04:35:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y0N-0005HB-Lf for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Y0I-0001j8-Iw for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:35 -0400 Received: from sh.osrg.net ([192.16.179.4]:37893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y0I-0001iD-33 for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:30 -0400 Received: from fs.osrg.net (localns.osrg.net [10.0.0.11]) by sh.osrg.net (8.14.4/8.14.4/OSRG-NET) with ESMTP id r6N8V83u010587; Tue, 23 Jul 2013 17:31:08 +0900 Received: from localhost (unknown [10.32.32.72]) by fs.osrg.net (Postfix) with ESMTP id 779A2F951; Tue, 23 Jul 2013 17:31:07 +0900 (JST) From: MORITA Kazutaka To: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org Date: Tue, 23 Jul 2013 17:30:20 +0900 Message-Id: <1374568221-23147-11-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.8.1.3.566.gaa39828 In-Reply-To: <1374568221-23147-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> References: <1374568221-23147-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Dispatcher: imput version 20100215(IM150) Lines: 189 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (sh.osrg.net [192.16.179.4]); Tue, 23 Jul 2013 17:31:08 +0900 (JST) X-Virus-Scanned: clamav-milter 0.97.8 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 192.16.179.4 Cc: sheepdog@lists.wpkg.org Subject: [Qemu-devel] [PATCH 10/11] sheepdog: make add_aio_request and send_aioreq void functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These functions no longer return errors. We can make them void functions and simplify the codes. Signed-off-by: MORITA Kazutaka --- block/sheepdog.c | 66 +++++++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index cd72927..8a6c432 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -667,10 +667,10 @@ static int do_req(int sockfd, SheepdogReq *hdr, void *data, return srco.ret; } -static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, +static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, struct iovec *iov, int niov, bool create, enum AIOCBState aiocb_type); -static int coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req); +static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req); static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char *tag); static int get_sheep_fd(BDRVSheepdogState *s); static void co_write_request(void *opaque); @@ -696,22 +696,14 @@ static void coroutine_fn send_pending_req(BDRVSheepdogState *s, uint64_t oid) { AIOReq *aio_req; SheepdogAIOCB *acb; - int ret; while ((aio_req = find_pending_req(s, oid)) != NULL) { acb = aio_req->aiocb; /* move aio_req from pending list to inflight one */ QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); - ret = add_aio_request(s, aio_req, acb->qiov->iov, - acb->qiov->niov, false, acb->aiocb_type); - if (ret < 0) { - error_report("add_aio_request is failed"); - free_aio_req(s, aio_req); - if (!acb->nr_pending) { - sd_finish_aiocb(acb); - } - } + add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, false, + acb->aiocb_type); } } @@ -867,11 +859,8 @@ static void coroutine_fn aio_read_response(void *opaque) } else { aio_req->oid = vid_to_vdi_oid(s->inode.vdi_id); } - ret = resend_aioreq(s, aio_req); - if (ret == SD_RES_SUCCESS) { - goto out; - } - /* fall through */ + resend_aioreq(s, aio_req); + goto out; default: acb->ret = -EIO; error_report("%s", sd_strerror(rsp.result)); @@ -1129,7 +1118,7 @@ out: return ret; } -static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, +static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, struct iovec *iov, int niov, bool create, enum AIOCBState aiocb_type) { @@ -1209,8 +1198,6 @@ out: aio_flush_request, s); s->co_send = NULL; qemu_co_mutex_unlock(&s->lock); - - return 0; } static int read_write_object(int fd, char *buf, uint64_t oid, int copies, @@ -1313,7 +1300,7 @@ out: return ret; } -static int coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req) +static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req) { SheepdogAIOCB *acb = aio_req->aiocb; bool create = false; @@ -1338,7 +1325,7 @@ static int coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req) dprintf("simultaneous CoW to %" PRIx64 "\n", aio_req->oid); QLIST_REMOVE(aio_req, aio_siblings); QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings); - return SD_RES_SUCCESS; + return; } } @@ -1348,13 +1335,13 @@ static int coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req) } out: if (is_data_obj(aio_req->oid)) { - return add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, - create, acb->aiocb_type); + add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, create, + acb->aiocb_type); } else { struct iovec iov; iov.iov_base = &s->inode; iov.iov_len = sizeof(s->inode); - return add_aio_request(s, aio_req, &iov, 1, false, AIOCB_WRITE_UDATA); + add_aio_request(s, aio_req, &iov, 1, false, AIOCB_WRITE_UDATA); } } @@ -1744,7 +1731,6 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset) */ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) { - int ret; BDRVSheepdogState *s = acb->common.bs->opaque; struct iovec iov; AIOReq *aio_req; @@ -1766,18 +1752,13 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), data_len, offset, 0, 0, offset); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); - ret = add_aio_request(s, aio_req, &iov, 1, false, AIOCB_WRITE_UDATA); - if (ret) { - free_aio_req(s, aio_req); - acb->ret = -EIO; - goto out; - } + add_aio_request(s, aio_req, &iov, 1, false, AIOCB_WRITE_UDATA); acb->aio_done_func = sd_finish_aiocb; acb->aiocb_type = AIOCB_WRITE_UDATA; return; } -out: + sd_finish_aiocb(acb); } @@ -1984,14 +1965,8 @@ static int coroutine_fn sd_co_rw_vector(void *p) } QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); - ret = add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, - create, acb->aiocb_type); - if (ret < 0) { - error_report("add_aio_request is failed"); - free_aio_req(s, aio_req); - acb->ret = -EIO; - goto out; - } + add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, create, + acb->aiocb_type); done: offset = 0; idx++; @@ -2059,7 +2034,6 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) BDRVSheepdogState *s = bs->opaque; SheepdogAIOCB *acb; AIOReq *aio_req; - int ret; if (s->cache_flags != SD_FLAG_CMD_CACHE) { return 0; @@ -2072,13 +2046,7 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id), 0, 0, 0, 0, 0); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); - ret = add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type); - if (ret < 0) { - error_report("add_aio_request is failed"); - free_aio_req(s, aio_req); - qemu_aio_release(acb); - return ret; - } + add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type); qemu_coroutine_yield(); return acb->ret;