]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
lockd: push lock_flocks down
authorArnd Bergmann <arnd@arndb.de>
Tue, 26 Oct 2010 20:55:40 +0000 (22:55 +0200)
committerArnd Bergmann <arnd@arndb.de>
Wed, 27 Oct 2010 19:39:39 +0000 (21:39 +0200)
lockd should use lock_flocks() instead of lock_kernel()
to lock against posix locks accessing the i_flock list.

This is a prerequisite to turning lock_flocks into a
spinlock.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: J. Bruce Fields <bfields@redhat.com>
fs/lockd/svc.c
fs/lockd/svcsubs.c
fs/nfs/Kconfig
fs/nfsd/Kconfig

index b13aabc1229894507ca05ba53159c6f081d77fcf..abfff9d7979dc60b57646b6129cdb7dd279c6041 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/in.h>
 #include <linux/uio.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/mutex.h>
 #include <linux/kthread.h>
 #include <linux/freezer.h>
@@ -130,15 +129,6 @@ lockd(void *vrqstp)
 
        dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
 
-       /*
-        * FIXME: it would be nice if lockd didn't spend its entire life
-        * running under the BKL. At the very least, it would be good to
-        * have someone clarify what it's intended to protect here. I've
-        * seen some handwavy posts about posix locking needing to be
-        * done under the BKL, but it's far from clear.
-        */
-       lock_kernel();
-
        if (!nlm_timeout)
                nlm_timeout = LOCKD_DFLT_TIMEO;
        nlmsvc_timeout = nlm_timeout * HZ;
@@ -195,7 +185,6 @@ lockd(void *vrqstp)
        if (nlmsvc_ops)
                nlmsvc_invalidate_all();
        nlm_shutdown_hosts();
-       unlock_kernel();
        return 0;
 }
 
index d0ef94cfb3da4d218b66a0a4046d96ab30506f3b..1ca0679c80bfcca842d277f7597d96dbe8792c35 100644 (file)
@@ -170,6 +170,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
 
 again:
        file->f_locks = 0;
+       lock_flocks(); /* protects i_flock list */
        for (fl = inode->i_flock; fl; fl = fl->fl_next) {
                if (fl->fl_lmops != &nlmsvc_lock_operations)
                        continue;
@@ -181,6 +182,7 @@ again:
                if (match(lockhost, host)) {
                        struct file_lock lock = *fl;
 
+                       unlock_flocks();
                        lock.fl_type  = F_UNLCK;
                        lock.fl_start = 0;
                        lock.fl_end   = OFFSET_MAX;
@@ -192,6 +194,7 @@ again:
                        goto again;
                }
        }
+       unlock_flocks();
 
        return 0;
 }
@@ -226,10 +229,14 @@ nlm_file_inuse(struct nlm_file *file)
        if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares)
                return 1;
 
+       lock_flocks();
        for (fl = inode->i_flock; fl; fl = fl->fl_next) {
-               if (fl->fl_lmops == &nlmsvc_lock_operations)
+               if (fl->fl_lmops == &nlmsvc_lock_operations) {
+                       unlock_flocks();
                        return 1;
+               }
        }
+       unlock_flocks();
        file->f_locks = 0;
        return 0;
 }
index fd667652c5026daf78c878941da5f950dfdb4a5b..ba306658a6db16441843d7c4244a8c0158625acd 100644 (file)
@@ -1,7 +1,6 @@
 config NFS_FS
        tristate "NFS client support"
        depends on INET && FILE_LOCKING
-       depends on BKL # fix as soon as lockd is done
        select LOCKD
        select SUNRPC
        select NFS_ACL_SUPPORT if NFS_V3_ACL
index 31a78fce4732a0d473884425a0728073bf96668e..18b3e8975fe05c2364dd507d50b364b4c13b0dfd 100644 (file)
@@ -2,7 +2,6 @@ config NFSD
        tristate "NFS server support"
        depends on INET
        depends on FILE_LOCKING
-       depends on BKL # fix as soon as lockd is done
        select LOCKD
        select SUNRPC
        select EXPORTFS