History log of /net/sunrpc/rpcb_clnt.c
Revision Date Author Comments
786615bc1ce84150ded80daea6bd9f6297f48e73 05-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: If the rpcbind channel is disconnected, fail the call to unregister

If rpcbind causes our connection to the AF_LOCAL socket to close after
we've registered a service, then we want to be careful about reconnecting
since the mount namespace may have changed.

By simply refusing to reconnect the AF_LOCAL socket in the case of
unregister, we avoid the need to somehow save the mount namespace. While
this may lead to some services not unregistering properly, it should
be safe.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Nix <nix@esperi.org.uk>
Cc: Jeff Layton <jlayton@redhat.com>
Cc: stable@vger.kernel.org # 3.9.x
00326ed6442c66021cd4b5e19e80f3e2027d5d42 05-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't auto-disconnect from the local rpcbind socket

There is no need for the kernel to time out the AF_LOCAL connection to
the rpcbind socket, and doing so is problematic because when it is
time to reconnect, our process may no longer be using the same mount
namespace.

Reported-by: Nix <nix@esperi.org.uk>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Jeff Layton <jlayton@redhat.com>
Cc: stable@vger.kernel.org # 3.9.x
5976687a2b3d1969f02aba16b80ad3ed79be6ad3 04-Feb-2013 Jeff Layton <jlayton@redhat.com> sunrpc: move address copy/cmp/convert routines and prototypes from clnt.h to addr.h

These routines are used by server and client code, so having them in a
separate header would be best.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
756933ee8a75970ca7d8a10e922f5d44720457a4 04-Dec-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove redundant "linux/nsproxy.h" includes

This is a cleanup patch.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
332e008a44d1ab6ca85b2214578f2f89af04a2fc 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from encode_rpcb_string

Replace BUG_ON() with WARN_ON_ONCE() and truncate the encoded string if
len > max.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
caea33da898e4e14f0ba58173e3b7689981d2c0b 20-Jul-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: return negative value in case rpcbind client creation error

Without this patch kernel will panic on LockD start, because lockd_up() checks
lockd_up_net() result for negative value.
From my pow it's better to return negative value from rpcbind routines instead
of replacing all such checks like in lockd_up().

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org [>= 3.0]
9793f7c88937e7ac07305ab1af1a519225836823 02-May-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: new svc_bind() routine introduced

This new routine is responsible for service registration in a specified
network context.

The idea is to separate service creation from per-net operations.

Note also: since registering service with svc_bind() can fail, the
service will be destroyed and during destruction it will try to
unregister itself from rpcbind. In this case unregistration has to be
skipped.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
bda14606a3c055dbbccd998fa91eb87c4c7b2027 13-May-2012 Randy Dunlap <rdunlap@xenotime.net> sunrpc: fix kernel-doc warnings

Fix kernel-doc warnings in sunrpc/rpc_pipe.c and
sunrpc/rpcb_clnt.c:

Warning(net/sunrpc/rpcb_clnt.c:428): No description found for parameter 'net'
Warning(net/sunrpc/rpcb_clnt.c:567): No description found for parameter 'net'

Warning(net/sunrpc/rpc_pipe.c:133): No description found for parameter 'pipe'
Warning(net/sunrpc/rpc_pipe.c:133): Excess function parameter 'inode' description in 'rpc_queue_upcall'
Warning(net/sunrpc/rpc_pipe.c:839): No description found for parameter 'pipe'
Warning(net/sunrpc/rpc_pipe.c:839): Excess function parameter 'ops' description in 'rpc_mkpipe_dentry'
Warning(net/sunrpc/rpc_pipe.c:839): Excess function parameter 'flags' description in 'rpc_mkpipe_dentry'
Warning(net/sunrpc/rpc_pipe.c:949): No description found for parameter 'dentry'
Warning(net/sunrpc/rpc_pipe.c:949): Excess function parameter 'clnt' description in 'rpc_remove_client_dir'

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
864cf9bf99f62d2095c8e6cc3a87af80b263984e 27-Mar-2012 Bryan Schumaker <bjschuma@netapp.com> SUNRPC: Use the already looked-up xprt in rpcb_getport_async()

rbcb_getport_async() was looking up the rpc_xprt (reference++) and then
later looking it up again (reference++) to pass through the
rpcbind_args. The xprt would only be dereferenced once, when we were
done with the rpcbind_args (reference--). This leaves an extra
reference to the transport that would never go away.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ffa94db6042e6fd014ae0bed8832ac707ef2afe9 20-Mar-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC/LOCKD: Fix build warnings when CONFIG_SUNRPC_DEBUG is undefined

Stephen Rothwell reports:
net/sunrpc/rpcb_clnt.c: In function 'rpcb_enc_mapping':
net/sunrpc/rpcb_clnt.c:820:19: warning: unused variable 'task' [-Wunused-variable]
net/sunrpc/rpcb_clnt.c: In function 'rpcb_dec_getport':
net/sunrpc/rpcb_clnt.c:837:19: warning: unused variable 'task' [-Wunused-variable]
net/sunrpc/rpcb_clnt.c: In function 'rpcb_dec_set':
net/sunrpc/rpcb_clnt.c:860:19: warning: unused variable 'task' [-Wunused-variable]
net/sunrpc/rpcb_clnt.c: In function 'rpcb_enc_getaddr':
net/sunrpc/rpcb_clnt.c:892:19: warning: unused variable 'task' [-Wunused-variable]
net/sunrpc/rpcb_clnt.c: In function 'rpcb_dec_getaddr':
net/sunrpc/rpcb_clnt.c:914:19: warning: unused variable 'task' [-Wunused-variable]
fs/lockd/svclock.c:49:20: warning: 'nlmdbg_cookie2a' declared 'static' but never defined [-Wunused-function]

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4e0038b6b246e4145fc4a53dca61a556d17bc52c 01-Mar-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move clnt->cl_server into struct rpc_xprt

