[PATCH v2 2/7] 9p: store req details and workqueue in struct p9_req_t

From: Stefano Stabellini
Date: Thu Dec 15 2016 - 17:14:25 EST


Add a few fields to struct p9_req_t: page offset, file offset, total
request size, completed, rsize pagevec and kiocb store important
information regarding the read or write request, essential to complete
the request. work is used to schedule a callback function, called upon
request completion.

Currently not utilized, but they will be used in a later patch.

Signed-off-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>

---
Changes in v2:
- clear pagevec
- replace callback with work_struct
- rename offset to page_offset
- add file_offset
- add fid
- add completed and tot_size
---
include/net/9p/client.h | 12 ++++++++++++
net/9p/client.c | 13 ++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index aef19c6..0e53b7f 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -110,7 +110,9 @@ enum p9_req_status_t {
*
*/

+struct p9_fid;
struct p9_req_t {
+ struct p9_fid *fid;
int status;
int t_err;
wait_queue_head_t *wq;
@@ -118,6 +120,16 @@ struct p9_req_t {
struct p9_fcall *rc;
void *aux;

+ /* Used for async requests */
+ struct work_struct work;
+ size_t file_offset;
+ size_t page_offset;
+ size_t tot_size;
+ size_t completed;
+ unsigned int 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..517bc20 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -405,6 +405,14 @@ 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->fid = NULL;
+ r->file_offset = 0;
+ r->page_offset = 0;
+ r->tot_size = 0;
+ r->completed = 0;
+ r->rsize = 0;
+ r->kiocb = NULL;
+ r->pagevec = NULL;
r->status = REQ_STATUS_IDLE;
if (tag != P9_NOTAG && p9_idpool_check(tag, c->tagpool))
p9_idpool_put(tag, c->tagpool);
@@ -427,7 +435,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->kiocb != NULL)
+ schedule_work(&req->work);
+ else
+ wake_up(req->wq);
p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc->tag);
}
EXPORT_SYMBOL(p9_client_cb);
--
1.9.1