History log of /net/sunrpc/clnt.c
Revision Date Author Comments
2aca5b869ace67a63aab895659e5dc14c33a4d6e 25-Sep-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Add missing support for RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT

The flag RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT was intended introduced in
order to allow NFSv4 clients to disable resend timeouts. Since those
cause the RPC layer to break the connection, they mess up the duplicate
reply caches that remain indexed on the port number in NFSv4..

This patch includes the code that was missing in the original to
set the appropriate flag in struct rpc_clnt, when the caller of
rpc_create() sets RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT.

Fixes: 8a19a0b6cb2e (SUNRPC: Add RPC task and client level options to...)
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
3dedbb5ca10ef13f25055776d2f6d9499d9ca1ba 24-Sep-2014 Jason Baron <jbaron@akamai.com> rpc: Add -EPERM processing for xs_udp_send_request()

If an iptables drop rule is added for an nfs server, the client can end up in
a softlockup. Because of the way that xs_sendpages() is structured, the -EPERM
is ignored since the prior bits of the packet may have been successfully queued
and thus xs_sendpages() returns a non-zero value. Then, xs_udp_send_request()
thinks that because some bits were queued it should return -EAGAIN. We then try
the request again and again, resulting in cpu spinning. Reproducer:

1) open a file on the nfs server '/nfs/foo' (mounted using udp)
2) iptables -A OUTPUT -d <nfs server ip> -j DROP
3) write to /nfs/foo
4) close /nfs/foo
5) iptables -D OUTPUT -d <nfs server ip> -j DROP

The softlockup occurs in step 4 above.

The previous patch, allows xs_sendpages() to return both a sent count and
any error values that may have occurred. Thus, if we get an -EPERM, return
that to the higher level code.

With this patch in place we can successfully abort the above sequence and
avoid the softlockup.

I also tried the above test case on an nfs mount on tcp and although the system
does not softlockup, I still ended up with the 'hung_task' firing after 120
seconds, due to the i/o being stuck. The tcp case appears a bit harder to fix,
since -EPERM appears to get ignored much lower down in the stack and does not
propogate up to xs_sendpages(). This case is not quite as insidious as the
softlockup and it is not addressed here.

Reported-by: Yigong Lou <ylou@akamai.com>
Signed-off-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
2fc193cf924ea6eb74f6a0cf73b94b2e62938ae5 03-Jul-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Handle EPIPE in xprt_connect_status

The callback handler xs_error_report() can end up propagating an EPIPE
error by means of the call to xprt_wake_pending_tasks(). Ensure that
xprt_connect_status() does not automatically convert this into an
EIO error.

Reported-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
3601c4a91ebbbf1cf69f66a2abeffc6c64a4fe64 30-Jun-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Ensure that we handle ENOBUFS errors correctly.

Currently, an ENOBUFS error will result in a fatal error for the RPC
call. Normally, we will just want to wait and then retry.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
83ddfebdd21da669918d7f9854fd592858625f4b 24-Mar-2014 Kinglong Mee <kinglongmee@gmail.com> SUNRPC: New helper for creating client with rpc_xprt

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
494314c415e2d3b308f57c9245ae6525166c70b8 20-Mar-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: rpc_restart_call/rpc_restart_call_prepare should clear task->tk_status

When restarting an rpc call, we should not be carrying over data from the
previous call.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
1fa3e2eb9db07f30a605c66d1a2fdde4b24e74d5 20-Mar-2014 Steve Dickson <steved@redhat.com> SUNRPC: Ensure call_connect_status() deals correctly with SOFTCONN tasks

Don't schedule an rpc_delay before checking to see if the task
is a SOFTCONN because the tk_callback from the delay (__rpc_atrun)
clears the task status before the rpc_exit_task can be run.

Signed-off-by: Steve Dickson <steved@redhat.com>
Fixes: 561ec1603171c (SUNRPC: call_connect_status should recheck...)
Link: http://lkml.kernel.org/r/5329CF7C.7090308@RedHat.com
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
9455e3f43b017f560daf4289d0fa295a33976f2a 19-Mar-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Ensure call_status() deals correctly with SOFTCONN tasks

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fdb63dcdb53a3c6dc11d4e438ef2425ec962d1e9 17-Mar-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Ensure that call_bind times out correctly

If the rpcbind server is unavailable, we still want the RPC client
to respect the timeout.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
485f2251782f7c44299c491d4676a8a01428d191 17-Mar-2014 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Ensure that call_connect times out correctly

When the server is unavailable due to a networking error, etc, we want
the RPC client to respect the timeout delays when attempting to reconnect.

Reported-by: Neil Brown <neilb@suse.de>
Fixes: 561ec1603171 (SUNRPC: call_connect_status should recheck bind..)
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
6ff33b7dd0228b7d7ed44791bbbc98b03fd15d9d 17-Dec-2013 Weston Andros Adamson <dros@netapp.com> sunrpc: Fix infinite loop in RPC state machine

When a task enters call_refreshresult with status 0 from call_refresh and
!rpcauth_uptodatecred(task) it enters call_refresh again with no rate-limiting
or max number of retries.

Instead of trying forever, make use of the retry path that other errors use.

This only seems to be possible when the crrefresh callback is gss_refresh_null,
which only happens when destroying the context.

To reproduce:

1) mount with sec=krb5 (or sec=sys with krb5 negotiated for non FSID specific
operations).

2) reboot - the client will be stuck and will need to be hard rebooted

BUG: soft lockup - CPU#0 stuck for 22s! [kworker/0:2:46]
Modules linked in: rpcsec_gss_krb5 nfsv4 nfs fscache ppdev crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd serio_raw i2c_piix4 i2c_core e1000 parport_pc parport shpchp nfsd auth_rpcgss oid_registry exportfs nfs_acl lockd sunrpc autofs4 mptspi scsi_transport_spi mptscsih mptbase ata_generic floppy
irq event stamp: 195724
hardirqs last enabled at (195723): [<ffffffff814a925c>] restore_args+0x0/0x30
hardirqs last disabled at (195724): [<ffffffff814b0a6a>] apic_timer_interrupt+0x6a/0x80
softirqs last enabled at (195722): [<ffffffff8103f583>] __do_softirq+0x1df/0x276
softirqs last disabled at (195717): [<ffffffff8103f852>] irq_exit+0x53/0x9a
CPU: 0 PID: 46 Comm: kworker/0:2 Not tainted 3.13.0-rc3-branch-dros_testing+ #4
Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013
Workqueue: rpciod rpc_async_schedule [sunrpc]
task: ffff8800799c4260 ti: ffff880079002000 task.ti: ffff880079002000
RIP: 0010:[<ffffffffa0064fd4>] [<ffffffffa0064fd4>] __rpc_execute+0x8a/0x362 [sunrpc]
RSP: 0018:ffff880079003d18 EFLAGS: 00000246
RAX: 0000000000000005 RBX: 0000000000000007 RCX: 0000000000000007
RDX: 0000000000000007 RSI: ffff88007aecbae8 RDI: ffff8800783d8900
RBP: ffff880079003d78 R08: ffff88006e30e9f8 R09: ffffffffa005a3d7
R10: ffff88006e30e7b0 R11: ffff8800783d8900 R12: ffffffffa006675e
R13: ffff880079003ce8 R14: ffff88006e30e7b0 R15: ffff8800783d8900
FS: 0000000000000000(0000) GS:ffff88007f200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f3072333000 CR3: 0000000001a0b000 CR4: 00000000001407f0
Stack:
ffff880079003d98 0000000000000246 0000000000000000 ffff88007a9a4830
ffff880000000000 ffffffff81073f47 ffff88007f212b00 ffff8800799c4260
ffff8800783d8988 ffff88007f212b00 ffffe8ffff604800 0000000000000000
Call Trace:
[<ffffffff81073f47>] ? trace_hardirqs_on_caller+0x145/0x1a1
[<ffffffffa00652d3>] rpc_async_schedule+0x27/0x32 [sunrpc]
[<ffffffff81052974>] process_one_work+0x211/0x3a5
[<ffffffff810528d5>] ? process_one_work+0x172/0x3a5
[<ffffffff81052eeb>] worker_thread+0x134/0x202
[<ffffffff81052db7>] ? rescuer_thread+0x280/0x280
[<ffffffff81052db7>] ? rescuer_thread+0x280/0x280
[<ffffffff810584a0>] kthread+0xc9/0xd1
[<ffffffff810583d7>] ? __kthread_parkme+0x61/0x61
[<ffffffff814afd6c>] ret_from_fork+0x7c/0xb0
[<ffffffff810583d7>] ? __kthread_parkme+0x61/0x61
Code: e8 87 63 fd e0 c6 05 10 dd 01 00 01 48 8b 43 70 4c 8d 6b 70 45 31 e4 a8 02 0f 85 d5 02 00 00 4c 8b 7b 48 48 c7 43 48 00 00 00 00 <4c> 8b 4b 50 4d 85 ff 75 0c 4d 85 c9 4d 89 cf 0f 84 32 01 00 00

And the output of "rpcdebug -m rpc -s all":