When the cl_xprt field is updated, the cl_server field will also have
to change. Since the contents of cl_server follow the remote endpoint
of cl_xprt, just move that field to the rpc_xprt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: simplify check_gss_callback_principal(), whitespace changes ]
[ cel: forward ported to 3.4 ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2446ab6070861aba2dd9229463ffbc40016a9f33 01-Mar-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field

A migration event will replace the rpc_xprt used by an rpc_clnt. To
ensure this can be done safely, all references to cl_xprt must now use
a form of rcu_dereference().

Special care is taken with rpc_peeraddr2str(), which returns a pointer
to memory whose lifetime is the same as the rpc_xprt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: fix lockdep splats and layering violations ]
[ cel: forward ported to 3.4 ]
[ cel: remove rpc_max_reqs(), add rpc_net_ns() ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a613fa168afc19179a7547fbba45644c5b6912bf 20-Jan-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: constify the rpc_program

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6eac7d3f45a2519283d38bf670cb6968230124f8 20-Jan-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: constify rpc_clnt fields cl_server and cl_protname

...and get rid of the superfluous cl_inline_name.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b030fb0bb113316cc6f56779388b8572ab0699da 13-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: use proper network namespace in rpcbind RPCBPROC_GETADDR procedure

Pass request socket network namespace to rpc_uaddr2sockaddr() instead of
hardcoded "init_net", when decoding address in RPCBPROC_GETADDR procedure.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f2ac4dc911fdbc9b98a6a48b40efc45aa9161775 13-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: parametrize rpc_uaddr2sockaddr() by network context

Parametrize rpc_uaddr2sockaddr() by network context and thus force it's callers to pass
in network context instead of using hard-coded "init_net".

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f7a30c18e8d673c996095420a026a28433cb4096 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: parametrize local rpcbind clients creation with net ns

These client are per network namespace and thus can be created for different
network namespaces.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
977ac3157328239a0f4074b13a3d9eb5c832cd6c 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: register rpcbind programs in passed network namespase context

Registering rpcbind program requires rpcbind clients, which are per network
namespace context.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c2550e07a61a4528673fb85aaaee16048b7cf6cc 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: create rpcbind client in passed network namespace context

Rpcbind clients are per network namespace.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1a114a66466ba914a41df438e806fc10e7d9fb3b 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: optimize net_ns dereferencing in rpcbind registering calls

Static rpcbind registering functions can be parametrized by network namespace
pointer, calculated only once, instead of using init_net pointer (or taking it
from current when virtualization will be comleted) in many places.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2ea75a10add779b722650aa10836247e7d609fd7 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: optimize net_ns dereferencing in rpcbind creation calls

Static rpcbind creation functions can be parametrized by network namespace
pointer, calculated only once, instead of using init_net pointer (or taking it
from current when virtualization will be comleted) in many places.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
dff02d499c067bdde589b764321b35fe763569f6 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: move rpcbind internals to sunrpc part of network namespace context

This patch makes rpcbind logic works in network namespace context. IOW each
network namespace will have it's own unique rpcbind internals (clients and
friends) required for registering svc services per network namespace.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e20de377578e9504f8467c05ab1db98b4935d4ed 25-Oct-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove rpcbind clients destruction on module cleanup

Rpcbind clients destruction during SUNRPC module removing is obsolete since now
those clients are destroying during last RPC service shutdown.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0f0c01da444fbfd63556f301dde15915fd6cbb20 25-Oct-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove rpcbind clients creation during service registering

We don't need this code since rpcbind clients are creating during RPC service
creation.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d99085605cd245d8f24858e9d0b06013e13aa044 25-Oct-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: introduce svc helpers for prepairing rpcbind infrastructure

This helpers will be used only for those services, that will send portmapper
registration calls.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
253fb070e78db981740b000914b04b9203092925 25-Oct-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: use rpcbind reference counting helpers

All is simple: we just increase users counter if rpcbind clients has been
created already. Otherwise we create them and set users counter to 1.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
914edb1bb2abe2ae4775368f2ffb7f41010fb81e 25-Oct-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: introduce helpers for reference counted rpcbind clients

v6:
1) added write memory barrier to rpcb_set_local to make sure, that rpcbind
clients become valid before rpcb_users assignment
2) explicitly set rpcb_users to 1 instead of incrementing it (looks clearer from
my pow).

v5: fixed races with rpcb_users in rpcb_get_local()

This helpers will be used for dynamical creation and destruction of rpcbind
clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind
clients has been created already, then we just increase rpcb_users.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d77385f23830ee6c400569bac8b37e6eb3b7d360 18-Oct-2011 Trond Myklebust <Trond.Myklebust@netapp.com> 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>
ec0dd267bf7d08cb30e321e45a75fd40edd7e528 12-Jul-2011 Ben Greear <greearb@candelatech.com> SUNRPC: Fix use of static variable in rpcb_getport_async

Because struct rpcbind_args *map was declared static, if two
threads entered this method at the same time, the values
assigned to map could be sent two two differen tasks.
This could cause all sorts of problems, include use-after-free
and double-free of memory.

