aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-07 01:49:38 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-07 01:50:23 -0500
commitb5c84bf6f6fa3a7dfdcb556023a62953574b60ee (patch)
tree7a2c299a180713e21d5cb653cb933121adf53c31 /fs/autofs4
parent949854d02455080d20cd3e1db28a3a18daf7599d (diff)
fs: dcache remove dcache_lock
dcache_lock no longer protects anything. remove it. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'fs/autofs4')
-rw-r--r--fs/autofs4/autofs_i.h3
-rw-r--r--fs/autofs4/expire.c10
-rw-r--r--fs/autofs4/root.c44
-rw-r--r--fs/autofs4/waitq.c7
4 files changed, 35 insertions, 29 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 9d2ae9b30d9f..0fffe1c24cec 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -16,6 +16,7 @@
16#include <linux/auto_fs4.h> 16#include <linux/auto_fs4.h>
17#include <linux/auto_dev-ioctl.h> 17#include <linux/auto_dev-ioctl.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/spinlock.h>
19#include <linux/list.h> 20#include <linux/list.h>
20 21
21/* This is the range of ioctl() numbers we claim as ours */ 22/* This is the range of ioctl() numbers we claim as ours */
@@ -60,6 +61,8 @@ do { \
60 current->pid, __func__, ##args); \ 61 current->pid, __func__, ##args); \
61} while (0) 62} while (0)
62 63
64extern spinlock_t autofs4_lock;
65
63/* Unified info structure. This is pointed to by both the dentry and 66/* Unified info structure. This is pointed to by both the dentry and
64 inode structures. Each file in the filesystem has an instance of this 67 inode structures. Each file in the filesystem has an instance of this
65 structure. It holds a reference to the dentry, so dentries are never 68 structure. It holds a reference to the dentry, so dentries are never
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 968c1434af62..2f7951d67d16 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -102,7 +102,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
102 if (prev == NULL) 102 if (prev == NULL)
103 return dget(prev); 103 return dget(prev);
104 104
105 spin_lock(&dcache_lock); 105 spin_lock(&autofs4_lock);
106relock: 106relock:
107 p = prev; 107 p = prev;
108 spin_lock(&p->d_lock); 108 spin_lock(&p->d_lock);
@@ -114,7 +114,7 @@ again:
114 114
115 if (p == root) { 115 if (p == root) {
116 spin_unlock(&p->d_lock); 116 spin_unlock(&p->d_lock);
117 spin_unlock(&dcache_lock); 117 spin_unlock(&autofs4_lock);
118 dput(prev); 118 dput(prev);
119 return NULL; 119 return NULL;
120 } 120 }
@@ -144,7 +144,7 @@ again:
144 dget_dlock(ret); 144 dget_dlock(ret);
145 spin_unlock(&ret->d_lock); 145 spin_unlock(&ret->d_lock);
146 spin_unlock(&p->d_lock); 146 spin_unlock(&p->d_lock);
147 spin_unlock(&dcache_lock); 147 spin_unlock(&autofs4_lock);
148 148
149 dput(prev); 149 dput(prev);
150 150
@@ -408,13 +408,13 @@ found:
408 ino->flags |= AUTOFS_INF_EXPIRING; 408 ino->flags |= AUTOFS_INF_EXPIRING;
409 init_completion(&ino->expire_complete); 409 init_completion(&ino->expire_complete);
410 spin_unlock(&sbi->fs_lock); 410 spin_unlock(&sbi->fs_lock);
411 spin_lock(&dcache_lock); 411 spin_lock(&autofs4_lock);
412 spin_lock(&expired->d_parent->d_lock); 412 spin_lock(&expired->d_parent->d_lock);
413 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); 413 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED);
414 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); 414 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
415 spin_unlock(&expired->d_lock); 415 spin_unlock(&expired->d_lock);
416 spin_unlock(&expired->d_parent->d_lock); 416 spin_unlock(&expired->d_parent->d_lock);
417 spin_unlock(&dcache_lock); 417 spin_unlock(&autofs4_lock);
418 return expired; 418 return expired;
419} 419}
420 420
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 7a9ed6b88291..10ca68a96dc7 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -23,6 +23,8 @@
23 23
24#include "autofs_i.h" 24#include "autofs_i.h"
25 25
26DEFINE_SPINLOCK(autofs4_lock);
27
26static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); 28static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
27static int autofs4_dir_unlink(struct inode *,struct dentry *); 29static int autofs4_dir_unlink(struct inode *,struct dentry *);
28static int autofs4_dir_rmdir(struct inode *,struct dentry *); 30static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -142,15 +144,15 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
142 * autofs file system so just let the libfs routines handle 144 * autofs file system so just let the libfs routines handle
143 * it. 145 * it.
144 */ 146 */
145 spin_lock(&dcache_lock); 147 spin_lock(&autofs4_lock);
146 spin_lock(&dentry->d_lock); 148 spin_lock(&dentry->d_lock);
147 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 149 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
148 spin_unlock(&dentry->d_lock); 150 spin_unlock(&dentry->d_lock);
149 spin_unlock(&dcache_lock); 151 spin_unlock(&autofs4_lock);
150 return -ENOENT; 152 return -ENOENT;
151 } 153 }
152 spin_unlock(&dentry->d_lock); 154 spin_unlock(&dentry->d_lock);
153 spin_unlock(&dcache_lock); 155 spin_unlock(&autofs4_lock);
154 156
155out: 157out:
156 return dcache_dir_open(inode, file); 158 return dcache_dir_open(inode, file);
@@ -255,11 +257,11 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
255 /* We trigger a mount for almost all flags */ 257 /* We trigger a mount for almost all flags */
256 lookup_type = autofs4_need_mount(nd->flags); 258 lookup_type = autofs4_need_mount(nd->flags);
257 spin_lock(&sbi->fs_lock); 259 spin_lock(&sbi->fs_lock);
258 spin_lock(&dcache_lock); 260 spin_lock(&autofs4_lock);
259 spin_lock(&dentry->d_lock); 261 spin_lock(&dentry->d_lock);
260 if (!(lookup_type || ino->flags & AUTOFS_INF_PENDING)) { 262 if (!(lookup_type || ino->flags & AUTOFS_INF_PENDING)) {
261 spin_unlock(&dentry->d_lock); 263 spin_unlock(&dentry->d_lock);
262 spin_unlock(&dcache_lock); 264 spin_unlock(&autofs4_lock);
263 spin_unlock(&sbi->fs_lock); 265 spin_unlock(&sbi->fs_lock);
264 goto follow; 266 goto follow;
265 } 267 }
@@ -272,7 +274,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
272 if (ino->flags & AUTOFS_INF_PENDING || 274 if (ino->flags & AUTOFS_INF_PENDING ||
273 (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) { 275 (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) {
274 spin_unlock(&dentry->d_lock); 276 spin_unlock(&dentry->d_lock);
275 spin_unlock(&dcache_lock); 277 spin_unlock(&autofs4_lock);
276 spin_unlock(&sbi->fs_lock); 278 spin_unlock(&sbi->fs_lock);
277 279
278 status = try_to_fill_dentry(dentry, nd->flags); 280 status = try_to_fill_dentry(dentry, nd->flags);
@@ -282,7 +284,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
282 goto follow; 284 goto follow;
283 } 285 }
284 spin_unlock(&dentry->d_lock); 286 spin_unlock(&dentry->d_lock);
285 spin_unlock(&dcache_lock); 287 spin_unlock(&autofs4_lock);
286 spin_unlock(&sbi->fs_lock); 288 spin_unlock(&sbi->fs_lock);
287follow: 289follow:
288 /* 290 /*
@@ -353,14 +355,14 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
353 return 0; 355 return 0;
354 356
355 /* Check for a non-mountpoint directory with no contents */ 357 /* Check for a non-mountpoint directory with no contents */
356 spin_lock(&dcache_lock); 358 spin_lock(&autofs4_lock);
357 spin_lock(&dentry->d_lock); 359 spin_lock(&dentry->d_lock);
358 if (S_ISDIR(dentry->d_inode->i_mode) && 360 if (S_ISDIR(dentry->d_inode->i_mode) &&
359 !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 361 !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
360 DPRINTK("dentry=%p %.*s, emptydir", 362 DPRINTK("dentry=%p %.*s, emptydir",
361 dentry, dentry->d_name.len, dentry->d_name.name); 363 dentry, dentry->d_name.len, dentry->d_name.name);
362 spin_unlock(&dentry->d_lock); 364 spin_unlock(&dentry->d_lock);
363 spin_unlock(&dcache_lock); 365 spin_unlock(&autofs4_lock);
364 366
365 /* The daemon never causes a mount to trigger */ 367 /* The daemon never causes a mount to trigger */
366 if (oz_mode) 368 if (oz_mode)
@@ -377,7 +379,7 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
377 return status; 379 return status;
378 } 380 }
379 spin_unlock(&dentry->d_lock); 381 spin_unlock(&dentry->d_lock);
380 spin_unlock(&dcache_lock); 382 spin_unlock(&autofs4_lock);
381 383
382 return 1; 384 return 1;
383} 385}
@@ -432,7 +434,7 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
432 const unsigned char *str = name->name; 434 const unsigned char *str = name->name;
433 struct list_head *p, *head; 435 struct list_head *p, *head;
434 436
435 spin_lock(&dcache_lock); 437 spin_lock(&autofs4_lock);
436 spin_lock(&sbi->lookup_lock); 438 spin_lock(&sbi->lookup_lock);
437 head = &sbi->active_list; 439 head = &sbi->active_list;
438 list_for_each(p, head) { 440 list_for_each(p, head) {
@@ -465,14 +467,14 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
465 dget_dlock(active); 467 dget_dlock(active);
466 spin_unlock(&active->d_lock); 468 spin_unlock(&active->d_lock);
467 spin_unlock(&sbi->lookup_lock); 469 spin_unlock(&sbi->lookup_lock);
468 spin_unlock(&dcache_lock); 470 spin_unlock(&autofs4_lock);
469 return active; 471 return active;
470 } 472 }
471next: 473next:
472 spin_unlock(&active->d_lock); 474 spin_unlock(&active->d_lock);
473 } 475 }
474 spin_unlock(&sbi->lookup_lock); 476 spin_unlock(&sbi->lookup_lock);
475 spin_unlock(&dcache_lock); 477 spin_unlock(&autofs4_lock);
476 478
477 return NULL; 479 return NULL;
478} 480}
@@ -487,7 +489,7 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
487 const unsigned char *str = name->name; 489 const unsigned char *str = name->name;
488 struct list_head *p, *head; 490 struct list_head *p, *head;
489 491
490 spin_lock(&dcache_lock); 492 spin_lock(&autofs4_lock);
491 spin_lock(&sbi->lookup_lock); 493 spin_lock(&sbi->lookup_lock);
492 head = &sbi->expiring_list; 494 head = &sbi->expiring_list;
493 list_for_each(p, head) { 495 list_for_each(p, head) {
@@ -520,14 +522,14 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
520 dget_dlock(expiring); 522 dget_dlock(expiring);
521 spin_unlock(&expiring->d_lock); 523 spin_unlock(&expiring->d_lock);
522 spin_unlock(&sbi->lookup_lock); 524 spin_unlock(&sbi->lookup_lock);
523 spin_unlock(&dcache_lock); 525 spin_unlock(&autofs4_lock);
524 return expiring; 526 return expiring;
525 } 527 }
526next: 528next:
527 spin_unlock(&expiring->d_lock); 529 spin_unlock(&expiring->d_lock);
528 } 530 }
529 spin_unlock(&sbi->lookup_lock); 531 spin_unlock(&sbi->lookup_lock);
530 spin_unlock(&dcache_lock); 532 spin_unlock(&autofs4_lock);
531 533
532 return NULL; 534 return NULL;
533} 535}
@@ -763,12 +765,12 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
763 765
764 dir->i_mtime = CURRENT_TIME; 766 dir->i_mtime = CURRENT_TIME;
765 767
766 spin_lock(&dcache_lock); 768 spin_lock(&autofs4_lock);
767 autofs4_add_expiring(dentry); 769 autofs4_add_expiring(dentry);
768 spin_lock(&dentry->d_lock); 770 spin_lock(&dentry->d_lock);
769 __d_drop(dentry); 771 __d_drop(dentry);
770 spin_unlock(&dentry->d_lock); 772 spin_unlock(&dentry->d_lock);
771 spin_unlock(&dcache_lock); 773 spin_unlock(&autofs4_lock);
772 774
773 return 0; 775 return 0;
774} 776}
@@ -785,20 +787,20 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
785 if (!autofs4_oz_mode(sbi)) 787 if (!autofs4_oz_mode(sbi))
786 return -EACCES; 788 return -EACCES;
787 789
788 spin_lock(&dcache_lock); 790 spin_lock(&autofs4_lock);
789 spin_lock(&sbi->lookup_lock); 791 spin_lock(&sbi->lookup_lock);
790 spin_lock(&dentry->d_lock); 792 spin_lock(&dentry->d_lock);
791 if (!list_empty(&dentry->d_subdirs)) { 793 if (!list_empty(&dentry->d_subdirs)) {
792 spin_unlock(&dentry->d_lock); 794 spin_unlock(&dentry->d_lock);
793 spin_unlock(&sbi->lookup_lock); 795 spin_unlock(&sbi->lookup_lock);
794 spin_unlock(&dcache_lock); 796 spin_unlock(&autofs4_lock);
795 return -ENOTEMPTY; 797 return -ENOTEMPTY;
796 } 798 }
797 __autofs4_add_expiring(dentry); 799 __autofs4_add_expiring(dentry);
798 spin_unlock(&sbi->lookup_lock); 800 spin_unlock(&sbi->lookup_lock);
799 __d_drop(dentry); 801 __d_drop(dentry);
800 spin_unlock(&dentry->d_lock); 802 spin_unlock(&dentry->d_lock);
801 spin_unlock(&dcache_lock); 803 spin_unlock(&autofs4_lock);
802 804
803 if (atomic_dec_and_test(&ino->count)) { 805 if (atomic_dec_and_test(&ino->count)) {
804 p_ino = autofs4_dentry_ino(dentry->d_parent); 806 p_ino = autofs4_dentry_ino(dentry->d_parent);
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 4be8f778a418..c5f8459c905e 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -194,14 +194,15 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,
194rename_retry: 194rename_retry:
195 buf = *name; 195 buf = *name;
196 len = 0; 196 len = 0;
197
197 seq = read_seqbegin(&rename_lock); 198 seq = read_seqbegin(&rename_lock);
198 rcu_read_lock(); 199 rcu_read_lock();
199 spin_lock(&dcache_lock); 200 spin_lock(&autofs4_lock);
200 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) 201 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent)
201 len += tmp->d_name.len + 1; 202 len += tmp->d_name.len + 1;
202 203
203 if (!len || --len > NAME_MAX) { 204 if (!len || --len > NAME_MAX) {
204 spin_unlock(&dcache_lock); 205 spin_unlock(&autofs4_lock);
205 rcu_read_unlock(); 206 rcu_read_unlock();
206 if (read_seqretry(&rename_lock, seq)) 207 if (read_seqretry(&rename_lock, seq))
207 goto rename_retry; 208 goto rename_retry;
@@ -217,7 +218,7 @@ rename_retry:
217 p -= tmp->d_name.len; 218 p -= tmp->d_name.len;
218 strncpy(p, tmp->d_name.name, tmp->d_name.len); 219 strncpy(p, tmp->d_name.name, tmp->d_name.len);
219 } 220 }
220 spin_unlock(&dcache_lock); 221 spin_unlock(&autofs4_lock);
221 rcu_read_unlock(); 222 rcu_read_unlock();
222 if (read_seqretry(&rename_lock, seq)) 223 if (read_seqretry(&rename_lock, seq))
223 goto rename_retry; 224 goto rename_retry;