RPC: 61 call_refresh (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refreshresult (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refreshresult (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refresh (status 0)
RPC: 61 call_refreshresult (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refreshresult (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refresh (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0
RPC: 61 call_refreshresult (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 call_refresh (status 0)
RPC: 61 call_refreshresult (status 0)
RPC: 61 refreshing RPCSEC_GSS cred ffff88007a413cf0

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Cc: stable@vger.kernel.org # 2.6.37+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
df2772700c6ee706be7b2fd16c6bf2c1bf63cda0 31-Dec-2013 Trond Myklebust <trond.myklebust@primarydata.com> SUNRPC: Handle connect errors ECONNABORTED and EHOSTUNREACH

Ensure that call_bind_status, call_connect_status, call_transmit_status and
call_status all are capable of handling ECONNABORTED and EHOSTUNREACH.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
d07ba8422f1e58be94cc98a1f475946dc1b89f1b 12-Nov-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Avoid deep recursion in rpc_release_client

In cases where an rpc client has a parent hierarchy, then
rpc_free_client may end up calling rpc_release_client() on the
parent, thus recursing back into rpc_free_client. If the hierarchy
is deep enough, then we can get into situations where the stack
simply overflows.

The fix is to have rpc_release_client() loop so that it can take
care of the parent rpc client hierarchy without needing to
recurse.

Reported-by: Jeff Layton <jlayton@redhat.com>
Reported-by: Weston Andros Adamson <dros@netapp.com>
Reported-by: Bruce Fields <bfields@fieldses.org>
Link: http://lkml.kernel.org/r/2C73011F-0939-434C-9E4D-13A1EB1403D7@netapp.com
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
09c3e54635c85b3da44d3bc156619c1f1af3bb43 30-Oct-2013 Wei Yongjun <yongjun_wei@trendmicro.com.cn> SUNRPC: remove duplicated include from clnt.c

Remove duplicated include.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
34751b9d04a221da2a74b27ba439f01c0ae30069 28-Oct-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add correct rcu_dereference annotation in rpc_clnt_set_transport

rpc_clnt_set_transport should use rcu_derefence_protected(), as it is
only safe to be called with the rpc_clnt::cl_lock held.

Cc: Chuck Lever <Chuck.Lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
40b00b6b17c412ff9ff28631250d32ee29ff0006 17-Oct-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add a helper to switch the transport of an rpc_clnt

Add an RPC client API to redirect an rpc_clnt's transport from a
source server to a destination server during a migration event.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: forward ported to 3.12 ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d746e54522e52275865ca23917c16b3fdc226e51 17-Oct-2013 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Modify synopsis of rpc_client_register()

The rpc_client_register() helper was added in commit e73f4cc0,
"SUNRPC: split client creation routine into setup and registration,"
Mon Jun 24 11:52:52 2013. In a subsequent patch, I'd like to invoke
rpc_client_register() from a context where a struct rpc_create_args
is not available.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
561ec1603171cd9b38dcf6cac53e8710f437a48d 26-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: call_connect_status should recheck bind and connect status on error

Currently, we go directly to call_transmit which sends us to call_status
on error. If we know that the connect attempt failed, we should rather
just jump straight back to call_bind and call_connect.

Ditto for EAGAIN, except do not delay.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ca7f33aa5b8051f17eec81766b8f39c83caf4196 25-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix RPC call retransmission statistics

A retransmit should be when you successfully transmit an RPC call to
the server a second time.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8a19a0b6cb2e2216afd68ef2047f30260cc8a220 24-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add RPC task and client level options to disable the resend timeout

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
90051ea774613ffc6b8aad3dc665c8505d6205a8 25-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Clean up - convert xprt_prepare_transmit to return a bool

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2f048db4680ae19da13df15d352ac02748781ecb 05-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add an identifier for struct rpc_clnt

Add an identifier in order to aid debugging.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
35fa5f7b35ca2076d594b2670a32d66dd3ae9eec 14-Aug-2013 Andy Adamson <andros@netapp.com> SUNRPC refactor rpcauth_checkverf error returns

Most of the time an error from the credops crvalidate function means the
server has sent us a garbage verifier. The gss_validate function is the
exception where there is an -EACCES case if the user GSS_context on the client
has expired.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f1ff0c27fd9987c59d707cd1a6b6c1fc3ae0a250 14-Aug-2013 Andy Adamson <andros@netapp.com> SUNRPC: don't map EKEYEXPIRED to EACCES in call_refreshresult

The NFS layer needs to know when a key has expired.
This change also returns -EKEYEXPIRED to the application, and the informative
"Key has expired" error message is displayed. The user then knows that
credential renewal is required.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
280ebcf97ce4b252c72af74ff3149ab5a5c9e680 02-Sep-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: rpcauth_create needs to know about rpc_clnt clone status

Ensure that we set rpc_clnt->cl_parent before calling rpc_client_register
so that rpcauth_create can find any existing RPCSEC_GSS caches for this
transport.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c36dcfe1f7712b7c12df2d80359e638b9d246ce6 26-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove the rpc_client->cl_dentry

It is now redundant.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5f42b016d7341871948a2b8cc8fb654691522d1a 26-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove the obsolete auth-only interface for pipefs dentry management

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6739ffb754b47e6c0fa9d9e268bde828f6856528 26-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add a framework to clean up management of rpc_pipefs directories

The current system requires everyone to set up notifiers, manage directory
locking, etc.
What we really want to do is have the rpc_client create its directory,
and then create all the entries.

This patch will allow the RPCSEC_GSS and NFS code to register all the
objects that they want to have appear in the directory, and then have
the sunrpc code call them back to actually create/destroy their pipefs
dentries when the rpc_client creates/destroys the parent.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c2190661039b3817b4cc1cbfea620b3f7dbe5cd8 27-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Replace clnt->cl_principal

The clnt->cl_principal is being used exclusively to store the service
target name for RPCSEC_GSS/krb5 callbacks. Replace it with something that
is stored only in the RPCSEC_GSS-specific code.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
41b6b4d0b88f80d04729a5286e838e972733db1e 23-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Cleanup rpc_setup_pipedir

The directory name is _always_ clnt->cl_program->pipe_dir_name.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1dada8e1f94e863a94f6622f0ddb5d1b01420150 27-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove unused struct rpc_clnt field cl_protname

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
55909f21a1079c5f9751d7919f8c9411500e1667 23-Aug-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Deprecate rpc_client->cl_protname

It just duplicates the cl_program->name, and is not used in any fast
paths where the extra dereference will cause a hit.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
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
1540c5d3cbf7670eb68a0d02611ec73e5604a91a 15-Jul-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix another issue with rpc_client_register()

Fix the error pathway if rpcauth_create() fails.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a95e691f9c4a6e24fdeab6d7feae6d5411fe8a69 14-Jul-2013 Al Viro <viro@zeniv.linux.org.uk> rpc_create_*_dir: don't bother with qstr

just pass the name

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
eeee245268c951262b861bc1be4e9dc812352499 10-Jul-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a deadlock in rpc_client_register()

Commit 384816051ca9125cd54750e59c780c2a2655fa4f (SUNRPC: fix races on
PipeFS MOUNT notifications) introduces a regression when we call
rpc_setup_pipedir() with RPCSEC_GSS as the auth flavour.

By calling rpcauth_create() while holding the sn->pipefs_sb_lock, we
end up deadlocking in gss_pipes_dentries_create_net().
Fix is to register the client and release the mutex before calling
rpcauth_create().

Reported-by: Weston Andros Adamson <dros@netapp.com>
Tested-by: Weston Andros Adamson <dros@netapp.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: <stable@vger.kernel.org> # : 3848160: SUNRPC: fix races on PipeFS MOUNT
Cc: <stable@vger.kernel.org> # : e73f4cc: SUNRPC: split client creation
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4f6bb246f69443549fbbd0f2abaf863243cb35e9 24-Jun-2013 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: PipeFS MOUNT notification optimization for dying clients

Not need to create pipes for dying client. So just skip them.

Note: we can safely dereference the client structure, because notification
caller is holding sn->pipefs_sb_lock.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e73f4cc051199799aee4320f300f28ffb82f3eb1 24-Jun-2013 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: split client creation routine into setup and registration

This helper moves all "registration" code to the new rpc_client_register()
helper.
This helper will be used later in the series to synchronize against PipeFS
MOUNT/UMOUNT events.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
adb6fa7ffe9031857ec14b8aab75c9ab65556cbc 26-Jun-2013 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: fix races on PipeFS UMOUNT notifications

CPU#0 CPU#1
----------------------------- -----------------------------
rpc_kill_sb
sn->pipefs_sb = NULL rpc_release_client
(UMOUNT_EVENT) rpc_free_auth
rpc_pipefs_event
rpc_get_client_for_event
!atomic_inc_not_zero(cl_count)
<skip the client>
atomic_inc(cl_count)
rpc_free_client
rpc_clnt_remove_pipedir
<skip client dir removing>

To fix this, this patch does the following:

1) Calls RPC_PIPEFS_UMOUNT notification with sn->pipefs_sb_lock being held.
2) Removes SUNRPC client from the list AFTER pipes destroying.
3) Doesn't hold RPC client on notification: if client in the list, then it
can't be destroyed while sn->pipefs_sb_lock in hold by notification caller.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
384816051ca9125cd54750e59c780c2a2655fa4f 24-Jun-2013 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: fix races on PipeFS MOUNT notifications

Below are races, when RPC client can be created without PiepFS dentries

CPU#0 CPU#1
----------------------------- -----------------------------
rpc_new_client rpc_fill_super
rpc_setup_pipedir
mutex_lock(&sn->pipefs_sb_lock)
rpc_get_sb_net == NULL
(no per-net PipeFS superblock)
sn->pipefs_sb = sb;
notifier_call_chain(MOUNT)
(client is not in the list)
rpc_register_client
(client without pipes dentries)

To fix this patch:
1) makes PipeFS mount notification call with pipefs_sb_lock being held.
2) releases pipefs_sb_lock on new SUNRPC client creation only after
registration.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9b1d75b75505cff4468ceba0da51a1ba47e15ea2 01-May-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't spam syslog with "Pseudoflavor not found" messages

Just convert those messages to dprintk()s so that they can be used
when debugging.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1d658336b05f8697d6445834f8867f8ad5e4f735 26-May-2012 Simo Sorce <simo@redhat.com> SUNRPC: Add RPC based upcall mechanism for RPCGSS auth

This patch implements a sunrpc client to use the services of the gssproxy
userspace daemon.

In particular it allows to perform calls in user space using an RPC
call instead of custom hand-coded upcall/downcall messages.

Currently only accept_sec_context is implemented as that is all is needed for
the server case.

File server modules like NFS and CIFS can use full gssapi services this way,
once init_sec_context is also implemented.

For the NFS server case this code allow to lift the limit of max 2k krb5
tickets. This limit is prevents legitimate kerberos deployments from using krb5
authentication with the Linux NFS server as they have normally ticket that are
many kilobytes large.

It will also allow to lift the limitation on the size of the credential set
(uid,gid,gids) passed down from user space for users that have very many groups
associated. Currently the downcall mechanism used by rpc.svcgssd is limited
to around 2k secondary groups of the 65k allowed by kernel structures.

Signed-off-by: Simo Sorce <simo@redhat.com>
[bfields: containerization, concurrent upcalls, misc. fixes and cleanup]
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
33d90ac0581ce81d1ebfc51918a2757e41a6011c 11-Apr-2013 J. Bruce Fields <bfields@redhat.com> SUNRPC: allow disabling idle timeout

In the gss-proxy case we don't want to have to reconnect at random--we
want to connect only on gss-proxy startup when we can steal gss-proxy's
context to do the connect in the right namespace.

So, provide a flag that allows the rpc_create caller to turn off the
idle timeout.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
b7993cebb841b0da7a33e9d5ce301a9fd3209165 14-Apr-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Allow rpc_create() to request that TCP slots be unlimited

This is mainly for use by NFSv4.1, where the session negotiation
ultimately wants to decide how many RPC slots we can fill.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ba60eb25ff6be6f8e60488cdfd454e5c612bce60 14-Apr-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a livelock problem in the xprt->backlog queue

This patch ensures that we throttle new RPC requests if there are
requests already waiting in the xprt->backlog queue. The reason for
doing this is to fix livelock issues that can occur when an existing
(high priority) task is waiting in the backlog queue, gets woken up
by xprt_free_slot(), but a new task then steals the slot.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f05c124a70a4953a66acbd6d6c601ea1eb5d0fa7 05-Apr-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a potential memory leak in rpc_new_client

If the call to rpciod_up() fails, we currently leak a reference to the
struct rpc_xprt.
As part of the fix, we also remove the redundant check for xprt!=NULL.
This is already taken care of by the callers.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a58e0be6f6b3eb2079b0b8fedc9df6fa86869f1e 22-Mar-2013 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Remove extra xprt_put()

While testing error cases where rpc_new_client() fails, I saw
some oopses.

If rpc_new_client() fails, it already invokes xprt_put(). Thus
__rpc_clone_client() does not need to invoke it again.

Introduced by commit 1b63a751 "SUNRPC: Refactor rpc_clone_client()"
Fri Sep 14, 2012.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@vger.kernel.org [>=3.7]
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3ed5e2a2c394df4e03a680842c2d07a8680f133b 04-Mar-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Report network/connection errors correctly for SOFTCONN rpc tasks

In the case of a SOFTCONN rpc task, we really want to ensure that it
reports errors like ENETUNREACH back to the caller. Currently, only
some of these errors are being reported back (connect errors are not),
and they are being converted by the RPC layer into EIO.

Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
512e4b291c0e97af24619a91f3e8963697da00d8 03-Mar-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: One line comment fix

Reported-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
edddbb1eda61753c886a3c5e159293a7b3a9e30a 01-Mar-2013 Weston Andros Adamson <dros@netapp.com> SUNRPC: add call to get configured timeout

Returns the configured timeout for the xprt of the rpc client.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
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>
ad2368d6f5ec6467b9503176e9fb878daf999629 08-Jan-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Avoid RCU dereferences in the transport bind and connect code

Avoid an RCU dereference by removing task->tk_xprt

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a4f0835c604f80f945ab3e72ffd00547145c4b2b 08-Jan-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Eliminate task->tk_xprt accesses that bypass rcu_dereference()

tk_xprt is just a shortcut for tk_client->cl_xprt, however cl_xprt is
defined as an __rcu variable. Replace dereferences of tk_xprt with
non-rcu dereferences where it is safe to do so.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7144bca6814a79ac86800da9d7f05a8c07bc818c 10-Jan-2013 Randy Dunlap <rdunlap@infradead.org> nfs: fix sunrpc/clnt.c kernel-doc warnings

Fix new kernel-doc warnings in clnt.c:

Warning(net/sunrpc/clnt.c:561): No description found for parameter 'flavor'
Warning(net/sunrpc/clnt.c:561): Excess function parameter 'auth' description in 'rpc_clone_client_set_auth'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
360e1a534901592b289ba8768fc71b6e6ad49070 04-Jan-2013 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Partial revert of commit 168e4b39d1afb79a7e3ea6c3bb246b4c82c6bdb9

Partially revert commit (SUNRPC: add WARN_ON_ONCE for potential deadlock).
The looping behaviour has been tracked down to a knownn issue with
workqueues, and a workaround has now been implemented.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Weston Andros Adamson <dros@netapp.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Bruce Fields <bfields@fieldses.org>
Cc: stable@vger.kernel.org [>= 3.7]
cd6c5968582a273561464fe6b1e8cc8214be02df 17-Dec-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: continue run over clients list on PipeFS event instead of break

There are SUNRPC clients, which program doesn't have pipe_dir_name. These
clients can be skipped on PipeFS events, because nothing have to be created or
destroyed. But instead of breaking in case of such a client was found, search
for suitable client over clients list have to be continued. Otherwise some
clients could not be covered by PipeFS event handler.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: stable@vger.kernel.org [>= v3.4]
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
eb96d5c97b0825d542e9c4ba5e0a22b519355166 27-Nov-2012 Andy Adamson <andros@netapp.com> SUNRPC handle EKEYEXPIRED in call_refreshresult

Currently, when an RPCSEC_GSS context has expired or is non-existent
and the users (Kerberos) credentials have also expired or are non-existent,
the client receives the -EKEYEXPIRED error and tries to refresh the context
forever. If an application is performing I/O, or other work against the share,
the application hangs, and the user is not prompted to refresh/establish their
credentials. This can result in a denial of service for other users.

Users are expected to manage their Kerberos credential lifetimes to mitigate
this issue.

Move the -EKEYEXPIRED handling into the RPC layer. Try tk_cred_retry number
of times to refresh the gss_context, and then return -EACCES to the application.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f994c43d19a9116727d4c228d3f13db595bff562 01-Nov-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Clean up rpc_bind_new_program

We can and should use the rpc_create_args and __rpc_clone_client()
to change the program and version number on the resulting rpc_client.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
50d2bdb19734f9e9f21e63881a9b6c8db4cc0eb7 01-Nov-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from rpc_call_sync

Use WARN_ON_ONCE instead of calling BUG_ON and return -EINVAL when
RPC_TASK_ASYNC flag is passed to rpc_call_sync.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8b827e1f1e46c45a4c9c389676f622e569d8a8ea 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from call_bc_transmit

Remove redundant BUG_ON().

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1facf4c4a486d515759edc0b2ece927942dd8167 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from call_bc_transmit

Replace BUG_ON() with WARN_ON_ONCE().

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
576e613d2111036a075b7c4f7cafdf29a0021c29 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from call_transmit

Remove unneeded BUG_ON()

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9a6478f6cccbd15af30f02368e68b47390360485 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON from rpc_run_bc_task

Replace BUG_ON() with WARN_ON_ONCE() - rpc_run_bc_task calls rpc_init_task()
then increments the tk_count, so this is a simple sanity check that
if hit once would hit every time this code path is executed.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
922eeac30d8456b8e4462cfb94ddbb6846790ad4 23-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: remove BUG_ON in __rpc_clnt_handle_event

Print a KERN_INFO message before rpc_d_lookup_sb returns NULL, like
other error paths in that function.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
168e4b39d1afb79a7e3ea6c3bb246b4c82c6bdb9 30-Oct-2012 Weston Andros Adamson <dros@netapp.com> SUNRPC: add WARN_ON_ONCE for potential deadlock

rpc_shutdown_client should never be called from a workqueue context.
If it is, it could deadlock looping forever trying to kill tasks that are
assigned to the same kworker thread (and will never run rpc_exit_task).

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ba9b584c1dc37851d9c6ca6d0d2ccba55d9aad04 14-Sep-2012 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce rpc_clone_client_set_auth()

An ULP is supposed to be able to replace a GSS rpc_auth object with
another GSS rpc_auth object using rpcauth_create(). However,
rpcauth_create() in 3.5 reliably fails with -EEXIST in this case.
This is because when gss_create() attempts to create the upcall pipes,
sometimes they are already there. For example if a pipe FS mount
event occurs, or a previous GSS flavor was in use for this rpc_clnt.

It turns out that's not the only problem here. While working on a
fix for the above problem, we noticed that replacing an rpc_clnt's
rpc_auth is not safe, since dereferencing the cl_auth field is not
protected in any way.

So we're deprecating the ability of rpcauth_create() to switch an
rpc_clnt's security flavor during normal operation. Instead, let's
add a fresh API that clones an rpc_clnt and gives the clone a new
flavor before it's used.

This makes immediate use of the new __rpc_clone_client() helper.

This can be used in a similar fashion to rpcauth_create() when a
client is hunting for the correct security flavor. Instead of
replacing an rpc_clnt's security flavor in a loop, the ULP replaces
the whole rpc_clnt.

To fix the -EEXIST problem, any ULP logic that relies on replacing
an rpc_clnt's rpc_auth with rpcauth_create() must be changed to use
this API instead.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1b63a75180c6c65c71655c250a4e6b578ba7d1c0 14-Sep-2012 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Refactor rpc_clone_client()

rpc_clone_client() does most of the same tasks as rpc_new_client(),
so there is an opportunity for code re-use. Create a generic helper
that makes it easy to clone an RPC client while replacing any of the
clnt's parameters.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a564b8f0398636ba30b07c0eaebdef7ff7837249 01-Aug-2012 Mel Gorman <mgorman@suse.de> nfs: enable swap on NFS

Implement the new swapfile a_ops for NFS and hook up ->direct_IO. This
will set the NFS socket to SOCK_MEMALLOC and run socket reconnect under
PF_MEMALLOC as well as reset SOCK_MEMALLOC before engaging the protocol
->connect() method.

PF_MEMALLOC should allow the allocation of struct socket and related
objects and the early (re)setting of SOCK_MEMALLOC should allow us to
receive the packets required for the TCP connection buildup.

[jlayton@redhat.com: Restore PF_MEMALLOC task flags in all cases]
[dfeng@redhat.com: Fix handling of multiple swap files]
[a.p.zijlstra@chello.nl: Original patch]
Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Eric Paris <eparis@redhat.com>
Cc: James Morris <jmorris@namei.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Neil Brown <neilb@suse.de>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
cac5d07e3ca696dcacfb123553cf6c722111cfd3 18-Jul-2012 Joe Perches <joe@perches.com> sunrpc: clnt: Add missing braces

Add a missing set of braces that commit 4e0038b6b24
("SUNRPC: Move clnt->cl_server into struct rpc_xprt")
forgot.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org [>= 3.4]
2c53040f018b6c36a46eec75b9b937aaa5f78e6d 10-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> net: Fix (nearly-)kernel-doc comments for various functions

Fix incorrect start markers, wrapped summary lines, missing section
breaks, incorrect separators, and some name mismatches.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1afeaf5c29aa07db25760d2fbed5c08a3aec3498 19-May-2012 Trond Myklebust <Trond.Myklebust@netapp.com> sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot

xprt_alloc_slot will call rpc_delay() to make the task wait a bit before
retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot.
The problem is that rpc_delay will clear the task->tk_status, causing
call_reserveresult to abort the task.

The solution is simply to let call_reserveresult handle the ENOMEM error
directly.

Reported-by: Jeff Layton <jlayton@redhat.com>
Cc: stable@vger.kernel.org [>= 3.1]
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
26fe575028703948880fce4355a210c76bb0536e 10-May-2012 Linus Torvalds <torvalds@linux-foundation.org> vfs: make it possible to access the dentry hash/len as one 64-bit entry

This allows comparing hash and len in one operation on 64-bit
architectures. Right now only __d_lookup_rcu() takes advantage of this,
since that is the case we care most about.

The use of anonymous struct/unions hides the alternate 64-bit approach
from most users, the exception being a few cases where we initialize a
'struct qstr' with a static initializer. This makes the problematic
cases use a new QSTR_INIT() helper function for that (but initializing
just the name pointer with a "{ .name = xyzzy }" initializer remains
valid, as does just copying another qstr structure).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
cbbb34498f8b2b26cbdc79532c8a2ee5cd1e756a 30-Apr-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: RPC client must use the current utsname hostname string

Now that the rpc client is namespace aware, it needs to use the
utsname of the process that created it instead of using the
init_utsname. Both rpc_new_client and rpc_clone_client need to
be fixed.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
ea8cfa06795bb30d2ea61f503ef129284492c06a 27-Apr-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: traverse clients tree on PipeFS event

v2: recursion was replaced by loop

If client is a clone, then it's parent can not be in the list.
But parent's Pipefs dentries have to be created and destroyed.

Note: event skip helper for clients introduced

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7aab449e5a2ebfa9c5116e87e16536bc4195e4de 20-Apr-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: skip clients with program without PipeFS entries

1) This is sane.
2) Otherwise there will be soft lockup:

