android_kernel_motorola_sm6225/fs/nfs
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
..
blocklayout nfs: modify pg_test interface to return size_t 2014-05-29 11:11:43 -04:00
filelayout sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
objlayout pNFS: Handle allocation errors correctly in objlayout_alloc_layout_hdr() 2014-05-29 20:17:17 -04:00
cache_lib.c
cache_lib.h
callback.c nfs: Use PTR_ERR_OR_ZERO in 'nfs41_callback_up' function 2013-10-28 18:16:55 -04:00
callback.h
callback_proc.c NFSv4.1: Minor optimisation in get_layout_by_fh_locked() 2014-02-19 21:21:06 -05:00
callback_xdr.c
client.c NFS: cache parsed auth_info in nfs_server 2013-10-28 15:37:43 -04:00
delegation.c NFS: Fix a delegation callback race 2014-03-02 22:03:12 -05:00
delegation.h
dir.c arch: Mass conversion of smp_mb__*() 2014-04-18 14:20:48 +02:00
direct.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-06-12 10:30:18 -07:00
dns_resolve.c NFS: Enabling v4.2 should not recompile nfsd and lockd 2013-11-19 16:20:40 -05:00
dns_resolve.h
file.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
fscache-index.c
fscache.c NFS: Use i_writecount to control whether to get an fscache cookie in nfs_open() 2013-09-27 18:40:25 +01:00
fscache.h NFS: Use i_writecount to control whether to get an fscache cookie in nfs_open() 2013-09-27 18:40:25 +01:00
getroot.c NFS: Fix memroy leak for double mounts 2014-04-15 10:29:25 -04:00
idmap.c NFSv4: Convert idmapper to use the new framework for pipefs dentries 2013-09-01 11:12:42 -04:00
inode.c sched: Allow wait_on_bit_action() functions to support a timeout 2014-07-16 15:10:41 +02:00
internal.h sched: Allow wait_on_bit_action() functions to support a timeout 2014-07-16 15:10:41 +02:00
iostat.h
Kconfig nfs: fix pnfs Kconfig defaults 2013-11-15 13:41:43 -05:00
Makefile Push the file layout driver into a subdirectory 2014-05-29 20:21:56 -04:00
mount_clnt.c
namespace.c nfs: use %p[dD] instead of open-coded (and often racy) equivalents 2013-10-24 23:34:50 -04:00
netns.h
nfs.h
nfs2super.c
nfs2xdr.c NFS: Create a common results structure for reads and writes 2014-05-28 18:12:43 -04:00
nfs3acl.c NFSv3: Fix return value of nfs3_proc_setacls 2014-02-03 13:14:23 -05:00
nfs3client.c
nfs3proc.c NFS: Create a common pgio_rpc_prepare function 2014-05-28 18:40:28 -04:00
nfs3super.c nfs: use generic posix ACL infrastructure for v3 Posix ACLs 2014-01-26 08:26:20 -05:00
nfs3xdr.c NFS: Create a common results structure for reads and writes 2014-05-28 18:12:43 -04:00
nfs4_fs.h NFSv4: test SECINFO RPC_AUTH_GSS pseudoflavors for support 2014-06-24 18:46:58 -04:00
nfs4client.c NFSv4: Schedule recovery if nfs40_walk_client_list() is interrupted 2014-03-19 08:34:20 -04:00
nfs4file.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-06-12 10:30:18 -07:00
nfs4getroot.c NFSv4: Fix security auto-negotiation 2013-09-07 16:18:30 -04:00
nfs4namespace.c NFSv4: test SECINFO RPC_AUTH_GSS pseudoflavors for support 2014-06-24 18:46:58 -04:00
nfs4proc.c NFSv4: test SECINFO RPC_AUTH_GSS pseudoflavors for support 2014-06-24 18:46:58 -04:00
nfs4renewd.c
nfs4session.c NFSv4.1: nfs4_destroy_session must call rpc_destroy_waitqueue 2014-02-01 15:13:39 -05:00
nfs4session.h NFSv4.1: nfs4_destroy_session must call rpc_destroy_waitqueue 2014-02-01 15:13:39 -05:00
nfs4state.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
nfs4super.c mm + fs: store shadow entries in page cache 2014-04-03 16:21:01 -07:00
nfs4sysctl.c nfs: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:16 -07:00
nfs4trace.c NFSv4.1: Add tracepoints for debugging slot table operations 2013-08-22 08:58:27 -04:00
nfs4trace.h NFS: Create a common read and write data struct 2014-05-28 18:12:47 -04:00
nfs4xdr.c NFS: Create a common results structure for reads and writes 2014-05-28 18:12:43 -04:00
nfsroot.c
nfstrace.c
nfstrace.h NFS: fix the handling of NFS_INO_INVALID_DATA flag in nfs_revalidate_mapping 2014-01-27 15:35:56 -05:00
pagelist.c sched: Allow wait_on_bit_action() functions to support a timeout 2014-07-16 15:10:41 +02:00
pnfs.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
pnfs.h NFS client updates for Linux 3.16 2014-06-10 15:02:42 -07:00
pnfs_dev.c
proc.c NFS: Create a common pgio_rpc_prepare function 2014-05-28 18:40:28 -04:00
read.c nfs: support page groups in nfs_read_completion 2014-05-29 11:11:50 -04:00
super.c NFS: populate ->net in mount data when remounting 2014-06-10 11:10:29 -04:00
symlink.c
sysctl.c nfs: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:16 -07:00
unlink.c nfs: emit a fsnotify_nameremove call in sillyrename codepath 2014-03-17 15:14:17 -04:00
write.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00