Skip to content

Commit 763641d

Browse files
committed
lockd: push lock_flocks down
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>
1 parent f9ba537 commit 763641d

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

fs/lockd/svc.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/in.h>
2323
#include <linux/uio.h>
2424
#include <linux/smp.h>
25-
#include <linux/smp_lock.h>
2625
#include <linux/mutex.h>
2726
#include <linux/kthread.h>
2827
#include <linux/freezer.h>
@@ -130,15 +129,6 @@ lockd(void *vrqstp)
130129

131130
dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
132131

133-
/*
134-
* FIXME: it would be nice if lockd didn't spend its entire life
135-
* running under the BKL. At the very least, it would be good to
136-
* have someone clarify what it's intended to protect here. I've
137-
* seen some handwavy posts about posix locking needing to be
138-
* done under the BKL, but it's far from clear.
139-
*/
140-
lock_kernel();
141-
142132
if (!nlm_timeout)
143133
nlm_timeout = LOCKD_DFLT_TIMEO;
144134
nlmsvc_timeout = nlm_timeout * HZ;
@@ -195,7 +185,6 @@ lockd(void *vrqstp)
195185
if (nlmsvc_ops)
196186
nlmsvc_invalidate_all();
197187
nlm_shutdown_hosts();
198-
unlock_kernel();
199188
return 0;
200189
}
201190

fs/lockd/svcsubs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
170170

171171
again:
172172
file->f_locks = 0;
173+
lock_flocks(); /* protects i_flock list */
173174
for (fl = inode->i_flock; fl; fl = fl->fl_next) {
174175
if (fl->fl_lmops != &nlmsvc_lock_operations)
175176
continue;
@@ -181,6 +182,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
181182
if (match(lockhost, host)) {
182183
struct file_lock lock = *fl;
183184

185+
unlock_flocks();
184186
lock.fl_type = F_UNLCK;
185187
lock.fl_start = 0;
186188
lock.fl_end = OFFSET_MAX;
@@ -192,6 +194,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
192194
goto again;
193195
}
194196
}
197+
unlock_flocks();
195198

196199
return 0;
197200
}
@@ -226,10 +229,14 @@ nlm_file_inuse(struct nlm_file *file)
226229
if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares)
227230
return 1;
228231

232+
lock_flocks();
229233
for (fl = inode->i_flock; fl; fl = fl->fl_next) {
230-
if (fl->fl_lmops == &nlmsvc_lock_operations)
234+
if (fl->fl_lmops == &nlmsvc_lock_operations) {
235+
unlock_flocks();
231236
return 1;
237+
}
232238
}
239+
unlock_flocks();
233240
file->f_locks = 0;
234241
return 0;
235242
}

fs/nfs/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
config NFS_FS
22
tristate "NFS client support"
33
depends on INET && FILE_LOCKING
4-
depends on BKL # fix as soon as lockd is done
54
select LOCKD
65
select SUNRPC
76
select NFS_ACL_SUPPORT if NFS_V3_ACL

fs/nfsd/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ config NFSD
22
tristate "NFS server support"
33
depends on INET
44
depends on FILE_LOCKING
5-
depends on BKL # fix as soon as lockd is done
65
select LOCKD
76
select SUNRPC
87
select EXPORTFS

0 commit comments

Comments
 (0)