Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1538877

[PATCH 2/5] 9p: store req details and callback in struct p9_req_t

From Stefano Stabellini <sstabellini@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 2/5] 9p: store req details and callback in struct p9_req_t
Date 2016-12-08 22:00 +0100
Message-ID <sMdXk-2rQ-35@gated-at.bofh.it> (permalink)
References <sMdXk-2rQ-3@gated-at.bofh.it> <sMdXk-2rQ-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;
 	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);
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] async requests support for 9pfs Stefano Stabellini <sstabellini@kernel.org> - 2016-12-08 22:00 +0100
  [PATCH 2/5] 9p: store req details and callback in struct p9_req_t Stefano Stabellini <sstabellini@kernel.org> - 2016-12-08 22:00 +0100
    Re: [V9fs-developer] [PATCH 2/5] 9p: store req details and callback  in struct p9_req_t Dominique Martinet <dominique.martinet@cea.fr> - 2016-12-09 08:30 +0100
      Re: [V9fs-developer] [PATCH 2/5] 9p: store req details and callback  in struct p9_req_t Stefano Stabellini <sstabellini@kernel.org> - 2016-12-10 00:30 +0100
  [PATCH 3/5] 9p: introduce p9_client_get_req Stefano Stabellini <sstabellini@kernel.org> - 2016-12-08 22:10 +0100
  [PATCH 1/5] 9p: add iocb parameter to p9_client_read and p9_client_write Stefano Stabellini <sstabellini@kernel.org> - 2016-12-08 22:10 +0100

csiph-web