fs/locks.c: prepare for BKL removal

This prepares the removal of the big kernel lock from the
file locking code. We still use the BKL as long as fs/lockd
uses it and ceph might sleep, but we can flip the definition
to a private spinlock as soon as that's done.
All users outside of fs/lockd get converted to use
lock_flocks() instead of lock_kernel() where appropriate.

Based on an earlier patch to use a spinlock from Matthew
Wilcox, who has attempted this a few times before, the
earliest patch from over 10 years ago turned it into
a semaphore, which ended up being slower than the BKL
and was subsequently reverted.

Someone should do some serious performance testing when
this becomes a spinlock, since this has caused problems
before. Using a spinlock should be at least as good
as the BKL in theory, but who knows...

Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Matthew Wilcox <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: John Kacur <[email protected]>
Cc: Sage Weil <[email protected]>
Cc: [email protected]
Cc: [email protected]
This commit is contained in:
Arnd Bergmann 2010-09-18 15:09:31 +02:00
commit b89f432133
8 changed files with 97 additions and 66 deletions

View file

@ -9,7 +9,6 @@
* 2 of the License, or (at your option) any later version.
*/
#include <linux/smp_lock.h>
#include "internal.h"
#define AFS_LOCK_GRANTED 0
@ -274,7 +273,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
lock_kernel();
lock_flocks();
/* make sure we've got a callback on this file and that our view of the
* data version is up to date */
@ -421,7 +420,7 @@ given_lock:
afs_vnode_fetch_status(vnode, NULL, key);
error:
unlock_kernel();
unlock_flocks();
_leave(" = %d", ret);
return ret;