[sheepdog] [PATCH 1/2] sheep: introduce async request handling
Hitoshi Mitake
mitake.hitoshi at gmail.com
Tue Dec 17 07:36:58 CET 2013
At Tue, 17 Dec 2013 14:17:30 +0800,
Liu Yuan wrote:
>
> On Tue, Dec 17, 2013 at 03:13:26PM +0900, Hitoshi Mitake wrote:
> > At Mon, 16 Dec 2013 21:16:38 +0800,
> > Liu Yuan wrote:
> > >
> > > This patch introduces async request framework that has the following usage
> > > patern:
> > >
> > > iocb = local_req_init();
> > >
> > > loop:
> > > ...
> > > exec_local_req_async(req, iocb);
> > > ...
> > >
> > > ret = local_req_wait(iocb);
> > >
> > > wait until all the reqs finish, if any req fails, just return it from
> > > local_req_wait();
> > >
> > > Request throttling should be handled by the async user.
> > >
> > > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > > ---
> > > sheep/request.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++----
> > > sheep/sheep.c | 2 +-
> > > sheep/sheep_priv.h | 13 +++++++-
> > > 3 files changed, 92 insertions(+), 8 deletions(-)
> >
> > Just a quick review.
> >
> > >
> > > diff --git a/sheep/request.c b/sheep/request.c
> > > index dfca8ee..53ccc04 100644
> > > --- a/sheep/request.c
> > > +++ b/sheep/request.c
> > > @@ -499,6 +499,15 @@ static void free_local_request(struct request *req)
> > > free(req);
> > > }
> > >
> > > +static void submit_local_request(struct request *req)
> > > +{
> > > + pthread_mutex_lock(&sys->local_req_lock);
> > > + list_add_tail(&req->request_list, &sys->local_req_queue);
> > > + pthread_mutex_unlock(&sys->local_req_lock);
> > > +
> > > + eventfd_xwrite(sys->local_req_efd, 1);
> > > +}
> > > +
> >
> > It seems that sys->local_req_efd is initialized with the return value
> > of eventfd(0, 0); IIUC, event write to a fd created by eventfd(0, 0)
> > can be blocked. SHould we use eventfd(0, EFD_NONBLOCK); for
> > asynchronous requests?
>
> sys->local_req_efd = eventfd(0, EFD_NONBLOCK); # line 912
I missed the line, sorry.
Thanks,
Hitoshi
More information about the sheepdog
mailing list