do {
rpc_get_client_for_event (clnt->cl_dentry == NULL ==> choose)
__rpc_pipefs_event (clnt->cl_program->pipe_dir_name == NULL ==> return)
} while (1)

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a4dff1bc492ee4a2184d384ae8b5bcab5859e150 20-Apr-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: skip dead but not buried clients on PipeFS events

These clients can't be safely dereferenced if their counter in 0.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
9ffc93f203c18a70623f21950f1dd473c9ec48cd 28-Mar-2012 David Howells <dhowells@redhat.com> Remove all #inclusions of asm/system.h

Remove all #inclusions of asm/system.h preparatory to splitting and killing
it. Performed with the following command:

perl -p -i -e 's!^#\s*include\s*<asm/system[.]h>.*\n!!' `grep -Irl '^#\s*include\s*<asm/system[.]h>' *`

Signed-off-by: David Howells <dhowells@redhat.com>
2e738fdce22f9a7edf20281fd2d768ef9785922e 01-Mar-2012 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Add API to acquire source address

NFSv4.0 clients must send endpoint information for their callback
service to NFSv4.0 servers during their first contact with a server.
Traditionally on Linux, user space provides the callback endpoint IP
address via the "clientaddr=" mount option.

During an NFSv4 migration event, it is possible that an FSID may be
migrated to a destination server that is accessible via a different
source IP address than the source server was. The client must update
callback endpoint information on the destination server so that it can
maintain leases and allow delegation.

Without a new "clientaddr=" option from user space, however, the
kernel itself must construct an appropriate IP address for the
callback update. Provide an API in the RPC client for upper layer
RPC consumers to acquire a source address for a remote.

The mechanism used by the mount.nfs command is copied: set up a
connected UDP socket to the designated remote, then scrape the source
address off the socket. We are careful to select the correct network
namespace when setting up the temporary UDP socket.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
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>
da3b462296e421e8f54b54b7d2706488661c36e2 27-Feb-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: release per-net clients lock before calling PipeFS dentries creation

v3:
1) Lookup for client is performed from the beginning of the list on each PipeFS
event handling operation.

Lockdep is sad otherwise, because inode mutex is taken on PipeFS dentry
creation, which can be called on mount notification, where this per-net client
lock is taken on clients list walk.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5753cba17611af108995672c4e2d978014e17a56 06-Feb-2012 Steve Dickson <steved@redhat.com> SUNRPC: Adding status trace points

This patch adds three trace points to the status routines
in the sunrpc state machine.

The goal of these trace points is to give an Admin
the ability to check on binding status or connection
status to see if there is a potential problem.

Signed-off-by: Steve Dickson <steved@redhat.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>
080b794ce5ad318ce34c52abaedf1bc6788a5abb 20-Jan-2012 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: constify rpc_program->name

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>
eee17325f1dfbe004f1475743bab9e3d050d00f5 10-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> NFS: idmap PipeFS notifier introduced

v2:
1) Added "nfs_idmap_init" and "nfs_idmap_quit" definitions for kernels built
without CONFIG_NFS_V4 option set.

This patch subscribes NFS clients to RPC pipefs notifications. Idmap notifier
is registering on NFS module load. This notifier callback is responsible for
creation/destruction of PipeFS idmap pipe dentry for NFS4 clients.

Since ipdmap pipe is created in rpc client pipefs directory, we have make sure,
that this directory has been created already. IOW RPC client notifier callback
has been called already. To achive this, PipeFS notifier priorities has been
introduced (RPC clients notifier priority is greater than NFS idmap one).
But this approach gives another problem: unlink for RPC client directory will
be called before NFS idmap pipe unlink on UMOUNT event and will fail, because
directory is not empty.
The solution, introduced in this patch, is to try to remove client directory
once again after idmap pipe was unlinked. This looks like ugly hack, so
probably it should be replaced in some more elegant way.

Note that no locking required in notifier callback because PipeFS superblock
pointer is passed as an argument from it's creation or destruction routine and
thus we can be sure about it's validity.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
30507f58ce11e7664512059c708347d7a7d75271 11-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove RPC PipeFS mount point reference from RPC client

This is a cleanup patch. We don't need this reference anymore.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
70fe25b6e1a535f09792d1ed7012036c7bd506b2 11-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove RPC pipefs mount point manipulations from RPC clients code

v2:
1) Updated due to changes in the first patch of the series.

Now, with RPC pipefs mount notifications handling in RPC clients, we can remove
mount point creation and destruction. RPC clients dentries will be created on
PipeFS mount event and removed on umount event.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f5131257f771ad0e84cf0314a2a86b66318755a9 11-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: remove RPC client pipefs dentries after unregister

Without this patch we have races:

rpc_fill_super rpc_free_client
rpc_pipefs_event(MOUNT) rpc_remove_pipedir
spin_lock(&rpc_client_lock);
rpc_setup_pipedir_sb
spin_unlock(&rpc_client_lock);
spin_lock(&rpc_client_lock);
(remove from list)
spin_unlock(&rpc_client_lock);
MEAMORY LEAKED

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
80df9d202255071c8ec610a6a3fdca5cac69f7bd 11-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: subscribe RPC clients to pipefs notifications

This patch subscribes RPC clients to RPC pipefs notifications. RPC clients
notifier block is registering with pipefs initialization during SUNRPC module
init.
This notifier callback is responsible for RPC client PipeFS directory and GSS
pipes creation. For pipes creation and destruction two additional callbacks
were added to struct rpc_authops.
Note that no locking required in notifier callback because PipeFS superblock
pointer is passed as an argument from it's creation or destruction routine and
thus we can be sure about it's validity.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
70abc49b4f4a4ef04a6bd9852edbd047b480bed7 12-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: make SUNPRC clients list per network namespace context

This patch moves static SUNRPC clients list and it's lock to sunrpc_net
structure.
Currently this list is used only for debug purposes. But later it will be used
also for selecting clients by networks namespace on PipeFS mount/umount events.
Per-network namespace lists will make this faster and simplier.

Note: client list is taken from "init_net" network namespace context in
rpc_show_tasks(). This will be changed some day later with making SUNRPC
sysctl's per network namespace context.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0157d021d23a087eecfa830502f81cfe843f0d16 11-Jan-2012 Stanislav Kinsbursky <skinsbursky@parallels.com> SUNRPC: handle RPC client pipefs dentries by network namespace aware routines

v2:
1) "Over-put" of PipeFS mount point fixed. Fix is ugly, but allows to bisect
the patch set. And it will be removed later in the series.

This patch makes RPC clients PipeFs dentries allocations in it's owner network
namespace context.
RPC client pipefs dentries creation logic has been changed:
1) Pipefs dentries creation by sb was moved to separated function, which will
be used for handling PipeFS mount notification.
2) Initial value of RPC client PipeFS dir dentry is set no NULL now.

RPC client pipefs dentries cleanup logic has been changed:
1) Cleanup is done now in separated rpc_remove_pipedir() function, which takes
care about pipefs superblock locking.

Also this patch removes slashes from cb_program.pipe_dir_name and from
NFS_PIPE_DIRNAME to make rpc_d_lookup_sb() work. This doesn't affect
vfs_path_lookup() results in nfs4blocklayout_init() since this slash is cutted
off anyway in link_path_walk().

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d00c5d43866720963a265fa3129f3203cac35b8e 19-Oct-2011 Trond Myklebust <Trond.Myklebust@netapp.com> NFS: Get rid of nfs_restart_rpc()

It can trivially be replaced with rpc_restart_call_prepare.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e0a0124936171af6156b80fe8ac8799f039e767f 27-Jun-2011 Al Viro <viro@zeniv.linux.org.uk> switch vfs_path_lookup() to struct path

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9e00abc3c20904fd6a5d888bb7023925799ec8a5 14-Jul-2011 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: sunrpc should not explicitly depend on NFS config options

Change explicit references to CONFIG_NFS_V4_1 to implicit ones
Get rid of the unnecessary defines in backchannel_rqst.c and
bc_svc.c: the Makefile takes care of those dependency.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
726fd6ad59f73bd116b6a22d701db078183673c8 01-Jun-2011 Vasily Averin <vvs@sw.ru> sunrpc: use dprint_status() macro in call_decode()

common dprint_status() macro is used in all callbacks but not in call_decode()

Signed-off-by: Vasily Averin <vvs@sw.ru>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
89f0e4feafb64643b0f0aba9d89984362bac9739 01-Jul-2011 Joe Perches <joe@perches.com> sunrpc: Reduce switch/case indent

Make the case labels the same indent as the switch.

git diff -w shows 80 column line reflowing.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5afa9133cfe67f1bfead6049a9640c9262a7101c 17-Jun-2011 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure the RPC client only quits on fatal signals

Fix a couple of instances where we were exiting the RPC client on
arbitrary signals. We should only do so on fatal signals.

Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0b760113a3a155269a3fba93a409c640031dd68f 31-May-2011 Trond Myklebust <Trond.Myklebust@netapp.com> NLM: Don't hang forever on NLM unlock requests

If the NLM daemon is killed on the NFS server, we can currently end up
hanging forever on an 'unlock' request, instead of aborting. Basically,
if the rpcbind request fails, or the server keeps returning garbage, we
really want to quit instead of retrying.

Tested-by: Vasily Averin <vvs@sw.ru>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
176e21ee2ec89cae8d45cf1a850ea45a45428fb8 09-May-2011 Chuck Lever <chuck.lever@ORACLE.COM> SUNRPC: Support for RPC over AF_LOCAL transports

TI-RPC introduces the capability of performing RPC over AF_LOCAL
sockets. It uses this mainly for registering and unregistering
local RPC services securely with the local rpcbind, but we could
also conceivably use it as a generic upcall mechanism.

This patch provides a client-side only implementation for the moment.
We might also consider a server-side implementation to provide
AF_LOCAL access to NLM (for statd downcalls, and such like).

Autobinding is not supported on kernel AF_LOCAL transports at this
time. Kernel ULPs must specify the pathname of the remote endpoint
when an AF_LOCAL transport is created. rpcbind supports registering
services available via AF_LOCAL, so the kernel could handle it with
some adjustment to ->rpcbind and ->set_port. But we don't need this
feature for doing upcalls via well-known named sockets.

This has not been tested with ULPs that move a substantial amount of
data. Thus, I can't attest to how robust the write_space and
congestion management logic is.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
559649efb9b0d248541933197bdf7b75529da457 09-May-2011 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Remove obsolete comment

Clean up. The documenting comment at the top of net/sunrpc/clnt.c is
out of date. We adopted BSD's RTO estimation mechanism years ago.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
da09eb93033e7204cb3e3f3140b46cf108c42c8f 09-May-2011 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up use of curly braces in switch cases

Clean up. Preferred style is not to use curly braces around
switch cases. I'm about to add another case that needs a third
type cast.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7494d00c7b826b6ceb79ec33892bd0ef59be5614 24-Apr-2011 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Allow RPC calls to return ETIMEDOUT instead of EIO

On occasion, it is useful for the NFS layer to distinguish between
soft timeouts and other EIO errors due to (say) encoding errors,
or authentication errors.

The following patch ensures that the default behaviour of the RPC
layer remains to return EIO on soft timeouts (until we have
audited all the callers).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8e26de238fd794c8ea56a5c98bf67c40cfeb051d 17-Mar-2011 Stanislav Kinsbursky <skinsbursky@parallels.com> RPC: killing RPC tasks races fixed

RPC task RPC_TASK_QUEUED bit is set must be checked before trying to wake up
task rpc_killall_tasks() because task->tk_waitqueue can not be set (equal to
NULL).
Also, as Trond Myklebust mentioned, such approach (instead of checking
tk_waitqueue to NULL) allows us to "optimise away the call to
rpc_wake_up_queued_task() altogether for those
tasks that aren't queued".

Here is an example of dereferencing of tk_waitqueue equal to NULL:

CPU 0 CPU 1 CPU 2
-------------------- --------------------- --------------------------
nfs4_run_open_task
rpc_run_task
rpc_execute
rpc_set_active
rpc_make_runnable
(waiting)
rpc_async_schedule
nfs4_open_prepare
nfs_wait_on_sequence
nfs_umount_begin
rpc_killall_tasks
rpc_wake_up_task
rpc_wake_up_queued_task
spin_lock(tk_waitqueue == NULL)
BUG()
rpc_sleep_on
spin_lock(&q->lock)
__rpc_sleep_on
task->tk_waitqueue = q

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cbdabc7f8bf14ca1d40ab1cb86f64b3bc09716e8 01-Mar-2011 Andy Adamson <andros@netapp.com> NFSv4.1: filelayout async error handler

Use our own async error handler.
Mark the layout as failed and retry i/o through the MDS on specified errors.

Update the mds_offset in nfs_readpage_retry so that a failed short-read retry
to a DS gets correctly resent through the MDS.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
eabf5baaaaf41b6a0273043cfb06d53dca67acef 11-Feb-2011 Fred Isaman <iisaman@netapp.com> RPC: clarify rpc_run_task error handling

rpc_run_task can only fail if it is not passed in a preallocated task.
However, that is not at all clear with the current code. So
remove several impossible to occur failure checks.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b3bcedadf23264c3b7afcbfbfe1965a17ef1352c 21-Dec-2010 Joe Perches <joe@perches.com> net/sunrpc/clnt.c: Convert sprintf_symbol to %ps

Signed-off-by: Joe Perches <joe@perches.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>
5fc43978a79e8021c189660ab63249fd29c5fb32 20-Nov-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix an infinite loop in call_refresh/call_refreshresult

If the rpcauth_refreshcred() call returns an error other than
EACCES, ENOMEM or ETIMEDOUT, we currently end up looping forever
between call_refresh and call_refreshresult.

The correct thing to do here is to exit on all errors except
EAGAIN and ETIMEDOUT, for which case we retry 3 times, then
return EACCES.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
118df3d17f11733b294ea2cd988d56ee376ef9fd 24-Oct-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: After calling xprt_release(), we must restart from call_reserve

Rob Leslie reports seeing the following Oops after his Kerberos session
expired.

BUG: unable to handle kernel NULL pointer dereference at 00000058
IP: [<e186ed94>] rpcauth_refreshcred+0x11/0x12c [sunrpc]
*pde = 00000000
Oops: 0000 [#1]
last sysfs file: /sys/devices/platform/pc87360.26144/temp3_input
Modules linked in: autofs4 authenc esp4 xfrm4_mode_transport ipt_LOG ipt_REJECT xt_limit xt_state ipt_REDIRECT xt_owner xt_HL xt_hl xt_tcpudp xt_mark cls_u32 cls_tcindex sch_sfq sch_htb sch_dsmark geodewdt deflate ctr twofish_generic twofish_i586 twofish_common camellia serpent blowfish cast5 cbc xcbc rmd160 sha512_generic sha1_generic hmac crypto_null af_key rpcsec_gss_krb5 nfsd exportfs nfs lockd fscache nfs_acl auth_rpcgss sunrpc ip_gre sit tunnel4 dummy ext3 jbd nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_conntrack_ftp iptable_mangle iptable_nat nf_nat nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 iptable_filter ip_tables x_tables pc8736x_gpio nsc_gpio pc87360 hwmon_vid loop aes_i586 aes_generic sha256_generic dm_crypt cs5535_gpio serio_raw cs5535_mfgpt hifn_795x des_generic geode_rng rng_core led_class ext4 mbcache jbd2 crc16 dm_mirror dm_region_hash dm_log dm_snapshot dm_mod sd_mod crc_t10dif ide_pci_generic cs5536 amd74xx ide_core pata_cs5536 ata_generic libata usb_storage via_rhine mii scsi_mod btrfs zlib_deflate crc32c libcrc32c [last unloaded: scsi_wait_scan]

Pid: 12875, comm: sudo Not tainted 2.6.36-net5501 #1 /
EIP: 0060:[<e186ed94>] EFLAGS: 00010292 CPU: 0
EIP is at rpcauth_refreshcred+0x11/0x12c [sunrpc]
EAX: 00000000 EBX: defb13a0 ECX: 00000006 EDX: e18683b8
ESI: defb13a0 EDI: 00000000 EBP: 00000000 ESP: de571d58
DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068
Process sudo (pid: 12875, ti=de570000 task=decd1430 task.ti=de570000)
Stack:
e186e008 00000000 defb13a0 0000000d deda6000 e1868f22 e196f12b defb13a0
<0> defb13d8 00000000 00000000 e186e0aa 00000000 defb13a0 de571dac 00000000
<0> e186956c de571e34 debea5c0 de571dc8 e186967a 00000000 debea5c0 de571e34
Call Trace:
[<e186e008>] ? rpc_wake_up_next+0x114/0x11b [sunrpc]
[<e1868f22>] ? call_decode+0x24a/0x5af [sunrpc]
[<e196f12b>] ? nfs4_xdr_dec_access+0x0/0xa2 [nfs]
[<e186e0aa>] ? __rpc_execute+0x62/0x17b [sunrpc]
[<e186956c>] ? rpc_run_task+0x91/0x97 [sunrpc]
[<e186967a>] ? rpc_call_sync+0x40/0x5b [sunrpc]
[<e1969ca2>] ? nfs4_proc_access+0x10a/0x176 [nfs]
[<e19572fa>] ? nfs_do_access+0x2b1/0x2c0 [nfs]
[<e186ed61>] ? rpcauth_lookupcred+0x62/0x84 [sunrpc]
[<e19573b6>] ? nfs_permission+0xad/0x13b [nfs]
[<c0177824>] ? exec_permission+0x15/0x4b
[<c0177fbd>] ? link_path_walk+0x4f/0x456
[<c017867d>] ? path_walk+0x4c/0xa8
[<c0179678>] ? do_path_lookup+0x1f/0x68
[<c017a3fb>] ? user_path_at+0x37/0x5f
[<c016359c>] ? handle_mm_fault+0x229/0x55b
[<c0170a2d>] ? sys_faccessat+0x93/0x146
[<c0170aef>] ? sys_access+0xf/0x13
[<c02cf615>] ? syscall_call+0x7/0xb
Code: 0f 94 c2 84 d2 74 09 8b 44 24 0c e8 6a e9 8b de 83 c4 14 89 d8 5b 5e 5f 5d c3 55 57 56 53 83 ec 1c fc 89 c6 8b 40 10 89 44 24 04 <8b> 58 58 85 db 0f 85 d4 00 00 00 0f b7 46 70 8b 56 20 89 c5 83
EIP: [<e186ed94>] rpcauth_refreshcred+0x11/0x12c [sunrpc] SS:ESP 0068:de571d58
CR2: 0000000000000058

This appears to be caused by the function rpc_verify_header() first
calling xprt_release(), then doing a call_refresh. If we release the
transport slot, we should _always_ jump back to call_reserve before
calling anything else.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
9a23e332ec621d36e52cc7a978abc0917067b1aa 29-Sep-2010 Pavel Emelyanov <xemul@parallels.com> sunrpc: Add net to xprt_create

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
55576244eba805307a2b2b6a145b8f85f8c7c124 13-Sep-2010 J. Bruce Fields <bfields@redhat.com> SUNRPC: cleanup state-machine ordering

This is just a minor cleanup: net/sunrpc/clnt.c clarifies the rpc client
state machine by commenting each state and by laying out the functions
implementing each state in the order that each state is normally
executed (in the absence of errors).

The previous patch "Fix null dereference in call_allocate" changed the
order of the states. Move the functions and update the comments to
reflect the change.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
006abe887c5e637d059c44310de6c92f36aded3b 13-Sep-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a race in rpc_info_open

There is a race between rpc_info_open and rpc_release_client()
in that nothing stops a process from opening the file after
the clnt->cl_kref goes to zero.

Fix this by using atomic_inc_unless_zero()...

Reported-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
f2d47d02fd84343a3c5452daca6ed12c75618aff 13-Sep-2010 J. Bruce Fields <bfields@redhat.com> Fix null dereference in call_allocate

In call_allocate we need to reach the auth in order to factor au_cslack
into the allocation.

As of a17c2153d2e271b0cbacae9bed83b0eaa41db7e1 "SUNRPC: Move the bound
cred to struct rpc_rqst", call_allocate attempts to do this by
dereferencing tk_client->cl_auth, however this is not guaranteed to be
defined--cl_auth can be zero in the case of gss context destruction (see
rpc_free_auth).

Reorder the client state machine to bind credentials before allocating,
so that we can instead reach the auth through the cred.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
a17c2153d2e271b0cbacae9bed83b0eaa41db7e1 31-Jul-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move the bound cred to struct rpc_rqst

This will allow us to save the original generic cred in rpc_message, so
that if we migrate from one server to another, we can generate a new bound
cred without having to punt back to the NFS layer.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8572b8e2e3c5f3d990122348c4d2c64dad338611 31-Jul-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Clean up of rpc_bindcred()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
58f9612c6ea858f532021a0ce42ec53cb0a493b3 31-Jul-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move remaining RPC client related task initialisation into clnt.c

Now that rpc_run_task() is the sole entry point for RPC calls, we can move
the remaining rpc_client-related initialisation of struct rpc_task from
sched.c into clnt.c.

Also move rpc_killall_tasks() into the same file, since that too is
relative to the rpc_clnt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f1f88fc7e818c6678c6799a2edb8f1aeccc124aa 31-Jul-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: The function rpc_restart_call() should return success/failure

Both rpc_restart_call_prepare() and rpc_restart_call() test for the
RPC_TASK_KILLED flag, and fail to restart the RPC call if that flag is set.

This patch allows callers to know whether or not the restart was
successful, so that they can perform cleanups etc in case of failure.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3fa21e07e6acefa31f974d57fba2b6920a7ebd1a 18-May-2010 Joe Perches <joe@perches.com> net: Remove unnecessary returns from void function()s

This patch removes from net/ (but not any netfilter files)
all the unnecessary return; statements that precede the
last closing brace of void functions.

It does not remove the returns that are immediately
preceded by a label as gcc doesn't like that.

Done via:
$ grep -rP --include=*.[ch] -l "return;\n}" net/ | \
xargs perl -i -e 'local $/ ; while (<>) { s/\n[ \t\n]+return;\n}/\n}/g; print; }'

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
19445b99b6d66af661c586c052de23110731a502 16-Apr-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Cleanup - make rpc_new_task() call rpc_release_calldata on failure

Also have it return an ERR_PTR(-ENOMEM) instead of a null pointer.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ff0901f8036a1586037c30a365c9666e946af0f1 19-Mar-2010 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix the return value of rpc_run_bc_task()

Currently rpc_run_bc_task() will return NULL if the task allocation failed.
However the only caller is bc_send, which assumes that the return value
will be an ERR_PTR.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3a28becc35e5c8f1fabb707bcd8a473712653de6 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: soft connect semantics for UDP

Introduce soft connect behavior for UDP transports. In this case, a
major timeout returns ETIMEDOUT instead of EIO.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
caabea8a565fb4e16f8e58e16bb9d535e591b709 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use soft connect semantics when performing RPC ping

Currently, if a remote RPC service is unreachable, an RPC ping will
hang until the underlying transport connect attempt times out. A more
desirable behavior might be to have the ping fail immediately so upper
layers can recover appropriately.

In the case of an NFS mount, for instance, this would mean the
mount(2) system call could fail immediately if the server isn't
listening, rather than hanging uninterruptibly for more than 3
minutes.

Change rpc_ping() so that it fails immediately for connection-oriented
transports. rpc_create() will then fail immediately for such
transports if an RPC ping was requested.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.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>
09a21c4102c8f7893368553273d39c0cadedf9af 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Allow RPCs to fail quickly if the server is unreachable

The kernel sometimes makes RPC calls to services that aren't running.
Because the kernel's RPC client always assumes the hard retry semantic
when reconnecting a connection-oriented RPC transport, the underlying
reconnect logic takes a long while to time out, even though the remote
may have responded immediately with ECONNREFUSED.

In certain cases, like upcalls to our local rpcbind daemon, or for NFS
mount requests, we'd like the kernel to fail immediately if the remote
service isn't reachable. This allows another transport to be tried
immediately, or the pending request can be abandoned quickly.

Introduce a per-request flag which controls how call_transmit_status()
behaves when request transmission fails because the server cannot be
reached.

We don't want soft connection semantics to apply to other errors. The
default case of the switch statement in call_transmit_status() no
longer falls through; the fall through code is copied to the default
case, and a "break;" is added.

The transport's connection re-establishment timeout is also ignored for
such requests. We want the request to fail immediately, so the
reconnect delay is skipped. Additionally, we don't want a connect
failure here to further increase the reconnect timeout value, since
this request will not be retried.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
206a134b4d8abf57cd34dffacf993869355b9aac 03-Dec-2009 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Check explicitly for tk_status == 0 in call_transmit_status()

The success case, where task->tk_status == 0, is by far the most
frequent case in call_transmit_status().

The default: arm of the switch statement in call_transmit_status()
handles the 0 case. default: was moved close to the top of the switch
statement in call_transmit_status() under the theory that the compiler
places object code for the earliest arms of a switch statement first,
making the CPU do less work.

The default: arm of a switch statement, however, is executed only
after all the other cases have been checked. Even if the compiler
rearranges the object code, the default: arm is the "last resort",
meaning all of the other cases have been explicitly exhausted. That
makes the current arrangement about as inefficient as it gets for the
common case.

To fix this, add an explicit check for zero before the switch
statement. That forces the compiler to do the zero check first, no
matter what optimizations it might try to do to the switch statement.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0c01695dabe508ecf3a619c36f0918e8d24c0d05 24-Sep-2009 Jaswinder Singh Rajput <jaswinder@kernel.org> net: fix htmldocs sunrpc, clnt.c

DOCPROC Documentation/DocBook/networking.xml
Warning(net/sunrpc/clnt.c:647): No description found for parameter 'req'
Warning(net/sunrpc/clnt.c:647): No description found for parameter 'tk_ops'
Warning(net/sunrpc/clnt.c:647): Excess function parameter 'ops' description in 'rpc_run_bc_task'

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Cc: Benny Halevy <bhalevy@panasas.com>
Cc: Andy Adamson <andros@netapp.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
7a73fdde3990ea840b604248362876437ea8ce80 24-Sep-2009 Jaswinder Singh Rajput <jaswinder@kernel.org> net: fix htmldocs sunrpc, clnt.c


DOCPROC Documentation/DocBook/networking.xml
Warning(net/sunrpc/clnt.c:647): No description found for parameter 'req'
Warning(net/sunrpc/clnt.c:647): No description found for parameter 'tk_ops'
Warning(net/sunrpc/clnt.c:647): Excess function parameter 'ops' description in 'rpc_run_bc_task'

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Cc: Benny Halevy <bhalevy@panasas.com>
Cc: Andy Adamson <andros@netapp.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: David Miller <davem@davemloft.net>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f300baba5a1536070d6d77bf0c8c4ca999bb4f0f 10-Sep-2009 Alexandros Batsakis <batsakis@netapp.com> nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel

[sunrpc: change idle timeout value for the backchannel]
Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2574cc9f4ffc6c681c9177111357efe5b76f0e36 28-Aug-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix rpc_task_force_reencode

This patch fixes the bug that was reported in
http://bugzilla.kernel.org/show_bug.cgi?id=14053

If we're in the case where we need to force a reencode and then resend of
the RPC request, due to xprt_transmit failing with a networking error, then
we _must_ retransmit the entire request.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23ac6581702ac6d029643328a7e6ea3baf834c5e 09-Aug-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: clean up rpc_setup_pipedir()

There is still a little wart or two there: Since we've already got a
vfsmount, we might as well pass that in to rpc_create_client_dir.
Another point is that if we open code __rpc_lookup_path() here, then we can
avoid looking up the entire parent directory path over and over again: it
doesn't change.

Also get rid of rpc_clnt->cl_pathname, since it has no users...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7d217caca5d704e48aa5e59aba0b3ad4c7af4fd2 09-Aug-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Replace rpc_client->cl_dentry and cl_mnt, with a cl_path

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
458adb8ba9b26bfc66593866013adbb62a1a3d2e 09-Aug-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Rename rpc_mkdir to rpc_create_client_dir()

This reflects the fact that rpc_mkdir() as it stands today, can only create
a RPC client type directory.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
405f55712dfe464b3240d7816cc4fe4174831be2 11-Jul-2009 Alexey Dobriyan <adobriyan@gmail.com> headers: smp_lock.h redux

* Remove smp_lock.h from files which don't need it (including some headers!)
* Add smp_lock.h to files which do need it
* Make smp_lock.h include conditional in hardirq.h
It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

This will make hardirq.h inclusion cheaper for every PREEMPT=n config
(which includes allmodconfig/allyesconfig, BTW)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
dd2b63d049480979016b959abc2d141cdddb1389 01-Apr-2009 Ricardo Labiaga <Ricardo.Labiaga@netapp.com> nfs41: Rename rq_received to rq_reply_bytes_recvd

The 'rq_received' member of 'struct rpc_rqst' is used to track when we
have received a reply to our request. With v4.1, the backchannel
can now accept callback requests over the existing connection. Rename
this field to make it clear that it is only used for tracking reply bytes
and not all bytes received on the connection.

Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
55ae1aabfb108106dd095de2578ceef1c755a8b8 01-Apr-2009 Ricardo Labiaga <Ricardo.Labiaga@netapp.com> nfs41: Add backchannel processing support to RPC state machine

Adds rpc_run_bc_task() which is called by the NFS callback service to
process backchannel requests. It performs similar work to rpc_run_task()
though "schedules" the backchannel task to be executed starting at the
call_trasmit state in the RPC state machine.

It also introduces some miscellaneous updates to the argument validation,
call_transmit, and transport cleanup functions to take into account
that there are now forechannel and backchannel tasks.

Backchannel requests do not carry an RPC message structure, since the
payload has already been XDR encoded using the existing NFSv4 callback
mechanism.

Introduce a new transmit state for the client to reply on to backchannel
requests. This new state simply reserves the transport and issues the
reply. In case of a connection related error, disconnects the transport and
drops the reply. It requires the forechannel to re-establish the connection
and the server to retransmit the request, as stated in NFSv4.1 section
2.9.2 "Client and Server Transport Behavior".

Note: There is no need to loop attempting to reserve the transport. If EAGAIN
is returned by xprt_prepare_transmit(), return with tk_status == 0,
setting tk_action to call_bc_transmit. rpc_execute() will invoke it again
after the task is taken off the sleep queue.

[nfs41: rpc_run_bc_task() need not be exported outside RPC module]
[nfs41: New call_bc_transmit RPC state]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: Backchannel: No need to loop in call_bc_transmit()]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[rpc_count_iostats incorrectly exits early]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[Convert rpc_reply_expected() to inline function]
[Remove unnecessary BUG_ON()]
[Rename variable]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
f4a2e418bfd03a1f25f515e8a92ecd584d96cfc1 01-Apr-2009 Ricardo Labiaga <Ricardo.Labiaga@netapp.com> nfs41: Process the RPC call direction

