alistair23-linux/include/linux/sunrpc
Trond Myklebust bf294b41ce SUNRPC: Close a race in __rpc_wait_for_completion_task()
Although they run as rpciod background tasks, under normal operation
(i.e. no SIGKILL), functions like nfs_sillyrename(), nfs4_proc_unlck()
and nfs4_do_close() want to be fully synchronous. This means that when we
exit, we want all references to the rpc_task to be gone, and we want
any dentry references etc. held by that task to be released.

For this reason these functions call __rpc_wait_for_completion_task(),
followed by rpc_put_task() in the expectation that the latter will be
releasing the last reference to the rpc_task, and thus ensuring that the
callback_ops->rpc_release() has been called synchronously.

This patch fixes a race which exists due to the fact that
rpciod calls rpc_complete_task() (in order to wake up the callers of
__rpc_wait_for_completion_task()) and then subsequently calls
rpc_put_task() without ensuring that these two steps are done atomically.

In order to avoid adding new spin locks, the patch uses the existing
waitqueue spin lock to order the rpc_task reference count releases between
the waiting process and rpciod.
The common case where nobody is waiting for completion is optimised for by
checking if the RPC_TASK_ASYNC flag is cleared and/or if the rpc_task
reference count is 1: in those cases we drop trying to grab the spin lock,
and immediately free up the rpc_task.

Those few processes that need to put the rpc_task from inside an
asynchronous context and that do not care about ordering are given a new
helper: rpc_put_task_async().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
2011-03-10 15:04:52 -05:00
..
auth.h SUNRPC: New xdr_streams XDR decoder API 2010-12-16 12:37:25 -05:00
auth_gss.h nfs: __rcu annotations 2010-08-19 17:18:00 -07:00
bc_xprt.h NFS do not find client in NFSv4 pg_authenticate 2011-01-25 15:26:51 -05:00
cache.h Merge branch 'for-2.6.38' of git://linux-nfs.org/~bfields/linux 2011-01-14 13:17:26 -08:00
clnt.h SUNRPC: New xdr_streams XDR decoder API 2010-12-16 12:37:25 -05:00
debug.h
gss_api.h NFS: Don't use GFP_KERNEL in rpcsec_gss downcalls 2010-05-14 15:09:33 -04:00
gss_asn1.h
gss_err.h
gss_krb5.h NFS: Don't use GFP_KERNEL in rpcsec_gss downcalls 2010-05-14 15:09:33 -04:00
Kbuild include: replace unifdef-y with header-y 2010-08-14 22:26:51 +02:00
metrics.h SUNRPC: Replace jiffies-based metrics with ktime-based metrics 2010-05-14 15:09:33 -04:00
msg_prot.h
rpc_pipe_fs.h
rpc_rdma.h
sched.h SUNRPC: Close a race in __rpc_wait_for_completion_task() 2011-03-10 15:04:52 -05:00
stats.h sunrpc: Make the /proc/net/rpc appear in net namespaces 2010-09-27 10:16:12 -04:00
svc.h Merge branch 'for-2.6.38' of git://linux-nfs.org/~bfields/linux 2011-01-14 13:17:26 -08:00
svc_rdma.h
svc_xprt.h NFS do not find client in NFSv4 pg_authenticate 2011-01-25 15:26:51 -05:00
svcauth.h sunrpc: Add net to pure API calls 2010-09-27 10:16:11 -04:00
svcauth_gss.h
svcsock.h rpc: move sk_bc_xprt to svc_xprt 2011-01-11 15:04:10 -05:00
timer.h
types.h
xdr.h Merge branch 'bugfixes' into nfs-for-2.6.38 2011-01-10 14:48:02 -05:00
xprt.h rpc: allow xprt_class->setup to return a preexisting xprt 2011-01-11 15:04:10 -05:00
xprtrdma.h
xprtsock.h