From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2axT-0005wF-Bm for qemu-devel@nongnu.org; Fri, 26 Jul 2013 01:52:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2axS-0005Cg-Dj for qemu-devel@nongnu.org; Fri, 26 Jul 2013 01:52:55 -0400 Received: from sh.osrg.net ([192.16.179.4]:40799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2axR-0005CS-Ra for qemu-devel@nongnu.org; Fri, 26 Jul 2013 01:52:54 -0400 Date: Fri, 26 Jul 2013 14:53:04 +0900 Message-ID: <87a9l93m0v.wl%morita.kazutaka@lab.ntt.co.jp> From: MORITA Kazutaka In-Reply-To: <20130725132043.GA9877@ubuntu-precise> References: <1374741125-31859-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1374741125-31859-8-git-send-email-morita.kazutaka@lab.ntt.co.jp> <20130725091346.GD2604@ubuntu-precise> <20130725132043.GA9877@ubuntu-precise> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [sheepdog] [PATCH v3 07/10] sheepdog: try to reconnect to sheepdog after network error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Yuan Cc: Kevin Wolf , sheepdog@lists.wpkg.org, MORITA Kazutaka , qemu-devel@nongnu.org, Stefan Hajnoczi , Paolo Bonzini , MORITA Kazutaka At Thu, 25 Jul 2013 21:20:43 +0800, Liu Yuan wrote: > > On Thu, Jul 25, 2013 at 09:53:14PM +0900, MORITA Kazutaka wrote: > > At Thu, 25 Jul 2013 17:13:46 +0800, > > Liu Yuan wrote: > > > > > > > + > > > > + /* Try to reconnect the sheepdog server every one second. */ > > > > + while (s->fd < 0) { > > > > + s->fd = get_sheep_fd(s); > > > > + if (s->fd < 0) { > > > > + dprintf("Wait for connection to be established\n"); > > > > + co_aio_sleep_ns(1000000000ULL); > > > > + } > > > > + }; > > > > + > > > > + /* Move all the inflight requests to the failed queue. */ > > > > + QLIST_FOREACH_SAFE(aio_req, &s->inflight_aio_head, aio_siblings, next) { > > > > + QLIST_REMOVE(aio_req, aio_siblings); > > > > + QLIST_INSERT_HEAD(&s->failed_aio_head, aio_req, aio_siblings); > > > > + } > > > > + > > > > + /* Resend all the failed aio requests. */ > > > > + 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); > > > > + } > > > > +} > > > > + > > > > > > Is failed queue necessary? Here you just move requests from inflight queue to > > > failed queue, then interate the failed queue to send them all. > > > > > > Isn't it simpler we just resend the requests in the inflight queue like > > > > > > > + QLIST_FOREACH(aio_req, &s->inflight_aio_head, aio_siblings, next) { > > > > + resend_aioreq(s, aio_req); > > > > + } > > > > resend_aioreq() can yield and a new aio request can be added to the > > inflight queue during this loop. To avoid mixing new requests and > > failed ones, I think the failed queue is necessary. > > > > Okay, make sense. This should be included in the source file. You can add my Okay, thanks for your review and comments. Kazutaka > > Tested-and-reviewed-by: Liu Yuan > > to sheepdog patches > > Thanks, > Yuan