Reading and storing the RPC direction is a three step process.

1. xs_tcp_read_calldir() reads the RPC direction, but it will not store it
in the XDR buffer since the 'struct rpc_rqst' is not yet available.

2. The 'struct rpc_rqst' is obtained during the TCP_RCV_COPY_DATA state.
This state need not necessarily be preceeded by the TCP_RCV_READ_CALLDIR.
For example, we may be reading a continuation packet to a large reply.
Therefore, we can't simply obtain the 'struct rpc_rqst' during the
TCP_RCV_READ_CALLDIR state and assume it's available during TCP_RCV_COPY_DATA.

This patch adds a new TCP_RCV_READ_CALLDIR flag to indicate the need to
read the RPC direction. It then uses TCP_RCV_COPY_CALLDIR to indicate the
RPC direction needs to be saved after the 'struct rpc_rqst' has been allocated.

3. The 'struct rpc_rqst' is obtained by the xs_tcp_read_data() helper
functions. xs_tcp_read_common() then saves the RPC direction in the XDR
buffer if TCP_RCV_COPY_CALLDIR is set. This will happen when we're reading
the data immediately after the direction was read. xs_tcp_read_common()
then clears this flag.

[was nfs41: Skip past the RPC call direction]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: sunrpc: Add RPC direction back into the XDR buffer]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: sunrpc: Don't skip past the RPC call direction]
Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
aae2006e9b0c294114915c13022fa348e1a88023 01-Apr-2009 Andy Adamson <andros@netapp.com> nfs41: sunrpc: Export the call prepare state for session reset

Signed-off-by: Andy Adamson<andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2a4919919a97911b0aa4b9f5ac1eab90ba87652b 11-Mar-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Return EAGAIN instead of ENOTCONN when waking up xprt->pending

While we should definitely return socket errors to the task that is
currently trying to send data, there is no need to propagate the same error
to all the other tasks on xprt->pending. Doing so actually slows down
recovery, since it causes more than one tasks to attempt socket recovery.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c8485e4d634f6df155040293928707f127f0d06d 11-Mar-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Handle ECONNREFUSED correctly in xprt_transmit()

If we get an ECONNREFUSED error, we currently go to sleep on the
'xprt->sending' wait queue. The problem is that no timeout is set there,
and there is nothing else that will wake the task up later.

We should deal with ECONNREFUSED in call_status, given that is where we
also deal with -EHOSTDOWN, and friends.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
15f081ca8ddfe150fb639c591b18944a539da0fc 11-Mar-2009 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Avoid an unnecessary task reschedule on ENOTCONN

If the socket is unconnected, and xprt_transmit() returns ENOTCONN, we
currently give up the lock on the transport channel. Doing so means that
the lock automatically gets assigned to the next task in the xprt->sending
queue, and so that task needs to be woken up to do the actual connect.

The following patch aims to avoid that unnecessary task switch.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
608207e8884e083ad8b8d33eda868da70f0d63e8 23-Dec-2008 Olga Kornievskaia <aglo@citi.umich.edu> rpc: pass target name down to rpc level on callbacks

The rpc client needs to know the principal that the setclientid was done
as, so it can tell gssd who to authenticate to.

Signed-off-by: Olga Kornievskaia <aglo@citi.umich.edu>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
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>
63ffc23d307c9534c732edd87895e37b223004a3 04-Oct-2008 Cedric Le Goater <clg@fr.ibm.com> sunrpc: fix oops in rpc_create when the mount namespace is unshared

On a system with nfs mounts, if a task unshares its mount namespace,
a oops can occur when the system is rebooted if the task is the last
to unreference the nfs mount. It will try to create a rpc request
using utsname() which has been invalidated by free_nsproxy().

The patch fixes the issue by using the global init_utsname() which is
always valid. the capability of identifying rpc clients per uts namespace
stills needs some extra work so this should not be a problem.

