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>
This commit is contained in:
Chuck Lever 2006-12-05 16:35:11 -05:00 коммит произвёл Trond Myklebust
Родитель 94efa93435
Коммит ffc2e518c9
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -125,6 +125,10 @@ static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
} }
#endif #endif
struct sock_xprt {
struct rpc_xprt xprt;
};
static void xs_format_peer_addresses(struct rpc_xprt *xprt) static void xs_format_peer_addresses(struct rpc_xprt *xprt)
{ {
struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
@ -1343,17 +1347,19 @@ static struct rpc_xprt_ops xs_tcp_ops = {
static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size) static struct rpc_xprt *xs_setup_xprt(struct sockaddr *addr, size_t addrlen, unsigned int slot_table_size)
{ {
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct sock_xprt *new;
if (addrlen > sizeof(xprt->addr)) { if (addrlen > sizeof(xprt->addr)) {
dprintk("RPC: xs_setup_xprt: address too large\n"); dprintk("RPC: xs_setup_xprt: address too large\n");
return ERR_PTR(-EBADF); return ERR_PTR(-EBADF);
} }
xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL); new = kzalloc(sizeof(*new), GFP_KERNEL);
if (xprt == NULL) { if (new == NULL) {
dprintk("RPC: xs_setup_xprt: couldn't allocate rpc_xprt\n"); dprintk("RPC: xs_setup_xprt: couldn't allocate rpc_xprt\n");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
xprt = &new->xprt;
xprt->max_reqs = slot_table_size; xprt->max_reqs = slot_table_size;
xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL); xprt->slot = kcalloc(xprt->max_reqs, sizeof(struct rpc_rqst), GFP_KERNEL);