From: Simon Derr <simon.derr@bull.net>
To: netdev@vger.kernel.org
Cc: simon.derr@bull.net, ericvh@gmail.com
Subject: [PATCH 03/10] 9pnet: refactor struct p9_fcall alloc code
Date: Tue, 2 Jul 2013 15:11:17 +0200 [thread overview]
Message-ID: <1372770684-25573-4-git-send-email-simon.derr@bull.net> (raw)
In-Reply-To: <1372770684-25573-1-git-send-email-simon.derr@bull.net>
Signed-off-by: Simon Derr <simon.derr@bull.net>
---
net/9p/client.c | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 47cd7d0..44691b9 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);
--
1.7.2.2
next prev parent reply other threads:[~2013-07-02 13:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 13:11 [PATCH 00/10] Improve 9P/RDMA Simon Derr
2013-07-02 13:11 ` [PATCH 01/10] 9P: Fix fcall allocation for rdma Simon Derr
2013-07-02 13:11 ` [PATCH 02/10] 9P/RDMA: rdma_request() needs not allocate req->rc Simon Derr
2013-07-02 13:11 ` Simon Derr [this message]
2013-07-02 16:40 ` [PATCH 03/10] 9pnet: refactor struct p9_fcall alloc code Sergei Shtylyov
2013-07-02 13:11 ` [PATCH 04/10] 9P/RDMA: increase P9_RDMA_MAXSIZE to 1MB Simon Derr
2013-07-02 13:11 ` [PATCH 05/10] 9P/RDMA: Protect against duplicate replies Simon Derr
2013-07-02 13:11 ` [PATCH 06/10] 9P/RDMA: Use a semaphore to protect the RQ Simon Derr
2013-07-02 13:11 ` [PATCH 07/10] 9P/RDMA: Do not free req->rc in error handling in rdma_request() Simon Derr
2013-07-02 13:11 ` [PATCH 08/10] 9P/RDMA: Improve error handling in rdma_request Simon Derr
2013-07-02 13:11 ` [PATCH 09/10] 9P/RDMA: count posted buffers without a pending request Simon Derr
2013-07-02 13:11 ` [PATCH 10/10] 9P: Add cancelled() to the transport functions Simon Derr
2013-07-02 16:49 ` Sergei Shtylyov
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=1372770684-25573-4-git-send-email-simon.derr@bull.net \
--to=simon.derr@bull.net \
--cc=ericvh@gmail.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).