diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-10-17 19:08:10 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-10-18 12:13:32 -0400 |
commit | d77385f23830ee6c400569bac8b37e6eb3b7d360 (patch) | |
tree | 871501dccd72630f7aec103738e649c2fcb2fd9d | |
parent | 45402c38eec740f52422aafc92937c6a4a8c8c0e (diff) |
SUNRPC: Fix rpc_sockaddr2uaddr
rpc_sockaddr2uaddr is only used by net/sunrpc/rpcb_clnt.c, where
it is used in a non-blockable context in at least one case.
Add non-blocking capability by adding a gfp_t argument
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | include/linux/sunrpc/clnt.h | 3 | ||||
-rw-r--r-- | net/sunrpc/addr.c | 5 | ||||
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index db7bcaf7c5bd..d926fd1a5313 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #ifndef _LINUX_SUNRPC_CLNT_H | 9 | #ifndef _LINUX_SUNRPC_CLNT_H |
10 | #define _LINUX_SUNRPC_CLNT_H | 10 | #define _LINUX_SUNRPC_CLNT_H |
11 | 11 | ||
12 | #include <linux/types.h> | ||
12 | #include <linux/socket.h> | 13 | #include <linux/socket.h> |
13 | #include <linux/in.h> | 14 | #include <linux/in.h> |
14 | #include <linux/in6.h> | 15 | #include <linux/in6.h> |
@@ -161,7 +162,7 @@ const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); | |||
161 | size_t rpc_ntop(const struct sockaddr *, char *, const size_t); | 162 | size_t rpc_ntop(const struct sockaddr *, char *, const size_t); |
162 | size_t rpc_pton(const char *, const size_t, | 163 | size_t rpc_pton(const char *, const size_t, |
163 | struct sockaddr *, const size_t); | 164 | struct sockaddr *, const size_t); |
164 | char * rpc_sockaddr2uaddr(const struct sockaddr *); | 165 | char * rpc_sockaddr2uaddr(const struct sockaddr *, gfp_t); |
165 | size_t rpc_uaddr2sockaddr(const char *, const size_t, | 166 | size_t rpc_uaddr2sockaddr(const char *, const size_t, |
166 | struct sockaddr *, const size_t); | 167 | struct sockaddr *, const size_t); |
167 | 168 | ||
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index 4195233c4914..23cd19d45ab3 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
@@ -255,12 +255,13 @@ EXPORT_SYMBOL_GPL(rpc_pton); | |||
255 | /** | 255 | /** |
256 | * rpc_sockaddr2uaddr - Construct a universal address string from @sap. | 256 | * rpc_sockaddr2uaddr - Construct a universal address string from @sap. |
257 | * @sap: socket address | 257 | * @sap: socket address |
258 | * @gfp_flags: allocation mode | ||
258 | * | 259 | * |
259 | * Returns a %NUL-terminated string in dynamically allocated memory; | 260 | * Returns a %NUL-terminated string in dynamically allocated memory; |
260 | * otherwise NULL is returned if an error occurred. Caller must | 261 | * otherwise NULL is returned if an error occurred. Caller must |
261 | * free the returned string. | 262 | * free the returned string. |
262 | */ | 263 | */ |
263 | char *rpc_sockaddr2uaddr(const struct sockaddr *sap) | 264 | char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) |
264 | { | 265 | { |
265 | char portbuf[RPCBIND_MAXUADDRPLEN]; | 266 | char portbuf[RPCBIND_MAXUADDRPLEN]; |
266 | char addrbuf[RPCBIND_MAXUADDRLEN]; | 267 | char addrbuf[RPCBIND_MAXUADDRLEN]; |
@@ -288,7 +289,7 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap) | |||
288 | if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) | 289 | if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) |
289 | return NULL; | 290 | return NULL; |
290 | 291 | ||
291 | return kstrdup(addrbuf, GFP_KERNEL); | 292 | return kstrdup(addrbuf, gfp_flags); |
292 | } | 293 | } |
293 | EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr); | 294 | EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr); |
294 | 295 | ||
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index e45d2fbbe5a8..f588b852d41c 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -410,7 +410,7 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
410 | unsigned short port = ntohs(sin->sin_port); | 410 | unsigned short port = ntohs(sin->sin_port); |
411 | int result; | 411 | int result; |
412 | 412 | ||
413 | map->r_addr = rpc_sockaddr2uaddr(sap); | 413 | map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL); |
414 | 414 | ||
415 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 415 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
416 | "local rpcbind\n", (port ? "" : "un"), | 416 | "local rpcbind\n", (port ? "" : "un"), |
@@ -437,7 +437,7 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
437 | unsigned short port = ntohs(sin6->sin6_port); | 437 | unsigned short port = ntohs(sin6->sin6_port); |
438 | int result; | 438 | int result; |
439 | 439 | ||
440 | map->r_addr = rpc_sockaddr2uaddr(sap); | 440 | map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL); |
441 | 441 | ||
442 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | 442 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " |
443 | "local rpcbind\n", (port ? "" : "un"), | 443 | "local rpcbind\n", (port ? "" : "un"), |
@@ -686,7 +686,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
686 | case RPCBVERS_4: | 686 | case RPCBVERS_4: |
687 | case RPCBVERS_3: | 687 | case RPCBVERS_3: |
688 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | 688 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); |
689 | map->r_addr = rpc_sockaddr2uaddr(sap); | 689 | map->r_addr = rpc_sockaddr2uaddr(sap, GFP_ATOMIC); |
690 | map->r_owner = ""; | 690 | map->r_owner = ""; |
691 | break; | 691 | break; |
692 | case RPCBVERS_2: | 692 | case RPCBVERS_2: |