summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprt.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2010-09-29 16:02:43 +0400
committerJ. Bruce Fields <bfields@redhat.com>2010-10-01 17:18:52 -0400
commitbd1722d4316e42a12fe6337ebe34d7e1e2c088b2 (patch)
tree358d45aaf5fb08a177fd6fbe5dcf8872160c30fc /net/sunrpc/xprt.c
parent2b44f1ba40914777f4b1075254ba97663d4e2574 (diff)
downloadlinux-bd1722d4316e42a12fe6337ebe34d7e1e2c088b2.tar.bz2
sunrpc: Factor out rpc_xprt allocation
Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r--net/sunrpc/xprt.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 970fb00f388c..26cbe219388b 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -962,6 +962,28 @@ static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
spin_unlock(&xprt->reserve_lock);
}
+struct rpc_xprt *xprt_alloc(int size, int max_req)
+{
+ struct rpc_xprt *xprt;
+
+ xprt = kzalloc(size, GFP_KERNEL);
+ if (xprt == NULL)
+ goto out;
+
+ xprt->max_reqs = max_req;
+ xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL);
+ if (xprt->slot == NULL)
+ goto out_free;
+
+ return xprt;
+
+out_free:
+ kfree(xprt);
+out:
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(xprt_alloc);
+
/**
* xprt_reserve - allocate an RPC request slot
* @task: RPC task requesting a slot allocation