kernel-ark/net/sunrpc
NeilBrown c1221321b7 sched: Allow wait_on_bit_action() functions to support a timeout
It is currently not possible for various wait_on_bit functions
to implement a timeout.

While the "action" function that is called to do the waiting
could certainly use schedule_timeout(), there is no way to carry
forward the remaining timeout after a false wake-up.
As false-wakeups a clearly possible at least due to possible
hash collisions in bit_waitqueue(), this is a real problem.

The 'action' function is currently passed a pointer to the word
containing the bit being waited on.  No current action functions
use this pointer.  So changing it to something else will be a
little noisy but will have no immediate effect.

This patch changes the 'action' function to take a pointer to
the "struct wait_bit_key", which contains a pointer to the word
containing the bit so nothing is really lost.

It also adds a 'private' field to "struct wait_bit_key", which
is initialized to zero.

An action function can now implement a timeout with something
like

static int timed_out_waiter(struct wait_bit_key *key)
{
	unsigned long waited;
	if (key->private == 0) {
		key->private = jiffies;
		if (key->private == 0)
			key->private -= 1;
	}
	waited = jiffies - key->private;
	if (waited > 10 * HZ)
		return -EAGAIN;
	schedule_timeout(waited - 10 * HZ);
	return 0;
}

If any other need for context in a waiter were found it would be
easy to use ->private for some other purpose, or even extend
"struct wait_bit_key".

My particular need is to support timeouts in nfs_release_page()
to avoid deadlocks with loopback mounted NFS.

While wait_on_bit_timeout() would be a cleaner interface, it
will not meet my need.  I need the timeout to be sensitive to
the state of the connection with the server, which could change.
 So I need to use an 'action' interface.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steve French <sfrench@samba.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140707051604.28027.41257.stgit@notabene.brown
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-07-16 15:10:41 +02:00
..
auth_gss NFS client updates for Linux 3.16 2014-06-10 15:02:42 -07:00
xprtrdma NFS client updates for Linux 3.16 2014-06-10 15:02:42 -07:00
addr.c
auth_generic.c sunrpc: Add missing kuids conversion for printing 2013-09-12 10:16:06 -04:00
auth_null.c SUNRPC refactor rpcauth_checkverf error returns 2013-09-03 15:25:09 -04:00
auth_unix.c SUNRPC refactor rpcauth_checkverf error returns 2013-09-03 15:25:09 -04:00
auth.c NFSv4: test SECINFO RPC_AUTH_GSS pseudoflavors for support 2014-06-24 18:46:58 -04:00
backchannel_rqst.c arch: Mass conversion of smp_mb__*() 2014-04-18 14:20:48 +02:00
bc_svc.c
cache.c SUNRPC: Fix printk that is not only for nfsd 2014-05-08 14:59:51 -04:00
clnt.c Merge branch 'for-3.15' of git://linux-nfs.org/~bfields/linux 2014-04-08 18:28:14 -07:00
Kconfig xprtrdma: add separate Kconfig options for NFSoRDMA client and server support 2014-03-28 18:02:12 -04:00
Makefile xprtrdma: add separate Kconfig options for NFSoRDMA client and server support 2014-03-28 18:02:12 -04:00
netns.h Merge branch 'for-3.14' of git://linux-nfs.org/~bfields/linux 2014-01-30 10:18:43 -08:00
rpc_pipe.c rpc_pipe: fix cleanup of dummy gssd directory when notification fails 2013-12-10 19:39:53 +02:00
rpcb_clnt.c
sched.c sched: Allow wait_on_bit_action() functions to support a timeout 2014-07-16 15:10:41 +02:00
socklib.c net: Save software checksum complete 2014-06-11 15:46:13 -07:00
stats.c
sunrpc_syms.c sunrpc: create a new dummy pipe for gssd to hold open 2013-12-06 13:06:30 -05:00
sunrpc.h SUNRPC: track whether a request is coming from a loop-back interface. 2014-05-22 15:59:18 -04:00
svc_xprt.c nfsd4: allow encoding across page boundaries 2014-05-30 17:31:54 -04:00
svc.c SUNRPC/NFSD: Support a new option for ignoring the result of svc_register 2014-01-03 18:18:49 -05:00
svcauth_unix.c
svcauth.c nfsd4: better reservation of head space for krb5 2014-05-30 17:32:17 -04:00
svcsock.c SUNRPC/NFSD: Remove using of dprintk with KERN_WARNING 2014-05-30 20:25:28 -04:00
sysctl.c
timer.c
xdr.c nfsd4: simplify server xdr->next_page use 2014-06-06 19:22:46 -04:00
xprt.c NFS client updates for Linux 3.16 2014-06-10 15:02:42 -07:00
xprtsock.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00