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>

authored by Ian Kent and committed by Al Viro e7854723 83fb96bf

+20 -31
-2
fs/autofs4/autofs_i.h
··· 61 61 current->pid, __func__, ##args); \ 62 62 } while (0) 63 63 64 - extern spinlock_t autofs4_lock; 65 - 66 64 /* Unified info structure. This is pointed to by both the dentry and 67 65 inode structures. Each file in the filesystem has an instance of this 68 66 structure. It holds a reference to the dentry, so dentries are never
+10 -8
fs/autofs4/expire.c
··· 92 92 static struct dentry *get_next_positive_subdir(struct dentry *prev, 93 93 struct dentry *root) 94 94 { 95 + struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb); 95 96 struct list_head *next; 96 97 struct dentry *p, *q; 97 98 98 - spin_lock(&autofs4_lock); 99 + spin_lock(&sbi->lookup_lock); 99 100 100 101 if (prev == NULL) { 101 102 spin_lock(&root->d_lock); ··· 113 112 start: 114 113 if (next == &root->d_subdirs) { 115 114 spin_unlock(&p->d_lock); 116 - spin_unlock(&autofs4_lock); 115 + spin_unlock(&sbi->lookup_lock); 117 116 dput(prev); 118 117 return NULL; 119 118 } ··· 130 129 dget_dlock(q); 131 130 spin_unlock(&q->d_lock); 132 131 spin_unlock(&p->d_lock); 133 - spin_unlock(&autofs4_lock); 132 + spin_unlock(&sbi->lookup_lock); 134 133 135 134 dput(prev); 136 135 ··· 143 142 static struct dentry *get_next_positive_dentry(struct dentry *prev, 144 143 struct dentry *root) 145 144 { 145 + struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb); 146 146 struct list_head *next; 147 147 struct dentry *p, *ret; 148 148 149 149 if (prev == NULL) 150 150 return dget(root); 151 151 152 - spin_lock(&autofs4_lock); 152 + spin_lock(&sbi->lookup_lock); 153 153 relock: 154 154 p = prev; 155 155 spin_lock(&p->d_lock); ··· 162 160 163 161 if (p == root) { 164 162 spin_unlock(&p->d_lock); 165 - spin_unlock(&autofs4_lock); 163 + spin_unlock(&sbi->lookup_lock); 166 164 dput(prev); 167 165 return NULL; 168 166 } ··· 192 190 dget_dlock(ret); 193 191 spin_unlock(&ret->d_lock); 194 192 spin_unlock(&p->d_lock); 195 - spin_unlock(&autofs4_lock); 193 + spin_unlock(&sbi->lookup_lock); 196 194 197 195 dput(prev); 198 196 ··· 461 459 ino->flags |= AUTOFS_INF_EXPIRING; 462 460 init_completion(&ino->expire_complete); 463 461 spin_unlock(&sbi->fs_lock); 464 - spin_lock(&autofs4_lock); 462 + spin_lock(&sbi->lookup_lock); 465 463 spin_lock(&expired->d_parent->d_lock); 466 464 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); 467 465 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); 468 466 spin_unlock(&expired->d_lock); 469 467 spin_unlock(&expired->d_parent->d_lock); 470 - spin_unlock(&autofs4_lock); 468 + spin_unlock(&sbi->lookup_lock); 471 469 return expired; 472 470 } 473 471
+7 -18
fs/autofs4/root.c
··· 23 23 24 24 #include "autofs_i.h" 25 25 26 - DEFINE_SPINLOCK(autofs4_lock); 27 - 28 26 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); 29 27 static int autofs4_dir_unlink(struct inode *,struct dentry *); 30 28 static int autofs4_dir_rmdir(struct inode *,struct dentry *); ··· 123 125 * autofs file system so just let the libfs routines handle 124 126 * it. 125 127 */ 126 - spin_lock(&autofs4_lock); 128 + spin_lock(&sbi->lookup_lock); 127 129 spin_lock(&dentry->d_lock); 128 130 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { 129 131 spin_unlock(&dentry->d_lock); 130 - spin_unlock(&autofs4_lock); 132 + spin_unlock(&sbi->lookup_lock); 131 133 return -ENOENT; 132 134 } 133 135 spin_unlock(&dentry->d_lock); 134 - spin_unlock(&autofs4_lock); 136 + spin_unlock(&sbi->lookup_lock); 135 137 136 138 out: 137 139 return dcache_dir_open(inode, file); ··· 169 171 const unsigned char *str = name->name; 170 172 struct list_head *p, *head; 171 173 172 - spin_lock(&autofs4_lock); 173 174 spin_lock(&sbi->lookup_lock); 174 175 head = &sbi->active_list; 175 176 list_for_each(p, head) { ··· 201 204 dget_dlock(active); 202 205 spin_unlock(&active->d_lock); 203 206 spin_unlock(&sbi->lookup_lock); 204 - spin_unlock(&autofs4_lock); 205 207 return active; 206 208 } 207 209 next: 208 210 spin_unlock(&active->d_lock); 209 211 } 210 212 spin_unlock(&sbi->lookup_lock); 211 - spin_unlock(&autofs4_lock); 212 213 213 214 return NULL; 214 215 } ··· 221 226 const unsigned char *str = name->name; 222 227 struct list_head *p, *head; 223 228 224 - spin_lock(&autofs4_lock); 225 229 spin_lock(&sbi->lookup_lock); 226 230 head = &sbi->expiring_list; 227 231 list_for_each(p, head) { ··· 253 259 dget_dlock(expiring); 254 260 spin_unlock(&expiring->d_lock); 255 261 spin_unlock(&sbi->lookup_lock); 256 - spin_unlock(&autofs4_lock); 257 262 return expiring; 258 263 } 259 264 next: 260 265 spin_unlock(&expiring->d_lock); 261 266 } 262 267 spin_unlock(&sbi->lookup_lock); 263 - spin_unlock(&autofs4_lock); 264 268 265 269 return NULL; 266 270 } ··· 595 603 596 604 dir->i_mtime = CURRENT_TIME; 597 605 598 - spin_lock(&autofs4_lock); 599 - autofs4_add_expiring(dentry); 606 + spin_lock(&sbi->lookup_lock); 607 + __autofs4_add_expiring(dentry); 600 608 spin_lock(&dentry->d_lock); 601 609 __d_drop(dentry); 602 610 spin_unlock(&dentry->d_lock); 603 - spin_unlock(&autofs4_lock); 611 + spin_unlock(&sbi->lookup_lock); 604 612 605 613 return 0; 606 614 } ··· 669 677 if (!autofs4_oz_mode(sbi)) 670 678 return -EACCES; 671 679 672 - spin_lock(&autofs4_lock); 673 680 spin_lock(&sbi->lookup_lock); 674 681 spin_lock(&dentry->d_lock); 675 682 if (!list_empty(&dentry->d_subdirs)) { 676 683 spin_unlock(&dentry->d_lock); 677 684 spin_unlock(&sbi->lookup_lock); 678 - spin_unlock(&autofs4_lock); 679 685 return -ENOTEMPTY; 680 686 } 681 687 __autofs4_add_expiring(dentry); 682 - spin_unlock(&sbi->lookup_lock); 683 688 __d_drop(dentry); 684 689 spin_unlock(&dentry->d_lock); 685 - spin_unlock(&autofs4_lock); 690 + spin_unlock(&sbi->lookup_lock); 686 691 687 692 if (sbi->version < 5) 688 693 autofs_clear_leaf_automount_flags(dentry);
+3 -3
fs/autofs4/waitq.c
··· 197 197 198 198 seq = read_seqbegin(&rename_lock); 199 199 rcu_read_lock(); 200 - spin_lock(&autofs4_lock); 200 + spin_lock(&sbi->fs_lock); 201 201 for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent) 202 202 len += tmp->d_name.len + 1; 203 203 204 204 if (!len || --len > NAME_MAX) { 205 - spin_unlock(&autofs4_lock); 205 + spin_unlock(&sbi->fs_lock); 206 206 rcu_read_unlock(); 207 207 if (read_seqretry(&rename_lock, seq)) 208 208 goto rename_retry; ··· 218 218 p -= tmp->d_name.len; 219 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 222 rcu_read_unlock(); 223 223 if (read_seqretry(&rename_lock, seq)) 224 224 goto rename_retry;