BUG: unable to handle kernel NULL pointer dereference at 00000004
IP: [<c024c9ab>] rpc_create+0x332/0x42f
Oops: 0000 [#1] DEBUG_PAGEALLOC

Pid: 1857, comm: uts-oops Not tainted (2.6.27-rc5-00319-g7686ad5 #4)
EIP: 0060:[<c024c9ab>] EFLAGS: 00210287 CPU: 0
EIP is at rpc_create+0x332/0x42f
EAX: 00000000 EBX: df26adf0 ECX: c0251887 EDX: 00000001
ESI: df26ae58 EDI: c02f293c EBP: dda0fc9c ESP: dda0fc2c
DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
Process uts-oops (pid: 1857, ti=dda0e000 task=dd9a0778 task.ti=dda0e000)
Stack: c0104532 dda0fffc dda0fcac dda0e000 dda0e000 dd93b7f0 00000009 c02f2880
df26aefc dda0fc68 c01096b7 00000000 c0266ee0 c039a070 c039a070 dda0fc74
c012ca67 c039a064 dda0fc8c c012cb20 c03daf74 00000011 00000000 c0275c90
Call Trace:
[<c0104532>] ? dump_trace+0xc2/0xe2
[<c01096b7>] ? save_stack_trace+0x1c/0x3a
[<c012ca67>] ? save_trace+0x37/0x8c
[<c012cb20>] ? add_lock_to_list+0x64/0x96
[<c0256fc4>] ? rpcb_register_call+0x62/0xbb
[<c02570c8>] ? rpcb_register+0xab/0xb3
[<c0252f4d>] ? svc_register+0xb4/0x128
[<c0253114>] ? svc_destroy+0xec/0x103
[<c02531b2>] ? svc_exit_thread+0x87/0x8d
[<c01a75cd>] ? lockd_down+0x61/0x81
[<c01a577b>] ? nlmclnt_done+0xd/0xf
[<c01941fe>] ? nfs_destroy_server+0x14/0x16
[<c0194328>] ? nfs_free_server+0x4c/0xaa
[<c019a066>] ? nfs_kill_super+0x23/0x27
[<c0158585>] ? deactivate_super+0x3f/0x51
[<c01695d1>] ? mntput_no_expire+0x95/0xb4
[<c016965b>] ? release_mounts+0x6b/0x7a
[<c01696cc>] ? __put_mnt_ns+0x62/0x70
[<c0127501>] ? free_nsproxy+0x25/0x80
[<c012759a>] ? switch_task_namespaces+0x3e/0x43
[<c01275a9>] ? exit_task_namespaces+0xa/0xc
[<c0117fed>] ? do_exit+0x4fd/0x666
[<c01181b3>] ? do_group_exit+0x5d/0x83
[<c011fa8c>] ? get_signal_to_deliver+0x2c8/0x2e0
[<c0102630>] ? do_notify_resume+0x69/0x700
[<c011d85a>] ? do_sigaction+0x134/0x145
[<c0127205>] ? hrtimer_nanosleep+0x8f/0xce
[<c0126d1a>] ? hrtimer_wakeup+0x0/0x1c
[<c0103488>] ? work_notifysig+0x13/0x1b
=======================
Code: 70 20 68 cb c1 2c c0 e8 75 4e 01 00 8b 83 ac 00 00 00 59 3d 00 f0 ff ff 5f 77 63 eb 57 a1 00 80 2d c0 8b 80 a8 02 00 00 8d 73 68 <8b> 40 04 83 c0 45 e8 41 46 f7 ff ba 20 00 00 00 83 f8 21 0f 4c
EIP: [<c024c9ab>] rpc_create+0x332/0x42f SS:ESP 0068:dda0fc2c

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d5b337b4877f7c4e1d761434ee04d045b0201e03 28-Sep-2008 Benny Halevy <bhalevy@panasas.com> nfsd: use nfs client rpc callback program

since commit ff7d9756b501744540be65e172d27ee321d86103
"nfsd: use static memory for callback program and stats"
do_probe_callback uses a static callback program
(NFS4_CALLBACK) rather than the one set in clp->cl_callback.cb_prog
as passed in by the client in setclientid (4.0)
or create_session (4.1).

This patches introduces rpc_create_args.prognumber that allows
overriding program->number when creating rpc_clnt.

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
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>
b6b6152c46861dd914d0e6cea9c27df057d6e235 09-Jun-2008 Olga Kornievskaia <aglo@citi.umich.edu> rpc: bring back cl_chatty

The cl_chatty flag alows us to control whether a given rpc client leaves

"server X not responding, timed out"

messages in the syslog. Such messages make sense for ordinary nfs
clients (where an unresponsive server means applications on the
mountpoint are probably hanging), but not for the callback client (which
can fail more commonly, with the only result just of disabling some
optimizations).

Previously cl_chatty was removed, do to lack of users; reinstate it, and
use it for the nfsd's callback client.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cb3997b5a0b21864368bd1bd1d0929f9304fb6d9 21-May-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Display some debugging information as text rather than numbers

In rpc_show_tasks(), display the program name, version number, procedure
name and tk_action as human-readable variable-length text fields rather
than columnar numbers.

Doing the symbol lookup here helps in cases where we have actual
debugging output from a kernel log, but don't have access to the kernel
image or RPC module that generated the output.

Sample output:

-pid- flgs status -client- --rqstp- -timeout ---ops--
5608 0001 -11 eeb42690 f6d93710 0 f8fa1764 nfsv3 WRITE a:call_transmit_status q:none
5609 0001 -11 eeb42690 f6d937e0 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5610 0001 -11 eeb42690 f6d93230 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5611 0001 -11 eeb42690 f6d93300 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5612 0001 -11 eeb42690 f6d93090 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5613 0001 -11 eeb42690 f6d933d0 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5614 0001 -11 eeb42690 f6d93cc0 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5615 0001 -11 eeb42690 f6d93a50 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5616 0001 -11 eeb42690 f6d93640 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5617 0001 -11 eeb42690 f6d93b20 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending
5618 0001 -11 eeb42690 f6d93160 0 f8fa1764 nfsv3 WRITE a:call_status q:xprt_sending

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
38e886e0c18975543938519254fc9bf0829c75a3 21-May-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Refactor rpc_show_tasks

Clean up: move the logic that displays each task to its own function.
This removes indentation and makes future changes easier.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
68a23ee94e3a06819f5a39d64f2e1f3131bab12d 21-May-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Don't display the rpc_show_tasks header if there are no tasks

Clean up: don't display the rpc_show_tasks column header unless there is at
least one task to display. As far as I can tell, it is safe to let the
list_for_each_entry macro decide that each list is empty.

scripts/checkpatch.pl also wants a KERN_FOO at the start of any newly added
printk() calls, so this and subsequent patches will also add KERN_INFO.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b0e1c57ea00302c3ac541ffd37e7db07d13cd674 21-May-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Rename "call_" functions that are no longer FSM states

The RPC client uses a finite state machine to move RPC tasks through each
step of an RPC request. Each state is contained in a function in
net/sunrpc/clnt.c, and named call_foo.

Some of the functions named call_foo have changed over the past few years and
are no longer states in the FSM. These include: call_encode, call_header,
and call_verify. As a clean up, rename the functions that have changed.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3748f1e447ac1dbf45f33ee7491a008a8bb5cdf0 21-May-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Add a function to display the name of an RPC procedure

Improve debugging messages in call_start() and call_verify() by having
them show the RPC procedure name instead of the procedure number.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b390c2b55c830eb3b64633fa8d8b8837e073e458 11-Jun-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: An ENOMEM error from call_encode is always fatal

The special 'ENOMEM' case that was previously flagged as non-fatal is
bogus: auth_gss always returns EAGAIN for non-fatal errors, and may in fact
return ENOMEM in the special case where xdr_buf_read_netobj runs out of
preallocated buffer space (invariably a _fatal_ error, since there is no
provision for preallocating larger buffers).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8b39f2b41033754e7ba669503d27268beb1b524a 15-May-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure we exit early in case of an encode error

All errors from call_encode(), with exception of EAGAIN are fatal, so we
should immediately return instead of proceeding to xprt_transmit().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b48633bd086d21f4a2a5bea96c7e6c7ba58eb60c 22-Apr-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Invalidate the RPCSEC_GSS session if the server dropped the request

RFC 2203 requires the server to drop the request if it believes the
RPCSEC_GSS context is out of sequence. The problem is that we have no way
on the client to know why the server dropped the request. In order to avoid
spinning forever trying to resend the request, the safe approach is
therefore to always invalidate the RPCSEC_GSS context on every major
timeout.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7c1d71cf56feebfb5b98219b9d11dfc3a2feca62 17-Apr-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't disconnect more than once if retransmitting NFSv4 requests

NFSv4 requires us to ensure that we break the TCP connection before we're
allowed to retransmit a request. However in the case where we're
retransmitting several requests that have been sent on the same
connection, we need to ensure that we don't interfere with the attempt to
reconnect and/or break the connection again once it has been established.

We therefore introduce a 'connection' cookie that is bumped every time a
connection is broken. This allows requests to track if they need to force a
disconnection.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1e799b673c6b82b336ab13c48b5651d511ca3000 21-Mar-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix read ordering problems with req->rq_private_buf.len

We want to ensure that req->rq_private_buf.len is updated before
req->rq_received, so that call_decode() doesn't use an old value for
req->rq_rcv_buf.len.

In 'call_decode()' itself, instead of using task->tk_status (which is set
using req->rq_received) must use the actual value of
req->rq_private_buf.len when deciding whether or not the received RPC reply
is too short.

Finally ensure that we set req->rq_rcv_buf.len to zero when retrying a
request. A typo meant that we were resetting req->rq_private_buf.len in
call_decode(), and then clobbering that value with the old rq_rcv_buf.len
again in xprt_transmit().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
24b74bf0c9e08cbda74d3c64af69ad402ed54e04 19-Apr-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a bug in call_decode()

call_verify() can, under certain circumstances, free the RPC slot. In that
case, our cached pointer 'req = task->tk_rqstp' is invalid. Bug was
introduced in commit 220bcc2afd7011b3e0569fc178331fa983c92c1b (SUNRPC:
Don't call xprt_release in call refresh).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ed13c27e546667fb0967ae30f5070cd7f6455f90 07-Apr-2008 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Fix a memory leak in rpc_create()

Commit 510deb0d was supposed to move the xprt_create_transport() call in
rpc_create(), but neglected to remove the old call site. This resulted in
a transport leak after every rpc_create() call.

This leak is present in 2.6.24 and 2.6.25.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
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>
fda1393938035559b417dd5b26b9cc293a7aee00 22-Feb-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Convert users of rpc_wake_up_task to use rpc_wake_up_queued_task

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
96ef13b283934fbf60b732e6c4ce23e8babd0042 22-Feb-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add a new helper rpc_wake_up_queued_task()

In all cases where we currently use rpc_wake_up_task(), we almost always
know on which waitqueue the rpc_task is actually sleeping. This will allows
us to simplify the queue locking in a future patch.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cbc20059259edee4ea24c923e6627c394830c972 14-Feb-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Declare as const the rpc_message arguments to rpc_call_sync/async

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
65b6e42cdc5b6a1ce2ada31cc294d7e60b22bb43 14-Feb-2008 Randy Dunlap <randy.dunlap@oracle.com> docbook: sunrpc filenames and notation fixes

Use updated file list for docbook files and
fix kernel-doc warnings in sunrpc:
Warning(linux-2.6.24-git12//net/sunrpc/rpc_pipe.c:689): No description found for parameter 'rpc_client'
Warning(linux-2.6.24-git12//net/sunrpc/rpc_pipe.c:765): No description found for parameter 'flags'
Warning(linux-2.6.24-git12//net/sunrpc/clnt.c:584): No description found for parameter 'tk_ops'
Warning(linux-2.6.24-git12//net/sunrpc/clnt.c:618): No description found for parameter 'bufsize'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Neil Brown <neilb@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
34f5b4662bf4b54f22b32ce76ce70eccd7ebc68a 15-Jan-2008 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't bother changing the sigmask for asynchronous RPC calls

The caller will never sleep in rpc_execute, so don't bother setting the
sigmask.

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>
ba7392bb37cb12781890f45d7ddee1618e33a036 20-Dec-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add support for per-client timeout values

In order to be able to support setting the timeo and retrans parameters on
a per-mountpoint basis, we move the rpc_timeout structure into the
rpc_clnt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
698b6d088e8a5d907596c689d5ae9109611c5b59 20-Dec-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: cleanup for rpc_new_client()

There is no reason why we shouldn't just pass the rpc_create_args.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
510deb0d7035d4fd465627deb3a119ca854f9e00 10-Dec-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: rpc_create() default hostname should support AF_INET6 addresses

If the ULP doesn't pass a hostname string to rpc_create(), it manufactures
one based on the passed-in address. Be smart enough to handle an AF_INET6
address properly in this case.

Move the default servername logic before the xprt_create_transport() call
to simplify error handling in rpc_create().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b5627943ab6fabbc13a45d92683363a3d08a249f 26-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove the now unused function rpc_call_setup()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b3ef8b3bb93300e58a4c4806207de3de4eb76f48 26-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Allow rpc_init_task() to initialise the rpc_task->tk_msg

In preparation for the removal of rpc_call_setup().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
77de2c590ec72828156d85fa13a96db87301cc68 26-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add a helper rpc_call_start() that initialises task->tk_action

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5085925902cc4d93b9a4992936edd2aee70a5e15 26-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Mask signals across the call to rpc_call_setup() in rpc_run_task

To ensure that the RPCSEC_GSS upcall is performed with the correct sigmask.

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>
84115e1cd4a3614c4e566d4cce31381dce3dbef9 14-Jul-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Cleanup of rpc_task initialisation

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e8914c65f7f8d4e8701b8e78a12b714872ea0402 14-Jul-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Restrict sunrpc client exports

The sunrpc client exports are not meant to be part of any official kernel
API: they can change at the drop of a hat. Mark them as internal functions
using EXPORT_SYMBOL_GPL.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a6eaf8bdf9308b51ec84e358915fc65400029519 14-Jul-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move exported declarations to the function declarations

Do this for all RPC client related functions and XDR functions.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3ebb067d92ebe5bcfd282acf12bade891d334d07 07-Nov-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Make call_status()/call_decode() call xprt_force_disconnect()

Move the calls to xprt_disconnect() over to xprt_force_disconnect() in
order to enable the transport layer to manage the state of the
XPRT_CONNECTED flag.
Ditto in xs_tcp_read_fraghdr().

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>
220bcc2afd7011b3e0569fc178331fa983c92c1b 01-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't call xprt_release in call refresh

Call it from call_verify() instead...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b6e9c713f5c526a85893c6e0ab1d5d6c6f1ab479 01-Oct-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't call xprt_release() if call_allocate fails

It completely fouls up the RPC call statistics, and serves no useful
purpose.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
afde94f398b62c8596a8d0cbfc25798f0b52a371 26-Sep-2007 J. Bruce Fields <bfields@citi.umich.edu> SUNRPC: Fix default hostname created in rpc_create()

Since 43780b87fa7..., rpc_create() fills in a default hostname based on
the ip address if the servername passed in is null. A small typo made
that default incorrect. (But this information appears to be used only
for debugging right now, so I don't believe the typo causes any bugs in
the current kernel.)

Thanks to Olga Kornievskaia for bug report and testing.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Cc: Olga Kornievskaia <aglo@citi.umich.edu>
Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4fa016eb248cac875541fa199af550a8aefa0e90 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> NFS/SUNRPC: support transport protocol naming

To prepare for including non-sockets-based RPC transports, select
RPC transports by an identifier (to be used in following patches).

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3c341b0b925eee01daae2c594b81e673f659d7cd 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> SUNRPC: rename the rpc_xprtsock_create structure

To prepare for including non-sockets-based RPC transports, change the
overly suggestive name of the transport creation arguments struct.

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4f22ccc3460ef65e9899ec271d36fc4ef795c68d 10-Sep-2007 \"Talpey, Thomas\ <Thomas.Talpey@netapp.com> SUNRPC: mark bulk read/write data in xdrbuf

Adds a flag word to the xdrbuf struct which indicates any bulk
disposition of the data. This enables RPC transport providers to
marshal it efficiently/appropriately, and may enable other
optimizations.

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b79dc8ced1412e7056f3969bef40a30cc75ee530 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: RPC bind failures should be permanent for NULL requests

The purpose of an RPC ping (a NULL request) is to determine whether the
remote end is operating and supports the RPC program and version of the
request.

If we do an RPC bind and the remote's rpcbind service says "this
program or service isn't supported" then we have our answer already,
and we should give up immediately.

This is good for the kernel mount client, as it will cause the request
to fail, and then allow an immediate retry with different options.

Signed-off-by: Chuck Lever <chuck.lever@oracle.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>
d66968f207b6402fd12c20145cb31dbe3608979c 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Clean up in rpc_show_tasks

/home/cel/linux/net/sunrpc/clnt.c: In function ‘rpc_show_tasks’:
/home/cel/linux/net/sunrpc/clnt.c:1538: warning:
signed and unsigned type in conditional expression

This points out another case where a conditional expression returns a
signed value in one arm and an unsigned value in the other.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
06b8d2552d50f802a3277137a565febcd59ef037 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Make sure server name is reasonable before trying to print it

Check the length of the passed-in server name before trying to print it in
the log.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
89eb21c35b61b5157940e1b78c2c6d0529d11c63 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: fix a signed v. unsigned comparison nit in rpc_bind_new_program

/home/cel/linux/net/sunrpc/clnt.c: In function ‘rpc_bind_new_program’:
/home/cel/linux/net/sunrpc/clnt.c:445: warning:
comparison between signed and unsigned

RPC version numbers are u32, not int.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5d34da3af923e0f950a89f160540d2506ca046ce 12-Sep-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Only one dprintk is needed during client creation

Remove one of two identical dprintk's that occur when an RPC client is
created.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d8558f99fbc5ef5d4ae76b893784005056450f82 10-Jul-2007 J. Bruce Fields <bfields@fieldses.org> sunrpc: drop BKL around wrap and unwrap

We don't need the BKL when wrapping and unwrapping; and experiments by Avishay
Traeger have found that permitting multiple encryption and decryption
operations to proceed in parallel can provide significant performance
improvements.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Cc: Avishay Traeger <atraeger@cs.sunysb.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d3bc9a1deb8964d774af8535814cb91bf8f6def0 09-Jul-2007 Frank van Maarseveen <frankvm@frankvm.com> SUNRPC client: add interface for binding to a local address

In addition to binding to a local privileged port the NFS client should
allow binding to a specific local address. This is used by the server
for callbacks. The patch adds the necessary interface.

Signed-off-by: Frank van Maarseveen <frankvm@frankvm.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
96802a095171f5b35cf0e1e0d4be943e6696a253 08-Jul-2007 Frank van Maarseveen <frankvm@frankvm.com> SUNRPC: cleanup transport creation argument passing

Cleanup argument passing to functions for creating an RPC transport.

Signed-off-by: Frank van Maarseveen <frankvm@frankvm.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
43780b87fa799ae65df11d89d4539d8d6a7c67eb 01-Jul-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Add a convenient default for the hostname when calling rpc_create()

A couple of callers just use a stringified IP address for the rpc client's
hostname. Move the logic for constructing this into rpc_create(), so it can
be shared.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
8a702bbb7ddaa2e78c17dbaaf48e3cd5943676f0 28-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Suppress some noisy and unnecessary printk() calls in call_verify()

Convert them into dprintk() calls.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1be27f36601973815171db684c711d30557cf50c 27-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove the tk_auth macro...

We should almost always be deferencing the rpc_auth struct by means of the
credential's cr_auth field instead of the rpc_clnt->cl_auth anyway. Fix up
that historical mistake, and remove the macro that propagated it.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1dd17ec693bf4a08b666c2ef76b68ca08ce3c93d 26-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Allow rpc_auth to run clean up before the rpc_client is destroyed

RPCSEC_GSS needs to be able to send NULL RPC calls to the server in order
to free up any remaining GSS contexts.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
de7a8ce38aea529876db3890b61947bc4bc004da 23-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Rename rpcauth_destroy() to rpcauth_release()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5e1550d6a2c2dd33ff0ca5febefd8e9c65c6ca1e 23-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add the helper function 'rpc_call_null()'

Does a NULL RPC call and returns a pointer to the resulting rpc_task. The
call may be either synchronous or asynchronous.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
64c91a1f1c8bc4295fd6b90df8adf911a7dd64f4 23-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Make rpc_ping() static

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6e5b70e9d1e712d8dad5514e0ab5240ac4b5fb57 12-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: clean up rpc_call_async/rpc_call_sync/rpc_run_task

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
188fef11db219f13f32d055ba59985e7d1a349fe 16-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move rpc_register_client and friends into net/sunrpc/clnt.c

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4ada539ed77c7a2bbcb75cafbbd7bd8d2b9bef7b 14-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Make create_client() take a reference to the rpciod workqueue

Ensures that an rpc_client always has the possibility to send asynchronous
RPC calls.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
d431a555fcf920e1b5c3e3eba52eb5f5e7836771 17-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Don't create an rpc_pipefs directory before rpc_clone is initialised

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>
8ad7c892e18ff8e6df422eb48ca0f73268ffd632 14-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Make rpc_clone take a reference instead of using cl_count

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>
848f1fe6be2e290691bb6c13cbb8fd92bd0cfaab 10-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Kill rpc_clnt->cl_dead

Its use is at best racy, and there is only one user (lockd), which has
additional locking that makes the whole thing redundant.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
34f52e3591f241b825353ba27def956d8487c400 14-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Convert rpc_clnt->cl_users to a kref

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4bef61ff7514396419563ca54fd42ef846485b06 16-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add a per-rpc_clnt spinlock

Use that to protect the rpc_clnt->cl_tasks list instead of using a global
lock.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6529eba08fe7297852391a468d95322913de73fa 14-Jun-2007 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Move rpc_task->tk_task list into struct rpc_clnt

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
00a6e7bbf990e3a5e59a9a1e6a68e99c94fe001c 29-Mar-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: RPC client should retry with different versions of rpcbind

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c5a4dd8b7c15927a8fbff83171b57cad675a79b9 29-Mar-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Eliminate side effects from rpc_malloc

Currently rpc_malloc sets req->rq_buffer internally. Make this a more
generic interface: return a pointer to the new buffer (or NULL) and
make the caller set req->rq_buffer and req->rq_bufsize. This looks much
more like kmalloc and eliminates the side effects.

To fix a potential deadlock, this patch also replaces GFP_NOFS with
GFP_NOWAIT in rpc_malloc. This prevents async RPCs from sleeping outside
the RPC's task scheduler while allocating their buffer.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2bea90d43a050bbc4021d44e59beb34f384438db 29-Mar-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: RPC buffer size estimates are too large

The RPC buffer size estimation logic in net/sunrpc/clnt.c always
significantly overestimates the requirements for the buffer size.
A little instrumentation demonstrated that in fact rpc_malloc was never
allocating the buffer from the mempool, but almost always called kmalloc.

To compute the size of the RPC buffer more precisely, split p_bufsiz into
two fields; one for the argument size, and one for the result size.

Then, compute the sum of the exact call and reply header sizes, and split
the RPC buffer precisely between the two. That should keep almost all RPC
buffers within the 2KiB buffer mempool limit.

And, we can finally be rid of RPC_SLACK_SPACE!

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
241c39b9ac4bf847013aa06cce6d4d61426a2006 20-Apr-2007 Trond Myklebust <Trond.Myklebust@netapp.com> RPC: Fix the TCP resend semantics for NFSv4

Fix a regression due to the patch "NFS: disconnect before retrying NFSv4
requests over TCP"

The assumption made in xprt_transmit() that the condition
"req->rq_bytes_sent == 0 and request is on the receive list"
should imply that we're dealing with a retransmission is false.
Firstly, it may simply happen that the socket send queue was full
at the time the request was initially sent through xprt_transmit().
Secondly, doing this for each request that was retransmitted implies
that we disconnect and reconnect for _every_ request that happened to
be retransmitted irrespective of whether or not a disconnection has
already occurred.

Fix is to move this logic into the call_status request timeout handler.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
43d78ef2ba5bec26d0315859e8324bfc0be23766 07-Feb-2007 Chuck Lever <chuck.lever@oracle.com> NFS: disconnect before retrying NFSv4 requests over TCP

RFC3530 section 3.1.1 states an NFSv4 client MUST NOT send a request
twice on the same connection unless it is the NULL procedure. Section
3.1.1 suggests that the client should disconnect and reconnect if it
wants to retry a request.

Implement this by adding an rpc_clnt flag that an ULP can use to
specify that the underlying transport should be disconnected on a
major timeout. The NFSv4 client asserts this new flag, and requests
no retries after a minor retransmit timeout.

Note that disconnecting on a retransmit is in general not safe to do
if the RPC client does not reuse the TCP port number when reconnecting.

See http://bugzilla.linux-nfs.org/show_bug.cgi?id=6

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cca5172a7ec10dfdb0b787cd8e9d5b0b8f179793 10-Feb-2007 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> [NET] SUNRPC: Fix whitespace errors.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
46121cf7d85869bfe9588bac7ccf55aa0bc7f278 31-Jan-2007 Chuck Lever <chuck.lever@oracle.com> SUNRPC: fix print format for tk_pid

The tk_pid field is an unsigned short. The proper print format specifier for
that type is %5u, not %4d.

Also clean up some miscellaneous print formatting nits.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2efef837fb84f78cee7439804cb3722bffc64e75 03-Feb-2007 Trond Myklebust <Trond.Myklebust@netapp.com> RPC: Clean up rpc_execute...

The error values are already propagated through task->tk_status, and
none of the callers check one without checking the other, so we can
drop the return value.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
bde8f00ce64d9824a4f227c8594e335a1a10d044 24-Jan-2007 Trond Myklebust <Trond.Myklebust@netapp.com> [PATCH] NFS: Fix Oops in rpc_call_sync()

Fix the Oops in http://bugzilla.linux-nfs.org/show_bug.cgi?id=138
We shouldn't be calling rpc_release_task() for tasks that are not active.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7559c7a28fbcaa0bca028eeebd5f251b09befe6b 05-Dec-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Make address format buffers more generic

For now we will assume that all transports will use the address format
buffers in the rpc_xprt struct to store their addresses. Change
rpc_peer2str() to be a generic routine to handle this, and get rid of the
print_address() op in the rpc_xprt_ops vector.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6d5fcb5a52bfd00eab3ba2c7ca890823388436ae 18-Oct-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Remove BKL around the RPC socket operations etc.

All internal RPC client operations should no longer depend on the BKL,
however lockd and NFS callbacks may still require it.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
bbd5a1f9fc9fad0f8725812d91c51b052e847de8 18-Oct-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix up missing BKL in asynchronous RPC callback functions

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
3e32a5d99a467b9d4d416323c8c292479b4915e5 16-Nov-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Give cloned RPC clients their own rpc_pipefs directory

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
23bf85ba43650e4341672a6bc85aa3f2c02eb633 21-Nov-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Handle the cases where rpc_alloc_iostats() fails

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e6b3c4db6fbcd0d33720696f37790d6b8be12313 12-Nov-2006 Trond Myklebust <Trond.Myklebust@netapp.com> Fix a second potential rpc_wakeup race...

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e69062b4f728dca01ec1a9eb4ed55b73a374f164 21-Nov-2006 Arnaldo Carvalho de Melo <acme@mandriva.com> [SUNRPC]: Use k{mem,str}dup where applicable

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
e9ff3990f08e9a0c2839cc22808b01732ea5b3e4 02-Oct-2006 Serge E. Hallyn <serue@us.ibm.com> [PATCH] namespaces: utsname: switch to using uts namespaces

Replace references to system_utsname to the per-process uts namespace
where appropriate. This includes things like uname.

Changes: Per Eric Biederman's comments, use the per-process uts namespace
for ELF_PLATFORM, sunrpc, and parts of net/ipv4/ipconfig.c

[jdike@addtoit.com: UML fix]
[clg@fr.ibm.com: cleanup]
[akpm@osdl.org: build fix]
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Kirill Korotaev <dev@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Andrey Savochkin <saw@sw.ru>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
d8ed029d6000ba2e2908d9286409e4833c091b4c 27-Sep-2006 Alexey Dobriyan <adobriyan@gmail.com> [SUNRPC]: trivial endianness annotations

pure s/u32/__be32/

[AV: large part based on Alexey's patches]

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
6b6ca86b77b62b798cf9ca2599036420abce7796 05-Sep-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Add refcounting to the struct rpc_xprt

In a subsequent patch, this will allow the portmapper to take a reference
to the rpc_xprt for which it is updating the port number, fixing an Oops.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
da45828e2835057045150b318c4fbe9bb91f18dd 31-Aug-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Clean up soft task error handling

- Ensure that the task aborts the RPC call only when it has actually timed out.
- Ensure that req->rq_majortimeo is initialised correctly.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
76303992b4701124f4cd0791ae2049ab4332f02c 30-Aug-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Handle ENETUNREACH, EHOSTUNREACH and EHOSTDOWN socket errors

In case of any of the above errors occuring, delay for 3 seconds, then
handle as if it were a timeout error.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
b86acd501a34227e0ed2b2d54dc8002c1701ce17 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: export new RPC client functions with _GPL

This patch is optional.

It has been suggested that the RPC client internal functions used by upper
layer protocols (such as NFS) be exported via EXPORT_SYMBOL_GPL. This
patch does that.

Test plan:
Compile kernel with CONFIG_NFS enabled as a module.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ff9aa5e56df60cc8565a93cc868fe25ae3f20e49 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Eliminate xprt_create_proto and rpc_create_client

The two function call API for creating a new RPC client is now obsolete.
Remove it.

Also, remove an unnecessary check to see whether the caller is capable of
using privileged network services. The kernel RPC client always uses a
privileged ephemeral port by default; callers are responsible for checking
the authority of users to make use of any RPC service, or for specifying
that a nonprivileged port is acceptable.

Test plan:
Repeated runs of Connectathon locking suite. Check network trace to ensure
correctness of NLM requests and replies.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c2866763b4029411d166040306691773c12d4caf 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: use sockaddr + size when creating remote transport endpoints

Prepare for more generic transport endpoint handling needed by transports
that might use different forms of addressing, such as IPv6.

Introduce a single function call to replace the two-call
xprt_create_proto/rpc_create_client API. Define a new rpc_create_args
structure that allows callers to pass in remote endpoint addresses of
varying length.

Test-plan:
Compile kernel with CONFIG_NFS enabled.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
c4efcb1d3e0bc76aeb9ca6301d19a5079893c6c9 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Use "sockaddr_storage" for storing RPC client's remote peer address

IPv6 addresses are big (128 bytes). Now that no RPC client consumers treat
the addr field in rpc_xprt structs as an opaque, and access it only via the
API calls, we can safely widen the field in the rpc_xprt struct to
accomodate larger addresses.

Test plan:
Compile kernel with CONFIG_NFS enabled.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f425eba437f0051bde979ea2eef8bc875a77cd00 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Create API for displaying remote peer address

Provide an API for formatting the remote peer address for printing without
exposing its internal structure. The address could be dynamic, so we
support a function call to get the address rather than reading it straight
out of a structure.

Test-plan:
Destructive testing (unplugging the network temporarily). Probably need
to rig a server where certain services aren't running, or that returns an
error for some typical operation.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ed39440a2573abc926f230267000f21fa5a87822 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: create API for getting remote peer address

Provide an API for retrieving the remote peer address without allowing
direct access to the rpc_xprt struct.

Test-plan:
Compile kernel with CONFIG_NFS enabled.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
bbf7c1dd2ae2b4040b41b1065ee9b1b6905b1605 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Introduce transport switch callout for pluggable rpcbind

Introduce a clean transport switch API for plugging in different types of
rpcbind mechanisms. For instance, rpcbind can cleanly replace the
existing portmapper client, or a transport can choose to implement RPC
binding any way it likes.

Test plan:
Destructive testing (unplugging the network temporarily). Connectathon
with UDP and TCP. NFSv2/3 and NFSv4 mounting should be carefully checked.
Probably need to rig a server where certain services aren't running, or
that returns an error for some typical operation.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
4a68179d38874c37be2802442a71b847f5d1a2a9 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Make RPC portmapper use per-transport storage

Move connection and bind state that was maintained in the rpc_clnt
structure to the rpc_xprt structure. This will allow the creation of
a clean API for plugging in different types of bind mechanisms.

This brings improvements such as the elimination of a single spin lock to
control serialization for all in-kernel RPC binding. A set of per-xprt
bitops is used to serialize tasks during RPC binding, just like it now
works for making RPC transport connections.

Test-plan:
Destructive testing (unplugging the network temporarily). Connectathon
with UDP and TCP. NFSv2/3 and NFSv4 mounting should be carefully checked.
Probably need to rig a server where certain services aren't running, or
that returns an error for some typical operation.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ec739ef03dc926d05051c8c5838971445504470a 23-Aug-2006 Chuck Lever <chuck.lever@oracle.com> SUNRPC: Create a helper to tell whether a transport is bound

Hide the contents and format of xprt->addr by eliminating direct uses
of the xprt->addr.sin_port field. This change is required to support
alternate RPC host address formats (eg IPv6).

Test-plan:
Destructive testing (unplugging the network temporarily). Repeated runs of
Connectathon locking suite with UDP and TCP.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e8896495bca8490a427409e0886d63d05419ec65 24-Aug-2006 David Howells <dhowells@redhat.com> NFS: Check lengths more thoroughly in NFS4 readdir XDR decode

Check the bounds of length specifiers more thoroughly in the XDR decoding of
NFS4 readdir reply data.

Currently, if the server returns a bitmap or attr length that causes the
current decode point pointer to wrap, this could go undetected (consider a
small "negative" length on a 32-bit machine).

Also add a check into the main XDR decode handler to make sure that the amount
of data is a multiple of four bytes (as specified by RFC-1014). This makes
sure that we can do u32* pointer subtraction in the NFS client without risking
an undefined result (the result is undefined if the pointers are not correctly
aligned with respect to one another).

Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from 5861fddd64a7eaf7e8b1a9997455a24e7f688092 commit)
8f8e7a50f450fcb86a5b2ffb94543c57a14f8260 14-Aug-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix dentry refcounting issues with users of rpc_pipefs

rpc_unlink() and rpc_rmdir() will dput the dentry reference for you.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from a05a57effa71a1f67ccbfc52335c10c8b85f3f6a commit)
dff02cc1a34fcb60904a2c57cb351857cc11219e 31-Jul-2006 Trond Myklebust <Trond.Myklebust@netapp.com> NFS: clean up rpc_rmdir

Make it take a dentry argument instead of a path

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from 648d4116eb2509f010f7f34704a650150309b3e7 commit)
e0ab53deaa91293a7958d63d5a2cf4c5645ad6f0 27-Jul-2006 Trond Myklebust <Trond.Myklebust@netapp.com> RPC: Ensure that we disconnect TCP socket when client requests error out

If we're part way through transmitting a TCP request, and the client
errors, then we need to disconnect and reconnect the TCP socket in order to
avoid confusing the server.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from 031a50c8b9ea82616abd4a4e18021a25848941ce commit)
0da974f4f303a6842516b764507e3c0a03f41e5a 21-Jul-2006 Panagiotis Issaris <takis@issaris.org> [NET]: Conversions from kmalloc+memset to k(z|c)alloc.

Signed-off-by: Panagiotis Issaris <takis@issaris.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7a1218a277c45cba1fb8d7089407a1769c645c43 21-Mar-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure rpc_call_async() always calls tk_ops->rpc_release()

Currently this will not happen if we exit before rpc_new_task() was called.
Also fix up rpc_run_task() to do the same (for consistency).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
43ac3f2961b8616da26114ec6dc76ac2a61f76ad 20-Mar-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix memory barriers for req->rq_received

We need to ensure that all writes to the XDR buffers are done before
req->rq_received is visible to other processors.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5428154827c2bf7cfdc9dab60db1e0eaa57c027a 20-Mar-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Fix a 'Busy inodes' error in rpc_pipefs

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
11c556b3d8d481829ab5f9933a25d29b00913b5a 20-Mar-2006 Chuck Lever <cel@netapp.com> SUNRPC: provide a mechanism for collecting stats in the RPC client

Add a simple mechanism for collecting stats in the RPC client. Stats are
tabulated during xprt_release. Note that per_cpu shenanigans are not
required here because the RPC client already serializes on the transport
write lock.

Test plan:
Compile kernel with CONFIG_NFS enabled. Basic performance regression
testing with high-speed networking and high performance server.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ef759a2e54ed434b2f72b52a14edecd6d4eadf74 20-Mar-2006 Chuck Lever <cel@netapp.com> SUNRPC: introduce per-task RPC iostats

Account for various things that occur while an RPC task is executed.
Separate timers for RPC round trip and RPC execution time show how
long RPC requests wait in queue before being sent. Eventually these
will be accumulated at xprt_release time in one place where they can
be viewed from userland.

Test plan:
Compile kernel with CONFIG_NFS enabled.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1356b8c28d67cafd74f7e7dcfb39bf53681790a5 20-Mar-2006 Levent Serinol <lserinol@gmail.com> SUNRPC: more verbose output for rpc auth weak error

This patch adds server ip address to be printed out when "server
requires stronger authentication" error occured.

Signed-off-by: Levent Serinol <lserinol@gmail.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12de3b35ea549c5819f287508d7afab0bf3ac44d 20-Mar-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure that rpc_mkpipe returns a refcounted dentry

If not, we cannot guarantee that idmap->idmap_dentry, gss_auth->dentry and
clnt->cl_dentry are valid dentries.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
712917d1c002f820b177683f4fd491289bde3c32 14-Mar-2006 Adrian Bunk <bunk@stusta.de> [PATCH] SUNRPC: fix a NULL pointer dereference in net/sunrpc/clnt.c

The Coverity checker spotted this possible NULL pointer dereference in
rpc_new_client().

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
8b3a70058bfe711b2d05ba2134178bae623183ce 12-Jan-2006 Kris Katterjohn <kjak@users.sourceforge.net> [NET]: Remove more unneeded typecasts on *malloc()

This removes more unneeded casts on the return value for kmalloc(),
sock_kmalloc(), and vmalloc().

Signed-off-by: Kris Katterjohn <kjak@users.sourceforge.net>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
4f47707b056bd2e3627ef390557ee93d312daba5 10-Jan-2006 Linus Torvalds <torvalds@g5.osdl.org> Fix rpc shutdown event condition bug

We want to wait for the cl_users to go down to zero, not for it to stay
positive. Quoth Trond (who wasn't even the author, but acked the wrong
version): "Argh! I need to increase my daily caffeine dosages."

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
532347e2bbae9e849816dc7b12a3d0f2c42d4944 10-Jan-2006 Ingo Molnar <mingo@elte.hu> [PATCH] nfs: sleep_on() removal

Convert sleep_on() to wait_event_timeout(). Probably safe with the BKL but
could be racy once BKL use in NFS-client is gone.

Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
f518e35aec984036903c1003e867f833747a9d79 03-Jan-2006 Chuck Lever <cel@netapp.com> SUNRPC: get rid of cl_chatty

Clean up: Every ULP that uses the in-kernel RPC client, except the NLM
client, sets cl_chatty. There's no reason why NLM shouldn't set it, so
just get rid of cl_chatty and always be verbose.

Test-plan:
Compile with CONFIG_NFS enabled.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
35f5a422ce1af836007f811b613c440d0e348e06 03-Jan-2006 Chuck Lever <cel@netapp.com> SUNRPC: new interface to force an RPC rebind

We'd like to hide fields in rpc_xprt and rpc_clnt from upper layer protocols.
Start by creating an API to force RPC rebind, replacing logic that simply
sets cl_port to zero.

Test-plan:
Destructive testing (unplugging the network temporarily). Connectathon
with UDP and TCP. NFSv2/3 and NFSv4 mounting should be carefully checked.
Probably need to rig a server where certain services aren't running, or
that returns an error for some typical operation.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
02107148349f31eee7c0fb06fd7a880df73dbd20 03-Jan-2006 Chuck Lever <cel@netapp.com> SUNRPC: switchable buffer allocation

Add RPC client transport switch support for replacing buffer management
on a per-transport basis.

In the current IPv4 socket transport implementation, RPC buffers are
allocated as needed for each RPC message that is sent. Some transport
implementations may choose to use pre-allocated buffers for encoding,
sending, receiving, and unmarshalling RPC messages, however. For
transports capable of direct data placement, the buffers can be carved
out of a pre-registered area of memory rather than from a slab cache.

Test-plan:
Millions of fsx operations. Performance characterization with "sio" and
"iozone". Use oprofile and other tools to look for significant regression
in CPU utilization.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2bd615797ef32ec06ef0ee44198a7aecc21ffd8c 03-Jan-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Ensure that SIGKILL will always terminate a synchronous RPC call.

...and make sure that the "intr" flag also enables SIGHUP and SIGTERM to
interrupt RPC calls too (as per the Solaris implementation).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
e60859ac0e50f660d23b72e42e05f58757dcfeff 03-Jan-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: rpc_execute should not return task->tk_status;

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
963d8fe53339128ee46a7701f2e36305f0ccff8c 03-Jan-2006 Trond Myklebust <Trond.Myklebust@netapp.com> RPC: Clean up RPC task structure

Shrink the RPC task structure. Instead of storing separate pointers
for task->tk_exit and task->tk_release, put them in a structure.

Also pass the user data pointer as a parameter instead of passing it via
task->tk_calldata. This enables us to nest callbacks.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
abbcf28f23d53e8ec56a91f3528743913fa2694a 03-Jan-2006 Trond Myklebust <Trond.Myklebust@netapp.com> SUNRPC: Yet more RPC cleanups

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
940e3318c36394939d805e797d7be39ddaaa7911 10-Nov-2005 Trond Myklebust <trond.myklebust@fys.uio.no> [PATCH] SUNRPC: don't reencode when looping in call transmit.

If the call to xprt_transmit() fails due to socket buffer space
exhaustion, we do not need to re-encode the RPC message when we
loop back through call_transmit.

Re-encoding can actually end up triggering the WARN_ON() in
call_decode() if we re-encode something like a read() request and
auth->au_rslack has changed.
It can also cause us to increment the RPCSEC_GSS sequence number
beyond the limits of the allowed window.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
f3680312a737355ddf35c1b68af25e384d7ef0a8 13-Oct-2005 J. Bruce Fields <bfields@fieldses.org> SUNRPC: Retry wrap in case of memory allocation failure.

For privacy we need to allocate extra pages to hold encrypted page data when
wrapping requests. This allocation may fail, and we handle that case by
waiting and retrying.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5e5ce5be6f0161d2a069a4f8a1154fe639c5c02f 18-Oct-2005 Trond Myklebust <Trond.Myklebust@netapp.com> RPC: allow call_encode() to delay transmission of an RPC call.

Currently, call_encode will cause the entire RPC call to abort if it returns
an error. This is unnecessarily rigid, and gets in the way of attempts
to allow the NFSv4 layer to order RPC calls that carry sequence ids.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
ea635a517e350eb03ab5f01618417f31b82a9a4d 07-Oct-2005 Chuck Lever <cel@netapp.com> SUNRPC: Retry rpcbind requests if the server's portmapper isn't up

After a server crash/reboot, rebinding should always retry, otherwise
requests on "hard" mounts will fail when they shouldn't.

Test plan:
Run a lock-intensive workload against a server while rebooting the server
repeatedly.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
f134585a7343d71f9be7f0cf97e2145f21dd10c6 23-Sep-2005 Trond Myklebust <Trond.Myklebust@netapp.com> Revert "[PATCH] RPC,NFS: new rpc_pipefs patch"

This reverts 17f4e6febca160a9f9dd4bdece9784577a2f4524 commit.
278c995c8a153bb2a9bc427e931cfb9c8034c9d7 25-Jul-2005 Christoph Hellwig <hch@infradead.org> [PATCH] RPC,NFS: new rpc_pipefs patch

Currently rpc_mkdir/rpc_rmdir and rpc_mkpipe/mk_unlink have an API that's
a little unfortunate. They take a path relative to the rpc_pipefs root and
thus need to perform a full lookup. If you look at debugfs or usbfs they
always store the dentry for directories they created and thus can pass in
a dentry + single pathname component pair into their equivalents of the
above functions.

And in fact rpc_pipefs actually stores a dentry for all but one component so
this change not only simplifies the core rpc_pipe code but also the callers.

Unfortuntately this code path is only used by the NFS4 idmapper and
AUTH_GSSAPI for which I don't have a test enviroment. Could someone give
it a spin? It's the last bit needed before we can rework the
lookup_hash API

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
470056c288334eb0b37be26c9ff8aee37ed1cc7a 26-Aug-2005 Chuck Lever <cel@netapp.com> [PATCH] RPC: rationalize set_buffer_size

In fact, ->set_buffer_size should be completely functionless for non-UDP.

Test-plan:
Check socket buffer size on UDP sockets over time.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
03bf4b707eee06706c9db343dd5c905b7ee47ed2 26-Aug-2005 Chuck Lever <cel@netapp.com> [PATCH] RPC: parametrize various transport connect timeouts

Each transport implementation can now set unique bind, connect,
reestablishment, and idle timeout values. These are variables,
allowing the values to be modified dynamically. This permits
exponential backoff of any of these values, for instance.

As an example, we implement exponential backoff for the connection
reestablishment timeout.

Test-plan:
Destructive testing (unplugging the network temporarily). Connectathon
with UDP and TCP.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
808012fbb23a52ec59352445d2076d175ad4ab26 26-Aug-2005 Chuck Lever <cel@netapp.com> [PATCH] RPC: skip over transport-specific heads automatically

Add a generic mechanism for skipping over transport-specific headers
when constructing an RPC request. This removes another "xprt->stream"
dependency.

Test-plan:
Write-intensive workload on a single mount point (try both UDP and
TCP).

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
55aa4f58aa43dc9a51fb80010630d94b96053a2e 11-Aug-2005 Chuck Lever <cel@citi.umich.edu> [PATCH] RPC: client-side transport switch cleanup

Clean-up: change some comments to reflect the realities of the new RPC
transport switch mechanism. Get rid of unused xprt_receive() prototype.

Also, organize function prototypes in xprt.h by usage and scope.

Test-plan:
Compile kernel with CONFIG_NFS enabled.

Version: Thu, 11 Aug 2005 16:07:21 -0400

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
86b9f57dfdf455763d2be73a742a9a88bb664173 11-Aug-2005 Chuck Lever <cel@citi.umich.edu> [PATCH] RPC: Eliminate socket.h includes in RPC client

Clean-up: get rid of unnecessary socket.h and in.h includes in the generic
parts of the RPC client.

Test-plan:
Compile kernel with CONFIG_NFS enabled.

Version: Thu, 11 Aug 2005 16:06:23 -0400

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
a246b0105bbd9a70a698f69baae2042996f2a0e9 11-Aug-2005 Chuck Lever <cel@citi.umich.edu> [PATCH] RPC: introduce client-side transport switch

Move the bulk of client-side socket-specific code into a separate source
file, net/sunrpc/xprtsock.c.

Test-plan:
Millions of fsx operations. Performance characterization such as "sio" or
"iozone". Destructive testing (unplugging the network temporarily, server
reboots). Connectathon with v2, v3, and v4.

Version: Thu, 11 Aug 2005 16:03:38 -0400

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
da35187801732397a7e05fb9e77f3700cc35f5db 11-Aug-2005 Chuck Lever <cel@citi.umich.edu> [PATCH] RPC: proper soft timeout behavior for rpcbind

Implement a best practice: for soft mounts, an rpcbind timeout should
cause an RPC request to fail.

This also provides an FSM hook for retrying an rpcbind with a different
rpcbind protocol version. We'll use this later to try multiple rpcbind
protocol versions when binding. To enable this, expose the RPC error
code returned during a portmap request to the FSM so it can make some
decision about how to report, retry, or fail the request.

Test-plan:
Hundreds of passes with connectathon NFSv3 locking suite, on the client
and server.

Version: Thu, 11 Aug 2005 16:01:53 -0400

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
14b218a8e4f110206c46e586a3da372f665631e7 22-Jun-2005 Trond Myklebust <Trond.Myklebust@netapp.com> [PATCH] RPC: Ensure rpc calls respects the RPC_NOINTR flag

For internal purposes, the rpc_clnt_sigmask() call is replaced by
a call to rpc_task_sigmask(), which ensures that the current task
sigmask respects both the client cl_intr flag and the per-task NOINTR flag.

Problem noted by Jiaying Zhang.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
007e251f2b2760f738c92adc8c80cbae0bed3ce5 22-Jun-2005 Andreas Gruenbacher <agruen@suse.de> [PATCH] RPC: Allow multiple RPC client programs to share the same transport

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Acked-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
cdf477068e6db0c3e19df96f46abb85202de138c 22-Jun-2005 Andreas Gruenbacher <agruen@suse.de> [PATCH] RPC: Return -EPFNOSUPPORT for RPC programs that are unavailable

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6a19275ada9137435da58990c8f8d3f58e170bf1 22-Jun-2005 J. Bruce Fields <bfields@citi.umich.edu> [PATCH] RPC: [PATCH] improve rpcauthauth_create error returns

Currently we return -ENOMEM for every single failure to create a new auth.
This is actually accurate for auth_null and auth_unix, but for auth_gss it's a
bit confusing.

Allow rpcauth_create (and the ->create methods) to return errors. With this
patch, the user may sometimes see an EINVAL instead. Whee.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5ee0ed7d3ab620a764740fb018f469d45f561931 22-Jun-2005 Trond Myklebust <Trond.Myklebust@netapp.com> [PATCH] RPC: Make rpc_create_client() probe server for RPC program+version support

Ensure that we don't create an RPC client without checking that the server
does indeed support the RPC program + version that we are trying to set up.

This enables us to immediately return an error to "mount" if it turns out
that the server is only supporting NFSv2, when we requested NFSv3 or NFSv4.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
5b616f5d596c0b056129f8aeafbc08409b3cd050 22-Jun-2005 Trond Myklebust <Trond.Myklebust@netapp.com> [PATCH] RPC: Make rpc_create_client() destroy the transport on failure.

This saves us a couple of lines of cleanup code for each call.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
334ccfd545bba9690515f2c5c167d5adb161989b 22-Jun-2005 Trond Myklebust <Trond.Myklebust@netapp.com> [PATCH] RPC: Ensure XDR iovec length is initialized correctly in call_header

Fix up call_header() so that it calls xdr_adjust_iovec().
Fix calculation of the scratch buffer length in xdr_init_encode().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!