From: Dominique Martinet <dominique.martinet@cea.fr>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: v9fs-developer@lists.sourceforge.net, ericvh@gmail.com,
rminnich@sandia.gov, linux-kernel@vger.kernel.org,
lucho@ionkov.net
Subject: Re: [V9fs-developer] [PATCH 2/5] 9p: store req details and callback in struct p9_req_t
Date: Fri, 9 Dec 2016 08:18:24 +0100 [thread overview]
Message-ID: <20161209071824.GC18158@nautica> (raw)
In-Reply-To: <1481230746-16741-2-git-send-email-sstabellini@kernel.org>
Nice. I like the idea of async I/Os :)
Stefano Stabellini wrote on Thu, Dec 08, 2016:
> Add a few fields to struct p9_req_t. Callback is the function which will
> be called upon requestion completion. offset, rsize, pagevec and kiocb
> store important information regarding the read or write request,
> essential to complete the request.
>
> Currently not utilized, but they will be used in a later patch.
>
> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> include/net/9p/client.h | 8 ++++++++
> net/9p/client.c | 9 ++++++++-
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/9p/client.h b/include/net/9p/client.h
> index aef19c6..69fc2f0 100644
> --- a/include/net/9p/client.h
> +++ b/include/net/9p/client.h
> @@ -110,6 +110,7 @@ enum p9_req_status_t {
> *
> */
>
> +struct p9_client;
> struct p9_req_t {
> int status;
> int t_err;
> @@ -118,6 +119,13 @@ struct p9_req_t {
> struct p9_fcall *rc;
> void *aux;
>
> + /* Used for async requests */
> + void (*callback)(struct p9_client *c, struct p9_req_t *req, int status);
> + size_t offset;
> + u64 rsize;
> + struct page **pagevec;
> + struct kiocb *kiocb;
> +
> struct list_head req_list;
> };
>
> diff --git a/net/9p/client.c b/net/9p/client.c
> index b5ea9a3..bfe1715 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -405,6 +405,10 @@ static void p9_free_req(struct p9_client *c, struct p9_req_t *r)
> int tag = r->tc->tag;
> p9_debug(P9_DEBUG_MUX, "clnt %p req %p tag: %d\n", c, r, tag);
>
> + r->offset = 0;
> + r->rsize = 0;
> + r->kiocb = NULL;
> + r->callback = NULL;
Probably want to cleanup r->pagevec here too, even if that doesn't seem
to have any implication short-term (e.g. only looked at if callback is
not empty from what I've seen)
> r->status = REQ_STATUS_IDLE;
> if (tag != P9_NOTAG && p9_idpool_check(tag, c->tagpool))
> p9_idpool_put(tag, c->tagpool);
> @@ -427,7 +431,10 @@ void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)
> smp_wmb();
> req->status = status;
>
> - wake_up(req->wq);
> + if (req->callback != NULL)
> + req->callback(c, req, status);
> + else
> + wake_up(req->wq);
> p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc->tag);
> }
> EXPORT_SYMBOL(p9_client_cb);
Mostly a warning here, but p9_client_cb is called from an interrupt
context in 9P/RDMA.
This has been working up till now because we only do a wake_up and
there's no waiting, but (looking at later patches),
p9_client_read_complete for example does allocations and possibly other
unsafe operations from an interrupt context.
I don't know if the way forward is to move p9_client_cb from that
context or to have the callback be scheduled in a work queue instead;
but we'll need to fix that later.
--
Dominique Martinet
next prev parent reply other threads:[~2016-12-09 7:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 20:58 [PATCH 0/5] async requests support for 9pfs Stefano Stabellini
2016-12-08 20:59 ` [PATCH 1/5] 9p: add iocb parameter to p9_client_read and p9_client_write Stefano Stabellini
2016-12-08 20:59 ` [PATCH 2/5] 9p: store req details and callback in struct p9_req_t Stefano Stabellini
2016-12-09 7:18 ` Dominique Martinet [this message]
2016-12-09 23:24 ` [V9fs-developer] " Stefano Stabellini
2016-12-08 20:59 ` [PATCH 3/5] 9p: introduce p9_client_get_req Stefano Stabellini
2016-12-08 20:59 ` [PATCH 4/5] 9p: introduce async read requests Stefano Stabellini
2016-12-09 7:27 ` [V9fs-developer] " Dominique Martinet
2016-12-09 22:22 ` Stefano Stabellini
2016-12-10 1:50 ` Al Viro
2016-12-13 1:15 ` Stefano Stabellini
2016-12-13 14:29 ` Latchesar Ionkov
2016-12-08 20:59 ` [PATCH 5/5] 9p: introduce async write requests Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161209071824.GC18158@nautica \
--to=dominique.martinet@cea.fr \
--cc=ericvh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=rminnich@sandia.gov \
--cc=sstabellini@kernel.org \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.