Fix this by removing the static declaration so that the map
pointer is on the stack.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7402ab19cdd5943c7dd4f3399afe3abda8077ef5 09-May-2011 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use AF_LOCAL for rpcbind upcalls

As libtirpc does in user space, have our registration API try using an
AF_LOCAL transport first when registering and unregistering.

This means we don't chew up privileged ports, and our registration is
bound to an "owner" (the effective uid of the process on the sending
end of the transport). Only that "owner" may unregister the service.

The kernel could probe rpcbind via an rpcbind query to determine
whether rpcbind has an AF_LOCAL service. For simplicity, we use the
same technique that libtirpc uses: simply fail over to network
loopback if creating an AF_LOCAL transport to the well-known rpcbind
service socket fails.

This means we open-code the pathname of the rpcbind socket in the
kernel. For now we have to do that anyway because the kernel's
RPC over AF_LOCAL implementation does not support autobind. That may
be undesirable in the long term.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
bf2695516db982e90a22fc94f93491b481796bb1 14-Dec-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: New xdr_streams XDR decoder API

Now that all client-side XDR decoder routines use xdr_streams, there
should be no need to support the legacy calling sequence [rpc_rqst *,
__be32 *, RPC res *] anywhere. We can construct an xdr_stream in the
generic RPC code, instead of in each decoder function.

This is a refactoring change. It should not cause different behavior.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9f06c719f474be7003763284a990bed6377bb0d4 14-Dec-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: New xdr_streams XDR encoder API

Now that all client-side XDR encoder routines use xdr_streams, there
should be no need to support the legacy calling sequence [rpc_rqst *,
__be32 *, RPC arg *] anywhere. We can construct an xdr_stream in the
generic RPC code, instead of in each encoder function.

Also, all the client-side encoder functions return 0 now, making a
return value superfluous. Take this opportunity to convert them to
return void instead.

This is a refactoring change. It should not cause different behavior.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1ac7c23e4af5e83525137661595000099f1ce94f 14-Dec-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Determine value of "nrprocs" automatically

Clean up.

Just fixed a panic where the nrprocs field in a different upper layer
client was set by hand incorrectly. Use the compiler-generated method
used by the other upper layer protocols.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4129ccf303593a1922a934697f99e682ff491504 14-Dec-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Avoid return code checking in rpcbind XDR encoder functions

Clean up.

The trend in the other XDR encoder functions is to BUG() when encoding
problems occur, since a problem here is always due to a local coding
error. Then, instead of a status, zero is unconditionally returned.

Update the rpcbind XDR encoders to behave this way.

To finish the update, use the new-style be32_to_cpup() and
cpu_to_be32() macros, and compute the buffer sizes using raw integers
instead of sizeof(). This matches the conventions used in other XDR
functions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c636b572e00e38855dc7a56a0fa438dd835f39de 06-Oct-2010 Pavel Emelyanov <xemul@parallels.com> sunrpc: Don't return NULL from rpcb_create

> The reason for this is in the future, we may want to support additional
> address family types. We should, therefore, ensure that every piece of
> code that is sensitive to address families fail in some orderly manner
> to let developers know where a change is needed.

