aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2011-03-24 13:51:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-03-24 14:54:35 -0400
commite7854723d0f3626f260c880d8db8e5136f29db19 (patch)
tree3fe4f138922f51d8214ccc6bd2fb9ed4dfa1f234 /fs/autofs4
parent83fb96bfc792e5ca693e53f7fd878d51b8493da8 (diff)
autofs4 - remove autofs4_lock
The autofs4_lock introduced by the rcu-walk changes has unnecessarily broad scope. The locking is better handled by the per-autofs super block lookup_lock. Signed-off-by: Ian Kent <raven@themaw.net> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/autofs4')
-rw-r--r--fs/autofs4/autofs_i.h2
-rw-r--r--fs/autofs4/expire.c18
-rw-r--r--fs/autofs4/root.c25
-rw-r--r--fs/autofs4/waitq.c6
4 files changed, 20 insertions, 31 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 54f923792728..475f9c597cb7 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -61,8 +61,6 @@ do { \
61 current->pid, __func__, ##args); \ 61 current->pid, __func__, ##args); \
62} while (0) 62} while (0)
63 63
64extern spinlock_t autofs4_lock;
65
66/* Unified info structure. This is pointed to by both the dentry and 64/* Unified info structure. This is pointed to by both the dentry and
67 inode structures. Each file in the filesystem has an instance of this 65 inode structures. Each file in the filesystem has an instance of this
68 structure. It holds a reference to the dentry, so dentries are never 66 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 bc482e07b925..450f529a4eae 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -92,10 +92,11 @@ done:
92static struct dentry *get_next_positive_subdir(struct dentry *prev, 92static struct dentry *get_next_positive_subdir(struct dentry *prev,
93 struct dentry *root) 93 struct dentry *root)
94{ 94{
95 struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);
95 struct list_head *next; 96 struct list_head *next;
96 struct dentry *p, *q; 97 struct dentry *p, *q;
97 98
98 spin_lock(&autofs4_lock); 99 spin_lock(&sbi->lookup_lock);
99 100
100 if (prev == NULL) { 101 if (prev == NULL) {
101 spin_lock(&root->d_lock); 102 spin_lock(&root->d_lock);
@@ -112,7 +113,7 @@ again:
112start: 113start:
113 if (next == &root->d_subdirs) { 114 if (next == &root->d_subdirs) {
114 spin_unlock(&p->d_lock); 115 spin_unlock(&p->d_lock);
115 spin_unlock(&autofs4_lock); 116 spin_unlock(&sbi->lookup_lock);
116 dput(prev); 117 dput(prev);
117 return NULL; 118 return NULL;
118 } 119 }
@@ -129,7 +130,7 @@ start:
129 dget_dlock(q); 130 dget_dlock(q);
130 spin_unlock(&q->d_lock); 131 spin_unlock(&q->d_lock);
131 spin_unlock(&p->d_lock); 132 spin_unlock(&p->d_lock);
132 spin_unlock(&autofs4_lock); 133 spin_unlock(&sbi->lookup_lock);
133 134
134 dput(prev); 135 dput(prev);
135 136
@@ -142,13 +143,14 @@ start:
142static struct dentry *get_next_positive_dentry(struct dentry *prev, 143static struct dentry *get_next_positive_dentry(struct dentry *prev,
143 struct dentry *root) 144 struct dentry *root)
144{ 145{
146 struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);
145 struct list_head *next; 147 struct list_head *next;
146 struct dentry *p, *ret; 148 struct dentry *p, *ret;
147 149
148 if (prev == NULL) 150 if (prev == NULL)
149 return dget(root); 151 return dget(root);
150 152
151 spin_lock(&autofs4_lock); 153 spin_lock(&sbi->lookup_lock);
152relock: 154relock:
153 p = prev; 155 p = prev;
154 spin_lock(&p->d_lock); 156 spin_lock(&p->d_lock);
@@ -160,7 +162,7 @@ again:
160 162
161 if (p == root) { 163 if (p == root) {
162 spin_unlock(&p->d_lock); 164 spin_unlock(&p->d_lock);
163 spin_unlock(&autofs4_lock); 165 spin_unlock(&sbi->lookup_lock);
164 dput(prev); 166 dput(prev);
165 return NULL; 167 return NULL;
166 } 168 }
@@ -190,7 +192,7 @@ again:
190 dget_dlock(ret); 192 dget_dlock(ret);
191 spin_unlock(&ret->d_lock); 193 spin_unlock(&ret->d_lock);
192 spin_unlock(&p->d_lock); 194 spin_unlock(&p->d_lock);
193 spin_unlock(&autofs4_lock); 195 spin_unlock(&sbi->lookup_lock);
194 196
195 dput(prev); 197 dput(prev);
196 198
@@ -459,13 +461,13 @@ found:
459 ino->flags |= AUTOFS_INF_EXPIRING; 461 ino->flags |= AUTOFS_INF_EXPIRING;
460 init_completion(&ino->expire_complete); 462 init_completion(&ino->expire_complete);
461 spin_unlock(&sbi->fs_lock); 463 spin_unlock(&sbi->fs_lock);
462 spin_lock(&autofs4_lock); 464 spin_lock(&sbi->lookup_lock);
463 spin_lock(&expired->d_parent->d_lock); 465 spin_lock(&expired->d_parent->d_lock);
464 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); 466 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED);
465 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); 467 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
466 spin_unlock(&expired->d_lock); 468 spin_unlock(&expired->d_lock);
467 spin_unlock(&expired->d_parent->d_lock); 469 spin_unlock(&expired->d_parent->d_lock);
468 spin_unlock(&autofs4_lock); 470 spin_unlock(&sbi->lookup_lock);
469 return expired; 471 return expired;
470} 472}
471 473
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index ebbfa0ce6d7b..96804a17bbd0 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -23,8 +23,6 @@
23 23
24#include "autofs_i.h" 24#include "autofs_i.h"
25 25
26DEFINE_SPINLOCK(autofs4_lock);
27
28static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); 26static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
29static int autofs4_dir_unlink(struct inode *,struct dentry *); 27static int autofs4_dir_unlink(struct inode *,struct dentry *);
30static int autofs4_dir_rmdir(struct inode *,struct dentry *); 28static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -125,15 +123,15 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
125 * autofs file system so just let the libfs routines handle 123 * autofs file system so just let the libfs routines handle
126 * it. 124 * it.
127 */ 125 */
128 spin_lock(&autofs4_lock); 126 spin_lock(&sbi->lookup_lock);
129 spin_lock(&dentry->d_lock); 127 spin_lock(&dentry->d_lock);
130 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 128 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
131 spin_unlock(&dentry->d_lock); 129 spin_unlock(&dentry->d_lock);
132 spin_unlock(&autofs4_lock); 130 spin_unlock(&sbi->lookup_lock);
133 return -ENOENT; 131 return -ENOENT;
134 } 132 }
135 spin_unlock(&dentry->d_lock); 133 spin_unlock(&dentry->d_lock);
136 spin_unlock(&autofs4_lock); 134 spin_unlock(&sbi->lookup_lock);
137 135
138out: 136out:
139 return dcache_dir_open(inode, file); 137 return dcache_dir_open(inode, file);
@@ -171,7 +169,6 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
171 const unsigned char *str = name->name; 169 const unsigned char *str = name->name;
172 struct list_head *p, *head; 170 struct list_head *p, *head;
173 171
174 spin_lock(&autofs4_lock);
175 spin_lock(&sbi->lookup_lock); 172 spin_lock(&sbi->lookup_lock);
176 head = &sbi->active_list; 173 head = &sbi->active_list;
177 list_for_each(p, head) { 174 list_for_each(p, head) {
@@ -204,14 +201,12 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
204 dget_dlock(active); 201 dget_dlock(active);
205 spin_unlock(&active->d_lock); 202 spin_unlock(&active->d_lock);
206 spin_unlock(&sbi->lookup_lock); 203 spin_unlock(&sbi->lookup_lock);
207 spin_unlock(&autofs4_lock);
208 return active; 204 return active;
209 } 205 }
210next: 206next:
211 spin_unlock(&active->d_lock); 207 spin_unlock(&active->d_lock);
212 } 208 }
213 spin_unlock(&sbi->lookup_lock); 209 spin_unlock(&sbi->lookup_lock);
214 spin_unlock(&autofs4_lock);
215 210
216 return NULL; 211 return NULL;
217} 212}
@@ -226,7 +221,6 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
226 const unsigned char *str = name->name; 221 const unsigned char *str = name->name;
227 struct list_head *p, *head; 222 struct list_head *p, *head;
228 223
229 spin_lock(&autofs4_lock);
230 spin_lock(&sbi->lookup_lock); 224 spin_lock(&sbi->lookup_lock);
231 head = &sbi->expiring_list; 225 head = &sbi->expiring_list;
232 list_for_each(p, head) { 226 list_for_each(p, head) {
@@ -259,14 +253,12 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
259 dget_dlock(expiring); 253 dget_dlock(expiring);
260 spin_unlock(&expiring->d_lock); 254 spin_unlock(&expiring->d_lock);
261 spin_unlock(&sbi->lookup_lock); 255 spin_unlock(&sbi->lookup_lock);
262 spin_unlock(&autofs4_lock);
263 return expiring; 256 return expiring;
264 } 257 }
265next: 258next:
266 spin_unlock(&expiring->d_lock); 259 spin_unlock(&expiring->d_lock);
267 } 260 }
268 spin_unlock(&sbi->lookup_lock); 261 spin_unlock(&sbi->lookup_lock);
269 spin_unlock(&autofs4_lock);
270 262
271 return NULL; 263 return NULL;
272} 264}
@@ -603,12 +595,12 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
603 595
604 dir->i_mtime = CURRENT_TIME; 596 dir->i_mtime = CURRENT_TIME;
605 597
606 spin_lock(&autofs4_lock); 598 spin_lock(&sbi->lookup_lock);
607 autofs4_add_expiring(dentry); 599 __autofs4_add_expiring(dentry);
608 spin_lock(&dentry->d_lock); 600 spin_lock(&dentry->d_lock);
609 __d_drop(dentry); 601 __d_drop(dentry);
610 spin_unlock(&dentry->d_lock); 602 spin_unlock(&dentry->d_lock);
611 spin_unlock(&autofs4_lock); 603 spin_unlock(&sbi->lookup_lock);
612 604
613 return 0; 605 return 0;
614} 606}
@@ -677,20 +669,17 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
677 if (!autofs4_oz_mode(sbi)) 669 if (!autofs4_oz_mode(sbi))
678 return -EACCES; 670 return -EACCES;
679 671
680 spin_lock(&autofs4_lock);
681 spin_lock(&sbi->lookup_lock); 672 spin_lock(&sbi->lookup_lock);
682 spin_lock(&dentry->d_lock); 673 spin_lock(&dentry->d_lock);
683 if (!list_empty(&dentry->d_subdirs)) { 674 if (!list_empty(&dentry->d_subdirs)) {
684 spin_unlock(&dentry->d_lock); 675 spin_unlock(&dentry->d_lock);
685 spin_unlock(&sbi->lookup_lock); 676 spin_unlock(&sbi->lookup_lock);
686 spin_unlock(&autofs4_lock);
687 return -ENOTEMPTY; 677 return -ENOTEMPTY;
688 } 678 }
689 __autofs4_add_expiring(dentry); 679 __autofs4_add_expiring(dentry);
690 spin_unlock(&sbi->lookup_lock);
691 __d_drop(dentry); 680 __d_drop(dentry);
692 spin_unlock(&dentry->d_lock); 681 spin_unlock(&dentry->d_lock);
693 spin_unlock(&autofs4_lock); 682 spin_unlock(&sbi->lookup_lock);
694 683
695 if (sbi->version < 5) 684 if (sbi->version < 5)
696 autofs_clear_leaf_automount_flags(dentry); 685 autofs_clear_leaf_automount_flags(dentry);
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 56010056b2e6..25435987d6ae 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -197,12 +197,12 @@ rename_retry:
197 197
198 seq = read_seqbegin(&rename_lock); 198 seq = read_seqbegin(&rename_lock);
199 rcu_read_lock(); 199 rcu_read_lock();
200 spin_lock(&autofs4_lock); 200 spin_lock(&sbi->fs_lock);
201 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) 201 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent)
202 len += tmp->d_name.len + 1; 202 len += tmp->d_name.len + 1;
203 203
204 if (!len || --len > NAME_MAX) { 204 if (!len || --len > NAME_MAX) {
205 spin_unlock(&autofs4_lock); 205 spin_unlock(&sbi->fs_lock);
206 rcu_read_unlock(); 206 rcu_read_unlock();
207 if (read_seqretry(&rename_lock, seq)) 207 if (read_seqretry(&rename_lock, seq))
208 goto rename_retry; 208 goto rename_retry;
@@ -218,7 +218,7 @@ rename_retry:
218 p -= tmp->d_name.len; 218 p -= tmp->d_name.len;
219 strncpy(p, tmp->d_name.name, tmp->d_name.len); 219 strncpy(p, tmp->d_name.name, tmp->d_name.len);
220 } 220 }
221 spin_unlock(&autofs4_lock); 221 spin_unlock(&sbi->fs_lock);
222 rcu_read_unlock(); 222 rcu_read_unlock();
223 if (read_seqretry(&rename_lock, seq)) 223 if (read_seqretry(&rename_lock, seq))
224 goto rename_retry; 224 goto rename_retry;