summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSimon Derr <simon.derr@bull.net>2013-06-21 15:32:36 +0200
committerEric Van Hensbergen <ericvh@gmail.com>2013-07-08 05:02:27 +0200
commit5387320d4814aa1e40b50529d960a8f2b3340535 (patch)
tree87b7a46b37e7f2800e65f7e159c9c99d03c65e31 /net
parent9P/RDMA: rdma_request() needs not allocate req->rc (diff)
downloadlinux-5387320d4814aa1e40b50529d960a8f2b3340535.tar.xz
linux-5387320d4814aa1e40b50529d960a8f2b3340535.zip
9pnet: refactor struct p9_fcall alloc code
Signed-off-by: Simon Derr <simon.derr@bull.net> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/9p/client.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index 5828769d1f3d..db5bf2480a33 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -204,6 +204,17 @@ free_and_return:
return ret;
}
+struct p9_fcall *p9_fcall_alloc(int alloc_msize)
+{
+ struct p9_fcall *fc;
+ fc = kmalloc(sizeof(struct p9_fcall) + alloc_msize, GFP_NOFS);
+ if (!fc)
+ return NULL;
+ fc->capacity = alloc_msize;
+ fc->sdata = (char *) fc + sizeof(struct p9_fcall);
+ return fc;
+}
+
/**
* p9_tag_alloc - lookup/allocate a request by tag
* @c: client session to lookup tag within
@@ -256,29 +267,19 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
col = tag % P9_ROW_MAXTAG;
req = &c->reqs[row][col];
- if (!req->tc) {
+ if (!req->wq) {
req->wq = kmalloc(sizeof(wait_queue_head_t), GFP_NOFS);
if (!req->wq)
goto grow_failed;
-
init_waitqueue_head(req->wq);
- req->tc = kmalloc(sizeof(struct p9_fcall) + alloc_msize,
- GFP_NOFS);
- if (!req->tc)
- goto grow_failed;
-
- req->tc->capacity = alloc_msize;
- req->tc->sdata = (char *) req->tc + sizeof(struct p9_fcall);
}
- if (!req->rc) {
- req->rc = kmalloc(sizeof(struct p9_fcall) + alloc_msize,
- GFP_NOFS);
- if (!req->rc)
- goto grow_failed;
- req->rc->capacity = alloc_msize;
- req->rc->sdata = (char *) req->rc + sizeof(struct p9_fcall);
- }
+ if (!req->tc)
+ req->tc = p9_fcall_alloc(alloc_msize);
+ if (!req->rc)
+ req->rc = p9_fcall_alloc(alloc_msize);
+ if (!req->tc || !req->rc)
+ goto grow_failed;
p9pdu_reset(req->tc);
p9pdu_reset(req->rc);