Makes sense. I was under impression, that AF-s other than INET are not
cared about at all :(

Here's a fixed version of the patch.

Log:

Its callers check for ERR_PTR.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
c653ce3f0aee9bb2b221ebf3579385c06f81efcd 29-Sep-2010 Pavel Emelyanov <xemul@parallels.com> sunrpc: Add net to rpc_create_args

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
38359352fcb0d776b562a9e0ed4f0d355d5a332e 21-Sep-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Correct an rpcbind debugging message

Clean up.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
859d5024f450686ad0a42ed3c06f2fa20295c9e6 17-Sep-2010 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Remove rpcb_getport_sync()

Clean up: rpcb_getport_sync() has no more users, so remove it.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4be929be34f9bdeffa40d815d32d7d60d2c7f03b 24-May-2010 Alexey Dobriyan <adobriyan@gmail.com> kernel-wide: replace USHORT_MAX, SHORT_MAX and SHORT_MIN with USHRT_MAX, SHRT_MAX and SHRT_MIN

- C99 knows about USHRT_MAX/SHRT_MAX/SHRT_MIN, not
USHORT_MAX/SHORT_MAX/SHORT_MIN.

- Make SHRT_MIN of type s16, not int, for consistency.

[akpm@linux-foundation.org: fix drivers/dma/timb_dma.c]
[akpm@linux-foundation.org: fix security/keys/keyring.c]
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
012da158f636347c4eb28fd1e1cca020fef5e54d 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use soft connects for autobinding over TCP

Autobinding is handled by the rpciod process, not in user processes
that are generating regular RPC requests. Thus autobinding is usually
not affected by signals targetting user processes, such as KILL or
timer expiration events.

In addition, an RPC request generated by a user process that has
RPC_TASK_SOFTCONN set and needs to perform an autobind will hang if
the remote rpcbind service is not available.

For rpcbind queries on connection-oriented transports, let's use the
new soft connect semantic to return control to the user's process
quickly, if the kernel's rpcbind client can't connect to the remote
rpcbind service.

Logic is introduced in call_bind_status() to handle connection errors
that occurred during an asynchronous rpcbind query. The logic
abandons the rpcbind query if the RPC request has SOFTCONN set, and
retries after a few seconds in the normal case.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2a76b3bfa22993fc09166bd6a8db0dbe902b6813 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use TCP for local rpcbind upcalls

Use TCP with the soft connect semantic for local rpcbind upcalls so
the kernel can detect immediately if the local rpcbind daemon is not
running.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
c526611dd631b2802b6b0221ffb306c5fa25c86c 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use a cached RPC client and transport for rpcbind upcalls

The kernel's rpcbind client creates and deletes an rpc_clnt and its
underlying transport socket for every upcall to the local rpcbind
daemon.

When starting a typical NFS server on IPv4 and IPv6, the NFS service
itself does three upcalls (one per version) times two upcalls (one
per transport) times two upcalls (one per address family), making 12,
plus another one for the initial call to unregister previous NFS
services. Starting the NLM service adds an additional 13 upcalls,
for similar reasons.

(Currently the NFS service doesn't start IPv6 listeners, but it will
soon enough).

Instead, let's create an rpc_clnt for rpcbind upcalls during the
first local rpcbind query, and cache it. This saves the overhead of
creating and destroying an rpc_clnt and a socket for every upcall.

The new logic also prevents the kernel from attempting an RPCB_SET or
RPCB_UNSET if it knows from the start that the local portmapper does
not support rpcbind protocol version 4. This will cut down on the
number of rpcbind upcalls in legacy environments.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
5a46211540a83871196489247f57da2bdde58d87 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Simplify synopsis of rpcb_local_clnt()

Clean up: At one point, rpcb_local_clnt() handled IPv6 loopback
addresses too, but it doesn't any more; only IPv4 loopback is used
now. Get rid of the @addr and @addrlen arguments to
rpcb_local_clnt().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f8b761eff1e49fde43dd940ac32b38cf7cee2a95 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Eliminate PROC macro from rpcb_clnt

Clean up: Replace PROC macro with open coded C99 structure
initializers to improve readability.

The rpcbind v4 GETVERSADDR procedure is never sent by the current
implementation, so it is not copied to the new structures.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0e47f0d665efcf1b45f293422d21d8383f07d122 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up: Remove unused XDR decoder functions from rpcb_clnt.c

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c0c077df009f2f329875051ac5283df235288689 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce new xdr_stream-based decoders to rpcb_clnt.c

Replace the open-coded decode logic for PMAP_GETPORT/RPCB_GETADDR with
an xdr_stream-based implementation, similar to what NFSv4 uses, to
protect against buffer overflows. The new implementation also checks
that the incoming port number is reasonable.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7ed0ff983c8ad30bf4e2b9fdbb299a3e3ec08d08 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce xdr_stream-based decoders for RPCB_UNSET

Replace the open-coded decode logic for rpcbind UNSET results with an
xdr_stream-based implementation, similar to what NFSv4 uses, to
protect against buffer overflows.

The new function is unused for the moment.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0d36c4f7574d5a33bedd8f0e3c793490d45d83c6 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up: Remove unused XDR encoder functions from rpcb_clnt.c

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6f2c2db7a46243bd86e3d7ff5f9ff982f26a9fe8 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce new xdr_stream-based encoders to rpcb_clnt.c

Replace the open-coded encode logic for rpcbind arguments with an
xdr_stream-based implementation, similar to what NFSv4 uses, to
better protect against buffer overflows.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ba809130bc260fce04141aca01ef9e068d32af2a 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Remove duplicate universal address generation

RPC universal address generation is currently done in several places:
rpcb_clnt.c, nfs4proc.c xprtsock.c, and xprtrdma.c. Remove the
redundant cases that convert a socket address to a universal
address. The nfs4proc.c case takes a pre-formatted presentation
address string, not a socket address, so we'll leave that one.

Because the new uaddr constructor uses the recently introduced
rpc_ntop(), it now supports proper "::" shorthanding for IPv6
addresses. This allows the kernel to register properly formed
universal addresses with the local rpcbind service, in _all_ cases.

The kernel can now also send properly formed universal addresses in
RPCB_GETADDR requests, and support link-local properly when
encoding and decoding IPv6 addresses.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0b10bf5e14d856d1d27a2117d07af2bebee81b75 09-Aug-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Move XDR data type size macros

Clean up: To make subsequent patches cleaner, move the XDR data type
size macros to the top of the file (similar to nfs4xdr.c) first.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
363f724cdd3d2ae554e261be995abdeb15f7bdd9 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: rpcb_register() should handle errors silently

Move error reporting for RPC registration to rpcb_register's caller.

This way the caller can choose to recover silently from certain
errors, but report errors it does not recognize. Error reporting
for kernel RPC service registration is now handled in one place.

This patch is part of a series that addresses
http://bugzilla.kernel.org/show_bug.cgi?id=12256

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1673d0de40ab46cac3b456ad50e1c8d6a31bfd66 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Allow callers to pass rpcb_v4_register a NULL address

The user space TI-RPC library uses an empty string for the universal
address when unregistering all target addresses for [program, version].
The kernel's rpcb client should behave the same way.

Here, we are switching between several registration methods based on
the protocol family of the incoming address. Rename the other rpcbind
v4 registration functions to make it clear that they, as well, are
switched on protocol family. In /etc/netconfig, this is either "inet"
or "inet6".

NB: The loopback protocol families are not supported in the kernel.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
126e4bc3b3b446482696377f67a634c76eaf2e9c 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: rpcbind actually interprets r_owner string

RFC 1833 has little to say about the contents of r_owner; it only
specifies that it is a string, and states that it is used to control
who can UNSET an entry.

Our port of rpcbind (from Sun) assumes this string contains a numeric
UID value, not alphabetical or symbolic characters, but checks this
value only for AF_LOCAL RPCB_SET or RPCB_UNSET requests. In all other
cases, rpcbind ignores the contents of the r_owner string.

The reference user space implementation of rpcb_set(3) uses a numeric
UID for all SET/UNSET requests (even via the network) and an empty
string for all other requests. We emulate that behavior here to
maintain bug-for-bug compatibility.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3aba45536fe8f92aa07bcdfd2fb1cf17eec7d786 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up address type casts in rpcb_v4_register()

Clean up: Simplify rpcb_v4_register() and its helpers by moving the
details of sockaddr type casting to rpcb_v4_register()'s helper
functions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fc28decdc93633a65d54e42498e9e819d466329c 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use IPv4 loopback for registering AF_INET6 kernel RPC services

The kernel uses an IPv6 loopback address when registering its AF_INET6
RPC services so that it can tell whether the local portmapper is
actually IPv6-enabled.

Since the legacy portmapper doesn't listen on IPv6, however, this
causes a long timeout on older systems if the kernel happens to try
creating and registering an AF_INET6 RPC service. Originally I wanted
to use a connected transport (either TCP or connected UDP) so that the
upcall would fail immediately if the portmapper wasn't listening on
IPv6, but we never agreed on what transport to use.

In the end, it's of little consequence to the kernel whether the local
portmapper is listening on IPv6. It's only important whether the
portmapper supports rpcbind v4. And the kernel can't tell that at all
if it is sending requests via IPv6 -- the portmapper will just ignore
them.

So, send both rpcbind v2 and v4 SET/UNSET requests via IPv4 loopback
to maintain better backwards compatibility between new kernels and
legacy user space, and prevent multi-second hangs in some cases when
the kernel attempts to register RPC services.

This patch is part of a series that addresses

http://bugzilla.kernel.org/show_bug.cgi?id=12256

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
776bd5c7a207de546918f805090bfc823d2660c8 19-Mar-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Don't flag empty RPCB_GETADDR reply as bogus

In 2007, commit e65fe3976f594603ed7b1b4a99d3e9b867f573ea added
additional sanity checking to rpcb_decode_getaddr() to make sure we
were getting a reply that was long enough to be an actual universal
address. If the uaddr string isn't long enough, the XDR decoder
returns EIO.

However, an empty string is a valid RPCB_GETADDR response if the
requested service isn't registered. Moreover, "::.n.m" is also a
valid RPCB_GETADDR response for IPv6 addresses that is shorter
than rpcb_decode_getaddr()'s lower limit of 11. So this sanity
check introduced a regression for rpcbind requests against IPv6
remotes.

So revert the lower bound check added by commit
e65fe3976f594603ed7b1b4a99d3e9b867f573ea, and add an explicit check
for an empty uaddr string, similar to libtirpc's rpcb_getaddr(3).

Pointed-out-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
21454aaad30651ba0dcc16fe5271bc12ee21f132 31-Oct-2008 Harvey Harrison <harvey.harrison@gmail.com> net: replace NIPQUAD() in net/*/

Using NIPQUAD() with NIPQUAD_FMT, %d.%d.%d.%d or %u.%u.%u.%u
can be replaced with %pI4

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5b095d98928fdb9e3b75be20a54b7a6cbf6ca9ad 29-Oct-2008 Harvey Harrison <harvey.harrison@gmail.com> net: replace %p6 with %pI6

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fdb46ee752ed05c94bac71fe3decdb5175ec6e1f 29-Oct-2008 Harvey Harrison <harvey.harrison@gmail.com> net, misc: replace uses of NIP6_FMT with %p6

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
96165e2b7c4e2c82a0b60c766d4a2036444c21a0 03-Oct-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a memory leak in rpcb_getport_async

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9a4bd29fe8f6d3f015fe1c8e5450eb62cfebfcc9 03-Oct-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix autobind on cloned rpc clients

Despite the fact that cloned rpc clients won't have the cl_autobind flag
set, they may still find themselves calling rpcb_getport_async(). For this
to happen, it suffices for a _parent_ rpc_clnt to use autobinding, in which
case any clone may find itself triggering the !xprt_bound() case in
call_bind().

The correct fix for this is to walk back up the tree of cloned rpc clients,
in order to find the parent that 'owns' the transport, either because it
has clnt->cl_autobind set, or because it originally created the
transport...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
db820d6376aa81accf5b648651e160fd76e363e2 25-Sep-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up debug messages in rpcb_clnt.c

The RPCB XDR functions are used for multiple procedures. For instance,
rpcb_encode_getaddr() is used for RPCB_GETADDR, RPCB_SET, and
RPCB_UNSET. Make the XDR debug messages more generic so they are less
confusing.

And, unlike in other RPC consumers in the kernel, a single debug flag
enables all levels of debug messages in the RPC bind client, including
XDR debug messages. Since the XDR decoders already report success or
failure in this case, remove redundant debug messages in the mid-level
rpcb_register_call() function.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
9d548b9c955c0709d1229d21d0bc14afa6b356de 15-Sep-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use short-hand IPv6 ANYADDR for RPCB_SET

Clean up: When doing an RPCB_SET, make the kernel's rpcb client use the
shorthand "::" for the universal form of the IPv6 ANY address.

Without this patch, rpcbind will advertise:

0000:0000:0000:0000:0000:0000:0000:0000.x.y

This is cosmetic only. It cleans up the display of information from
/sbin/rpcinfo.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
14aeb2118d6e9fd9ee988324c740a00c80979093 19-Aug-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Simplify rpcb_register() API

Bruce suggested there's no need to expose the difference between an error
sending the PMAP_SET request and an error reply from the portmapper to
rpcb_register's callers. The user space equivalent of rpcb_register() is
pmap_set(3), which returns a bool_t : either the PMAP set worked, or it
didn't. Simple.

So let's remove the "*okay" argument from rpcb_register() and
rpcb_v4_register(), and simply return an error if any part of the call
didn't work.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
c2e1b09ff237c0a3687b9a804cc8bf489743cffc 14-Jul-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Support registering IPv6 interfaces with local rpcbind daemon

Introduce a new API to register RPC services on IPv6 interfaces to allow
the NFS server and lockd to advertise on IPv6 networks.

Unlike rpcb_register(), the new rpcb_v4_register() function uses rpcbind
protocol version 4 to contact the local rpcbind daemon. The version 4
SET/UNSET procedures allow services to register address families besides
AF_INET, register at specific network interfaces, and register transport
protocols besides UDP and TCP. All of this functionality is exposed via
the new rpcb_v4_register() kernel API.

A user-space rpcbind daemon implementation that supports version 4 of the
rpcbind protocol is required in order to make use of this new API.

Note that rpcbind version 3 is sufficient to support the new rpcbind
facilities listed above, but most extant implementations use version 4.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
babe80eb4994dfdc97d5be19a68b5af66d667585 14-Jul-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Refactor rpcb_register to make rpcbindv4 support easier

rpcbind version 4 registration will reuse part of rpcb_register, so just
split it out into a separate function now.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
423d8b064771f5cd8b706a4839b18db9bb6c3c59 14-Jul-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: None of rpcb_create's callers wants a privileged source port

Clean up: Callers that required a privileged source port now use
rpcb_create_local(), so we can remove the @privileged argument from
rpcb_create().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cc5598b78fd320dd6d1f90c14491e08029f3c4f6 14-Jul-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce a specific rpcb_create for contacting localhost

Add rpcb_create_local() for use by rpcb_register() and upcoming IPv6
registration functions.

Ensure any errors encountered by rpcb_create_local() are properly
reported.

We can also use a statically allocated constant loopback socket address
instead of one allocated on the stack and initialized every time the
function is called.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
166b88d755f925139af7f7b75aa0a1b896ca0670 14-Jul-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use correct XDR encoding procedure for rpcbind SET/UNSET

The rpcbind versions 3 and 4 SET and UNSET procedures use the same
arguments as the GETADDR procedure.

While definitely a bug, this hasn't been a problem so far since the
kernel hasn't used version 3 or 4 SET and UNSET. But this will change
in just a moment.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
381ba74af55e58bca4c01553835a360a9f6fbb07 07-Jul-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure our task is notified when an rpcbind call is done

If another task is busy in rpcb_getport_async number, it is more efficient
to have it wake us up when it has finished instead of arbitrarily sleeping
for 5 seconds.

Also ensure that rpcb_wake_rpcbind_waiters() is called regardless of
whether or not rpcb_getport_done() gets called.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
40fef8a649e5344bfb6a67a7cc3def3e0dad6448 25-Jun-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use only rpcbind v2 for AF_INET requests

Some server vendors support the higher versions of rpcbind only for
AF_INET6. The kernel doesn't need to use v3 or v4 for AF_INET anyway,
so change the kernel's rpcbind client to query AF_INET servers over
rpcbind v2 only.

This has a few interesting benefits:

1. If the rpcbind request is going over TCP, and the server doesn't
support rpcbind versions 3 or 4, the client reduces by two the number
of ephemeral ports left in TIME_WAIT for each rpcbind request. This
will help during NFS mount storms.

2. The rpcbind interaction with servers that don't support rpcbind
versions 3 or 4 will use less network traffic. Also helpful
during mount storms.

3. We can eliminate the kernel build option that controls whether the
kernel's rpcbind client uses rpcbind version 3 and 4 for AF_INET
servers. Less complicated kernel configuration...

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8842413aa4c3220ce9313791f99808fc149ca16d 25-Jun-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use GETADDR for rpcbind version 4 queries

Some rpcbind servers that do support rpcbind version 4 do not support
the GETVERSADDR procedure. Use GETADDR for querying rpcbind servers
via rpcbind version 4 instead of GETVERSADDR.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6a774051573042cdeb57e81f77b36c25e5856739 25-Jun-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use rpcbind version 2 GETPORT

Clean up: Change the version 2 procedure name to GETPORT. It's the same
procedure number as GETADDR, but version 2 implementations usually refer
to it as GETPORT.

This also now matches the procedure name used in the version 2 procedure
entry in the rpcb_next_version[] array, making it slightly less confusing.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fc200e794d723bc88c39859e8f096b717532f9c9 25-Jun-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Document some naked integers in rpcbind client

Clean up: Replace naked integers that represent rpcbind protocol versions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
877fcf103982e52a59a1035378b4c0b8c63fe004 25-Jun-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: More useful debugging output for rpcb client

Clean up dprintk's in rpcb client's XDR decoder functions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
803a9067e19714ea7b7da760fe92f0d53bfa6994 01-Jul-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix an rpcbind breakage for the case of IPv6 lookups

Now that rpcb_next_version has been split into an IPv4 version and an IPv6
version, we Oops when rpcb_call_async attempts to look up the IPv6-specific
RPC procedure in rpcb_next_version.

Fix the Oops simply by having rpcb_getport_async pass the correct RPC
procedure as an argument.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0d3a34b48c87a374b37d7a21a60d257d076484f3 07-Jul-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a double-free in rpcbind

It is wrong to be freeing up the rpcbind arguments if the call to
rpcb_call_async() fails, since they should already have been freed up by
rpcb_map_release().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0dc47877a3de00ceadea0005189656ae8dc52669 06-Mar-2008 Harvey Harrison <harvey.harrison@gmail.com> net: replace remaining __FUNCTION__ occurrences

__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5d00837b90340af9106dcd93af75fd664c8eb87f 22-Feb-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Run rpc timeout functions as callbacks instead of in softirqs

An audit of the current RPC timeout functions shows that they don't really
ever need to run in the softirq context. As long as the softirq is
able to signal that the wakeup is due to a timeout (which it can do by
setting task->tk_status to -ETIMEDOUT) then the callback functions can just
run as standard task->tk_callback functions (in the rpciod/process
context).

The only possible border-line case would be xprt_timer() for the case of
UDP, when the callback is used to reduce the size of the transport
congestion window. In testing, however, the effect of moving that update
to a callback would appear to be minor.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
afc881124b8aff83c7a28269ef9d9cfce543256c 14-Jan-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: rpcb_getport_sync() passes incorrect address size to rpc_create()

The variable "sin" is a pointer, so sizeof(sin) is the size of a pointer,
not the size of thing that sin points to.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
67d60213627ec4391cc402bf95753eefde8522af 14-Jan-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up block comment preceding rpcb_getport_sync()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f1ec08cb9492cab579f85f9d937c79788b1dfde3 14-Jan-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use appropriate argument types in rpcb client

Clean up: Follow recommendations of Chapter 5 of Documentation/CodingStyle
and use "u32" instead of "__u32" for types in definitions that are not
shared with user space.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b91e101fca70319f9ca839311bceff5f44dfc1ed 14-Jan-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: rpcb_getport_sync() should use built-in hostname generator

rpc_create() can already fill in the hostname with a string representation
of the server's IP address, so remove redundant logic in in
rpcb_getport_sync() that does that.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
86d61d8638ddf9cdf87df26c7fa69b2804425fbe 08-Jan-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix up constant string declarations in struct rpcbind_args

...and eliminate an unnecessary cast.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b454ae906085cf7774fb4756746680c9b03b6f84 08-Jan-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: fewer conditionals in the format_ip_address routines

Clean up: have the set up routines explicitly pass the strings to be used
for the transport name and NETID. This removes a number of conditionals
and dependencies on rpc_xprt.prot, which is overloaded.

Tighten up type checking on the address_strings array while we're at it.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0fb2b7e945f55a8317e5f58db7c068aab5b825a1 10-Dec-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Move universal address definitions to global header

Universal addresses are defined in RFC 1833 and clarified in RFC 3530. We
need to use them in several places in the NFS and RPC clients, so move the
relevant definition and block comment to an appropriate global include
file.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0a48f5d70fa9e87269d076fe27f3563f4375c479 10-Dec-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: RPC version numbers are u32

Clean up: use correct type for RPC version numbers in rpcbind client.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9f6ad26d2abfd9a2ec4a34b934ca75c4239ab8cf 10-Dec-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Fix socket address handling in rpcb_clnt

Make sure rpcb_clnt passes the correct address length to rpc_create().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5138fde01161cd7976fdc51f6a17da73adaa6baf 14-Jul-2007 Trond Myklebust <Trond.Myklebust@netapp.com> NFS/SUNRPC: Convert all users of rpc_call_setup()

Replace use of rpc_call_setup() with rpc_init_task(), and in cases where we
need to initialise task->tk_action, with rpc_call_start().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c970aa85e71bd581726c42df843f6f129db275ac 14-Jul-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Clean up rpc_run_task

Make it use the new task initialiser structure instead of acting as a
wrapper.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
150030b78a454ba50d5e267b0dcf01b162809192 06-Dec-2007 Matthew Wilcox <matthew@wil.cx> NFS: Switch from intr mount option to TASK_KILLABLE

By using the TASK_KILLABLE infrastructure, we can get rid of the 'intr'
mount option. We have to use _killable everywhere instead of _interruptible
as we get rid of rpc_clnt_sigmask/sigunmask.

Signed-off-by: Liam R. Howlett <howlett@gmail.com>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
7f4adeff6fa32ff46f148110c4f08130175c8da8 13-Jun-2007 Adrian Bunk <bunk@stusta.de> [2.6 patch] net/sunrpc/rpcb_clnt.c: make struct rpcb_program static

This patch makes the needlessly global struct rpcb_program static.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0896a725a1c5fdc8773a4d1ab0b73059507f5925 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> NFS/SUNRPC: use transport protocol naming

Instead of an { address family, raw IP protocol number }-tuple, use the
newly-defined RPC identifier when creating clients in the upper layers.

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1244480976d357447aeddd3f44977586bfa0462b 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> SUNRPC: add EXPORT_SYMBOL_GPL for generic transport functions

SUNRPC: add EXPORT_SYMBOL_GPL for generic transport functions

As a preface to allowing arbitrary transport modules to be loaded
dynamically, add EXPORT_SYMBOL_GPL for all generic transport functions
that a transport implementation might want to use.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Acked-by: Tom Talpey <tmt@netapp.com>

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4417c8c41a51a2ae95b2a2fa2811640b368c4151 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> SUNRPC: export per-transport rpcbind netid's

The rpcbind (v3+) netid is provided by each RPC client transport. This fixes
an omission in IPv6 rpcbind client support, and enables future extension.

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4f40ee4a02a2d017b714d5b2faaf5c25bf9eae47 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> SUNRPC: move per-transport rpcbind netid's

Move the TCP/UDP rpcbind netid's from the rpcbind client to a global header.

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
906462af4c707ba0238f3579fdb2b594c4ea29c3 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Split another new rpcbind retry error code from EACCES

Add more new error code processing to the kernel's rpcbind client
and to call_bind_status() to distinguish two cases:

Case 1: the remote has replied that the program/version tuple is not
registered (returns EACCES)

Case 2: retry with a lesser rpcbind version (rpcb now returns EPFNOSUPPORT)

This change allows more specific error processing for each of these two
cases. We now fail case 2 instead of retrying... it's a server
configuration error not to support even rpcbind version 2. And don't
expose this new error code to user land -- convert it to EIO before
failing the RPC.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2429cbf6a1566b8e92436d615387e4250feab46b 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Add a new error code for retry waiting for another binder

Add new error code processing to the kernel's rpcbind client and to
call_bind_status() to distinguish two cases:

Case 1: the remote has replied that the program/version tuple is not
registered (returns -EACCES)

Case 2: another process is already in the middle of binding on this
transport (now returns -EAGAIN)

This change allows more specific retry processing for each of these two
cases.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4784cb51a3f66d401f8a08810231aa7dc8f44e43 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Retry bad rpcbind replies

When a server returns a bad rpcbind reply, make rpcbind client recovery logic
retry with an older protocol version. Older versions are more likely to work
correctly.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e65fe3976f594603ed7b1b4a99d3e9b867f573ea 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Make rpcb_decode_getaddr more picky about universal addresses

Add better sanity checking of server replies to the GETVERSADDR reply
decoder. Change the error return code: EIO is what other XDR decoding
routines return if there is a failure while decoding.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6d0aa06afd62a868d83c6021335622a316469527 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use correct argument type in memcpy()

Noticed by Tom Talpey <tmt@netapp.com>:

OBTW, there's a nit on that memcpy, too. The r_addr is an array, so

memcpy(&map->r_addr

is passing the address of the array as a char **. It's the same as
map->r_addr, but technically the wrong type.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
143b6c4008a7928de7e139c3a77a90e4cad8db2c 16-Aug-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Fix generation of universal addresses for

Fix some problems with rpcbind v3 and v4 queries from the in-kernel rpcbind
client:

1. The r_addr argument must be a full universal address, not just an IP
address, and

2. The universal address in r_addr is the address of the remote rpcbind
server, not the RPC service being requested

This addresses bugzilla.kernel.org report 8891 for 2.6.23-rc and greater.

In addition, if the rpcbind client is unable to start the rpcbind request,
make sure not to leak the xprt.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
d5b6443014940eb83788161c69b17cb7a1ffaaed 06-Aug-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: add support for IPv6 to the kernel's rpcbind client

Prepare for adding IPv6 support to the RPC client by adding IPv6
capabilities to rpcbind. Note that this is support on the query side
only; registering IPv6 addresses with the local portmapper will come
later.

Note we have to take care not to fall back to using version 2 of the
rpcbind protocol if we're dealing with IPv6 address. Version 2 doesn't
support IPv6 at all.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
adc24df81d6903d2d6280d77e936aa5e1670d7a1 06-Aug-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Fix a signed v. unsigned comparison in rpcbind's XDR routines

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
45160d6275814e0c86206e6981f0b92c61a50a21 01-Jul-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Rename rpcb_getport to be consistent with new rpcb_getport_sync name

Clean up, for consistency. Rename rpcb_getport as rpcb_getport_async, to
match the naming scheme of rpcb_getport_sync.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cce63cd6374e6f1b4ea897ece1454feb13993d7c 01-Jul-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Rename rpcb_getport_external routine

In preparation for handling NFS mount option parsing in the kernel,
rename rpcb_getport_external as rpcb_get_port_sync, and make it available
always (instead of only when CONFIG_ROOT_NFS is enabled).

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f7fb558e503dc80e100acaf116f7261cdd97f0ca 01-Jul-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Allow rpcbind requests to be interrupted by a signal.

This allows NFS mount requests and RPC re-binding to be interruptible if the
server isn't responding.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4c402b40970382ded616eadd544fd63feb76cc79 14-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove rpc_clnt->cl_count

The kref now does most of what cl_count + cl_user used to do. The only
remaining role for cl_count is to tell us if we are in a 'shutdown'
phase. We can provide that information using a single bit field instead
of a full atomic counter.

Also rename rpc_destroy_client() to rpc_close_client(), which reflects
better what its role is these days.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
90c5755ff5111ffdcca10a1e8a823dba29f37b6d 10-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Kill rpc_clnt->cl_oneshot

Replace it with explicit calls to rpc_shutdown_client() or
rpc_destroy_client() (for the case of asynchronous calls).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a509050bd3b8e0aa269c2241aa10d74ca7701e2f 29-Mar-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: introduce rpcbind: replacement for in-kernel portmapper

Introduce a replacement for the in-kernel portmapper client that supports
all 3 versions of the rpcbind protocol. This code is not used yet.

Original code by Groupe Bull updated for the latest kernel, with multiple
bug fixes.

Note that rpcb_clnt.c does not yet support registering via versions 3 and
4 of the rpcbind protocol. That is planned for a later patch.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>