linux/fs/afs
David Howells 0fafdc9f88 afs: Fix file locking
Fix the AFS file locking whereby the use of the big kernel lock (which
could be slept with) was replaced by a spinlock (which couldn't).  The
problem is that the AFS code was doing stuff inside the critical section
that might call schedule(), so this is a broken transformation.

Fix this by the following means:

 (1) Use a state machine with a proper state that can only be changed under
     the spinlock rather than using a collection of bit flags.

 (2) Cache the key used for the lock and the lock type in the afs_vnode
     struct so that the manager work function doesn't have to refer to a
     file_lock struct that's been dequeued.  This makes signal handling
     safer.

 (4) Move the unlock from afs_do_unlk() to afs_fl_release_private() which
     means that unlock is achieved in other circumstances too.

 (5) Unlock the file on the server before taking the next conflicting lock.

Also change:

 (1) Check the permits on a file before actually trying the lock.

 (2) fsync the file before effecting an explicit unlock operation.  We
     don't fsync if the lock is erased otherwise as we might not be in a
     context where we can actually do that.

Further fixes:

 (1) Fixed-fileserver address rotation is made to work.  It's only used by
     the locking functions, so couldn't be tested before.

Fixes: 72f98e7255 ("locks: turn lock_flocks into a spinlock")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: jlayton@redhat.com
2017-11-17 10:06:13 +00:00
..
addr_list.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
afs_cm.h afs: support the CB.ProbeUuid RPC op 2008-04-29 08:06:26 -07:00
afs_fs.h afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
afs_vl.h afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
afs.h afs: Overhaul permit caching 2017-11-13 15:38:18 +00:00
cache.c afs: Update the cache index structure 2017-11-13 15:38:17 +00:00
callback.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
cell.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
cmservice.c afs: Protect call->state changes against signals 2017-11-13 15:38:21 +00:00
dir.c afs: Introduce a file-private data record 2017-11-13 15:38:20 +00:00
file.c afs: Trace page dirty/clean 2017-11-13 15:38:21 +00:00
flock.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
fsclient.c afs: Get rid of the afs_writeback record 2017-11-13 15:38:20 +00:00
inode.c afs: Get rid of the afs_writeback record 2017-11-13 15:38:20 +00:00
internal.h afs: Fix file locking 2017-11-17 10:06:13 +00:00
Kconfig fs/afs: remove depends on CONFIG_EXPERIMENTAL 2013-01-21 14:39:04 -08:00
main.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
Makefile afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
misc.c afs: Consolidate abort_to_error translators 2017-11-13 15:38:17 +00:00
mntpt.c afs: Add metadata xattrs 2017-07-09 14:40:12 -07:00
netdevices.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
proc.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00
rotate.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
rxrpc.c afs: Protect call->state changes against signals 2017-11-13 15:38:21 +00:00
security.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
server_list.c afs: Fix file locking 2017-11-17 10:06:13 +00:00
server.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
super.c afs: Get rid of the afs_writeback record 2017-11-13 15:38:20 +00:00
vlclient.c afs: Trace the initiation and completion of client calls 2017-11-13 15:38:19 +00:00
volume.c afs: Make use of the YFS service upgrade to fully support IPv6 2017-11-13 15:38:19 +00:00
write.c AFS development 2017-11-16 11:41:22 -08:00
xattr.c afs: Overhaul volume and server record caching and fileserver rotation 2017-11-13 15:38:19 +00:00