aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2006-12-05 16:35:11 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:48 -0500
commitffc2e518c91942b7ed45fb0ab7deba1ba0c8594a (patch)
tree64d712342ceb16e273fa242a9898f7af7d3d04c5 /net/sunrpc/xprtsock.c
parent94efa93435383b08d822a40f24ff6f6ce1a888df (diff)
SUNRPC: Allocate a private data area for socket-specific rpc_xprt fields
When setting up a new transport instance, allocate enough memory for an rpc_xprt and a private area. As part of the same memory allocation, it will be easy to find one, given a pointer to the other. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index ec3462f141b4..dc4a21f1a129 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -125,6 +125,10 @@ static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
125} 125}
126#endif 126#endif
127 127
128struct sock_xprt {
129 struct rpc_xprt xprt;
130};
131
128static void xs_format_peer_addresses(struct rpc_xprt *xprt) 132static void xs_format_peer_addresses(struct rpc_xprt *xprt)
129{ 133{
130 struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; 134 struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
@@ -1343,17 +1347,19 @@ static struct rpc_xprt_ops xs_tcp_ops = {
1343static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size) 1347static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size)
1344{ 1348{
1345 struct rpc_xprt *xprt; 1349 struct rpc_xprt *xprt;
1350 struct sock_xprt *new;
1346 1351
1347 if (addrlen > sizeof(xprt->addr)) { 1352 if (addrlen > sizeof(xprt->addr)) {
1348 dprintk("RPC: xs_setup_xprt: address too large\n"); 1353 dprintk("RPC: xs_setup_xprt: address too large\n");
1349 return ERR_PTR(-EBADF); 1354 return ERR_PTR(-EBADF);
1350 } 1355 }
1351 1356
1352 xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL); 1357 new = kzalloc(sizeof(*new), GFP_KERNEL);
1353 if (xprt == NULL) { 1358 if (new == NULL) {
1354 dprintk("RPC: xs_setup_xprt: couldn't allocate rpc_xprt\n"); 1359 dprintk("RPC: xs_setup_xprt: couldn't allocate rpc_xprt\n");
1355 return ERR_PTR(-ENOMEM); 1360 return ERR_PTR(-ENOMEM);
1356 } 1361 }
1362 xprt = &new->xprt;
1357 1363
1358 xprt->max_reqs = slot_table_size; 1364 xprt->max_reqs = slot_table_size;
1359 xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL); 1365 xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL);