aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/svcsubs.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 1adcf93cb6e6..d1c48b539df8 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -196,6 +196,12 @@ again:
196 return 0; 196 return 0;
197} 197}
198 198
199static int
200nlmsvc_always_match(void *dummy1, struct nlm_host *dummy2)
201{
202 return 1;
203}
204
199/* 205/*
200 * Inspect a single file 206 * Inspect a single file
201 */ 207 */
@@ -232,7 +238,8 @@ nlm_file_inuse(struct nlm_file *file)
232 * Loop over all files in the file table. 238 * Loop over all files in the file table.
233 */ 239 */
234static int 240static int
235nlm_traverse_files(void *data, nlm_host_match_fn_t match) 241nlm_traverse_files(void *data, nlm_host_match_fn_t match,
242 int (*is_failover_file)(void *data, struct nlm_file *file))
236{ 243{
237 struct hlist_node *pos, *next; 244 struct hlist_node *pos, *next;
238 struct nlm_file *file; 245 struct nlm_file *file;
@@ -241,6 +248,8 @@ nlm_traverse_files(void *data, nlm_host_match_fn_t match)
241 mutex_lock(&nlm_file_mutex); 248 mutex_lock(&nlm_file_mutex);
242 for (i = 0; i < FILE_NRHASH; i++) { 249 for (i = 0; i < FILE_NRHASH; i++) {
243 hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { 250 hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) {
251 if (is_failover_file && !is_failover_file(data, file))
252 continue;
244 file->f_count++; 253 file->f_count++;
245 mutex_unlock(&nlm_file_mutex); 254 mutex_unlock(&nlm_file_mutex);
246 255
@@ -345,7 +354,7 @@ void
345nlmsvc_mark_resources(void) 354nlmsvc_mark_resources(void)
346{ 355{
347 dprintk("lockd: nlmsvc_mark_resources\n"); 356 dprintk("lockd: nlmsvc_mark_resources\n");
348 nlm_traverse_files(NULL, nlmsvc_mark_host); 357 nlm_traverse_files(NULL, nlmsvc_mark_host, NULL);
349} 358}
350 359
351/* 360/*
@@ -356,7 +365,7 @@ nlmsvc_free_host_resources(struct nlm_host *host)
356{ 365{
357 dprintk("lockd: nlmsvc_free_host_resources\n"); 366 dprintk("lockd: nlmsvc_free_host_resources\n");
358 367
359 if (nlm_traverse_files(host, nlmsvc_same_host)) { 368 if (nlm_traverse_files(host, nlmsvc_same_host, NULL)) {
360 printk(KERN_WARNING 369 printk(KERN_WARNING
361 "lockd: couldn't remove all locks held by %s\n", 370 "lockd: couldn't remove all locks held by %s\n",
362 host->h_name); 371 host->h_name);
@@ -376,8 +385,26 @@ nlmsvc_invalidate_all(void)
376 * turn, which is about as inefficient as it gets. 385 * turn, which is about as inefficient as it gets.
377 * Now we just do it once in nlm_traverse_files. 386 * Now we just do it once in nlm_traverse_files.
378 */ 387 */
379 nlm_traverse_files(NULL, nlmsvc_is_client); 388 nlm_traverse_files(NULL, nlmsvc_is_client, NULL);
389}
390
391static int
392nlmsvc_match_sb(void *datap, struct nlm_file *file)
393{
394 struct super_block *sb = datap;
395
396 return sb == file->f_file->f_path.mnt->mnt_sb;
397}
398
399int
400nlmsvc_unlock_all_by_sb(struct super_block *sb)
401{
402 int ret;
403
404 ret = nlm_traverse_files(sb, nlmsvc_always_match, nlmsvc_match_sb);
405 return ret ? -EIO : 0;
380} 406}
407EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb);
381 408
382static int 409static int
383nlmsvc_match_ip(void *datap, struct nlm_host *host) 410nlmsvc_match_ip(void *datap, struct nlm_host *host)
@@ -391,7 +418,7 @@ int
391nlmsvc_unlock_all_by_ip(__be32 server_addr) 418nlmsvc_unlock_all_by_ip(__be32 server_addr)
392{ 419{
393 int ret; 420 int ret;
394 ret = nlm_traverse_files(&server_addr, nlmsvc_match_ip); 421 ret = nlm_traverse_files(&server_addr, nlmsvc_match_ip, NULL);
395 return ret ? -EIO : 0; 422 return ret ? -EIO : 0;
396 423
397} 424}