From: Arnd Bergmann <arnd@arndb.de>
To: Bryan Schumaker <bjschuma@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: nfsd changes for 2.6.37
Date: Tue, 26 Oct 2010 22:55:40 +0200 [thread overview]
Message-ID: <201010262255.40481.arnd@arndb.de> (raw)
In-Reply-To: <4CC73BA6.1090407@netapp.com>
On Tuesday 26 October 2010 22:35:50 Bryan Schumaker wrote:
> Hi
>
> I left the one call because I was unable to figure out what
> was being protected with the BKL in that section of the code.
> I figured I would leave it for the maintainers, since they
> know more about the code than I do.
My guess is that we need something like the patch below.
This moves the lock_flocks() call into the places where it
is needed and can be safely converted into a spinlock because
that code does not sleep.
Finally, we can build fs/locks.c, nfs and nfsd with CONFIG_BKL
disabled.
*not tested*
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Kconfig | 1 -
lockd/svc.c | 11 -----------
lockd/svcsubs.c | 9 ++++++++-
locks.c | 5 +++--
nfs/Kconfig | 1 -
nfsd/Kconfig | 1 -
6 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/fs/Kconfig b/fs/Kconfig
index 65781de..3d18530 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -50,7 +50,6 @@ endif # BLOCK
config FILE_LOCKING
bool "Enable POSIX file locking API" if EMBEDDED
default y
- select BKL # while lockd still uses it.
help
This option enables standard file locking support, required
for filesystems like NFS and for the flock() system
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index b13aabc..abfff9d 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -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;
}
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index d0ef94c..1ca0679 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -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;
}
diff --git a/fs/locks.c b/fs/locks.c
index 8b2b6ad..a417901 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -142,6 +142,7 @@ int lease_break_time = 45;
static LIST_HEAD(file_lock_list);
static LIST_HEAD(blocked_list);
+static DEFINE_SPINLOCK(file_lock_lock);
/*
* Protects the two list heads above, plus the inode->i_flock list
@@ -149,13 +150,13 @@ static LIST_HEAD(blocked_list);
*/
void lock_flocks(void)
{
- lock_kernel();
+ spin_lock(&file_lock_lock);
}
EXPORT_SYMBOL_GPL(lock_flocks);
void unlock_flocks(void)
{
- unlock_kernel();
+ spin_unlock(&file_lock_lock);
}
EXPORT_SYMBOL_GPL(unlock_flocks);
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index fd66765..ba30665 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -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
diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig
index 31a78fc..18b3e89 100644
--- a/fs/nfsd/Kconfig
+++ b/fs/nfsd/Kconfig
@@ -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
next prev parent reply other threads:[~2010-10-26 20:55 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-26 16:45 nfsd changes for 2.6.37 J. Bruce Fields
2010-10-26 17:22 ` J. Bruce Fields
2010-10-26 17:39 ` Linus Torvalds
[not found] ` <AANLkTi=emsmLNFSV=j48d37JQxecQmNGZwY9OYdoKjeS-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-26 17:46 ` J. Bruce Fields
2010-10-26 20:18 ` Arnd Bergmann
2010-10-26 20:35 ` Bryan Schumaker
2010-10-26 20:55 ` Arnd Bergmann [this message]
2010-10-26 21:02 ` Linus Torvalds
2010-10-26 21:24 ` J. Bruce Fields
2010-10-26 21:37 ` Linus Torvalds
2010-10-26 21:44 ` J. Bruce Fields
2010-10-26 22:11 ` J. Bruce Fields
2010-10-26 22:41 ` J. Bruce Fields
2010-10-27 7:21 ` Arnd Bergmann
2010-10-27 8:39 ` Christoph Hellwig
2010-10-27 13:39 ` J. Bruce Fields
2010-10-27 13:46 ` Arnd Bergmann
2010-10-27 14:55 ` J. Bruce Fields
2010-10-27 14:59 ` Christoph Hellwig
2010-10-27 15:16 ` J. Bruce Fields
2010-10-27 15:19 ` Christoph Hellwig
2010-10-27 15:23 ` Arnd Bergmann
2010-10-27 15:28 ` J. Bruce Fields
2010-10-27 15:31 ` Christoph Hellwig
2010-10-27 16:12 ` Linus Torvalds
[not found] ` <AANLkTinTm-LwjfBfoFUyp5Dj8S2hexnHGQGpZiOWqyMY-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-27 16:46 ` J. Bruce Fields
2010-10-27 17:32 ` Linus Torvalds
2010-10-27 17:40 ` J. Bruce Fields
2010-10-27 18:20 ` Arnd Bergmann
2010-10-27 18:42 ` Linus Torvalds
2010-10-27 18:43 ` Linus Torvalds
2010-10-27 19:48 ` Arnd Bergmann
2010-10-27 20:01 ` J. Bruce Fields
2010-10-27 20:20 ` Arnd Bergmann
2010-10-27 20:24 ` J. Bruce Fields
2010-10-30 21:25 ` J. Bruce Fields
2010-10-30 21:31 ` [PATCH 1/4] locks: prevent ENOMEM on lease unlock J. Bruce Fields
2010-10-30 21:31 ` [PATCH 2/4] locks: fix leaks on setlease errors J. Bruce Fields
2010-10-31 11:10 ` Christoph Hellwig
2010-11-01 17:24 ` J. Bruce Fields
2010-11-01 17:41 ` Christoph Hellwig
2010-11-01 18:34 ` J. Bruce Fields
2010-10-30 21:31 ` [PATCH 3/4] locks: fix setlease methods to free passed-in lock J. Bruce Fields
2010-10-30 21:31 ` [PATCH 4/4] nfsd4: initialize delegation pointer to lease J. Bruce Fields
2010-10-31 2:04 ` Christoph Hellwig
2010-10-31 3:04 ` J. Bruce Fields
2010-10-30 21:40 ` nfsd changes for 2.6.37 Arnd Bergmann
2010-10-31 2:07 ` Christoph Hellwig
2010-10-31 3:05 ` J. Bruce Fields
2010-10-31 12:34 ` Christoph Hellwig
2010-10-31 12:35 ` [PATCH 1/2] locks: let the caller free file_lock on ->setlease failure Christoph Hellwig
2010-11-03 20:41 ` J. Bruce Fields
2010-11-04 1:40 ` J. Bruce Fields
2010-11-04 1:41 ` J. Bruce Fields
2010-11-06 19:03 ` Christoph Hellwig
2010-11-06 19:03 ` Christoph Hellwig
2010-11-08 16:10 ` J. Bruce Fields
2010-10-31 12:35 ` [PATCH 2/2] locks: remove fl_copy_lock lock_manager operation Christoph Hellwig
2010-11-01 15:02 ` nfsd changes for 2.6.37 J. Bruce Fields
2010-11-06 19:04 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010262255.40481.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=bfields@fieldses.org \
--cc=bjschuma@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).