linux/fs/cifs
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
..
asn1.c
cache.c
cifs_debug.c
cifs_debug.h
cifs_dfs_ref.c
cifs_fs_sb.h
cifs_spnego.c
cifs_spnego.h
cifs_unicode.c [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option 2014-06-24 08:10:24 -05:00
cifs_unicode.h
cifs_uniupr.h
cifsacl.c [CIFS] Fix cifsacl mounts over smb2 to not call cifs 2014-02-10 14:08:16 -06:00
cifsacl.h
cifsencrypt.c
cifsfs.c cifs: revalidate mapping prior to satisfying read_iter request with cache=loose 2014-06-19 13:34:04 -05:00
cifsfs.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-06-12 10:30:18 -07:00
cifsglob.h cifs: Set client guid on per connection basis 2014-05-21 10:18:05 -07:00
cifspdu.h
cifsproto.h cifs: Wait for writebacks to complete before attempting write. 2014-04-16 13:51:46 -05:00
cifssmb.c Return correct error on query of xattr on file with empty xattrs 2014-04-16 13:51:46 -05:00
connect.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
dir.c [CIFS] Fix cifsacl mounts over smb2 to not call cifs 2014-02-10 14:08:16 -06:00
dns_resolve.c
dns_resolve.h
export.c
file.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
fscache.c
fscache.h
inode.c sched: Allow wait_on_bit_action() functions to support a timeout 2014-07-16 15:10:41 +02:00
ioctl.c fs: cifs: new helper: file_inode(file) 2014-05-21 10:18:05 -07:00
Kconfig
link.c fs/cifs: fix regression in cifs_create_mf_symlink() 2014-06-16 13:50:11 -05:00
Makefile
misc.c sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
netmisc.c fs/cifs/netmisc.c: convert printk to pr_foo() 2014-05-21 10:18:05 -07:00
nterr.c
nterr.h
ntlmssp.h
readdir.c cifs: Rename MF symlink function names 2014-01-20 00:13:54 -06:00
rfc1002pdu.h
sess.c
smb1ops.c cifs: Wait for writebacks to complete before attempting write. 2014-04-16 13:51:46 -05:00
smb2file.c
smb2glob.h CIFS: Fix too big maxBuf size for SMB3 mounts 2014-02-14 16:50:47 -06:00
smb2inode.c
smb2maperror.c
smb2misc.c cifs: Wait for writebacks to complete before attempting write. 2014-04-16 13:51:46 -05:00
smb2ops.c Clarify SMB2/SMB3 create context and add missing ones 2014-05-21 10:18:06 -07:00
smb2pdu.c CIFS: Fix memory leaks in SMB2_open 2014-05-24 13:24:20 -07:00
smb2pdu.h Clarify SMB2/SMB3 create context and add missing ones 2014-05-21 10:18:06 -07:00
smb2proto.h [CIFS] clean up page array when uncached write send fails 2014-02-07 20:47:00 -06:00
smb2status.h
smb2transport.c
smbencrypt.c
smberr.h
smbfsctl.h Check SMB3 dialects against downgrade attacks 2013-11-19 23:52:54 -06:00
transport.c cifs: sanity check length of data to send before sending 2014-02-23 20:55:07 -06:00
winucase.c
xattr.c retrieving CIFS ACLs when mounted with SMB2 fails dropping session 2014-02-07 11:08:17 -06:00