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