Skip to content

Commit

Permalink
autofs4 - remove autofs4_lock
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
raven-au authored and Al Viro committed Mar 24, 2011
1 parent 83fb96b commit e785472
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
2 changes: 0 additions & 2 deletions fs/autofs4/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ do { \
current->pid, __func__, ##args); \
} while (0)

extern spinlock_t autofs4_lock;

/* Unified info structure. This is pointed to by both the dentry and
inode structures. Each file in the filesystem has an instance of this
structure. It holds a reference to the dentry, so dentries are never
Expand Down
18 changes: 10 additions & 8 deletions fs/autofs4/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
static struct dentry *get_next_positive_subdir(struct dentry *prev,
struct dentry *root)
{
struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);
struct list_head *next;
struct dentry *p, *q;

spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);

if (prev == NULL) {
spin_lock(&root->d_lock);
Expand All @@ -112,7 +113,7 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
start:
if (next == &root->d_subdirs) {
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);
dput(prev);
return NULL;
}
Expand All @@ -129,7 +130,7 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
dget_dlock(q);
spin_unlock(&q->d_lock);
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);

dput(prev);

Expand All @@ -142,13 +143,14 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
static struct dentry *get_next_positive_dentry(struct dentry *prev,
struct dentry *root)
{
struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);
struct list_head *next;
struct dentry *p, *ret;

if (prev == NULL)
return dget(root);

spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
relock:
p = prev;
spin_lock(&p->d_lock);
Expand All @@ -160,7 +162,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,

if (p == root) {
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);
dput(prev);
return NULL;
}
Expand Down Expand Up @@ -190,7 +192,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
dget_dlock(ret);
spin_unlock(&ret->d_lock);
spin_unlock(&p->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);

dput(prev);

Expand Down Expand Up @@ -459,13 +461,13 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
ino->flags |= AUTOFS_INF_EXPIRING;
init_completion(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
spin_lock(&expired->d_parent->d_lock);
spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED);
list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
spin_unlock(&expired->d_lock);
spin_unlock(&expired->d_parent->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);
return expired;
}

Expand Down
25 changes: 7 additions & 18 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "autofs_i.h"

DEFINE_SPINLOCK(autofs4_lock);

static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
static int autofs4_dir_unlink(struct inode *,struct dentry *);
static int autofs4_dir_rmdir(struct inode *,struct dentry *);
Expand Down Expand Up @@ -125,15 +123,15 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
* autofs file system so just let the libfs routines handle
* it.
*/
spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
spin_lock(&dentry->d_lock);
if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
spin_unlock(&dentry->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);
return -ENOENT;
}
spin_unlock(&dentry->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);

out:
return dcache_dir_open(inode, file);
Expand Down Expand Up @@ -171,7 +169,6 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
const unsigned char *str = name->name;
struct list_head *p, *head;

spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
head = &sbi->active_list;
list_for_each(p, head) {
Expand Down Expand Up @@ -204,14 +201,12 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
dget_dlock(active);
spin_unlock(&active->d_lock);
spin_unlock(&sbi->lookup_lock);
spin_unlock(&autofs4_lock);
return active;
}
next:
spin_unlock(&active->d_lock);
}
spin_unlock(&sbi->lookup_lock);
spin_unlock(&autofs4_lock);

return NULL;
}
Expand All @@ -226,7 +221,6 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
const unsigned char *str = name->name;
struct list_head *p, *head;

spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
head = &sbi->expiring_list;
list_for_each(p, head) {
Expand Down Expand Up @@ -259,14 +253,12 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
dget_dlock(expiring);
spin_unlock(&expiring->d_lock);
spin_unlock(&sbi->lookup_lock);
spin_unlock(&autofs4_lock);
return expiring;
}
next:
spin_unlock(&expiring->d_lock);
}
spin_unlock(&sbi->lookup_lock);
spin_unlock(&autofs4_lock);

return NULL;
}
Expand Down Expand Up @@ -603,12 +595,12 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)

dir->i_mtime = CURRENT_TIME;

spin_lock(&autofs4_lock);
autofs4_add_expiring(dentry);
spin_lock(&sbi->lookup_lock);
__autofs4_add_expiring(dentry);
spin_lock(&dentry->d_lock);
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);

return 0;
}
Expand Down Expand Up @@ -677,20 +669,17 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
if (!autofs4_oz_mode(sbi))
return -EACCES;

spin_lock(&autofs4_lock);
spin_lock(&sbi->lookup_lock);
spin_lock(&dentry->d_lock);
if (!list_empty(&dentry->d_subdirs)) {
spin_unlock(&dentry->d_lock);
spin_unlock(&sbi->lookup_lock);
spin_unlock(&autofs4_lock);
return -ENOTEMPTY;
}
__autofs4_add_expiring(dentry);
spin_unlock(&sbi->lookup_lock);
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->lookup_lock);

if (sbi->version < 5)
autofs_clear_leaf_automount_flags(dentry);
Expand Down
6 changes: 3 additions & 3 deletions fs/autofs4/waitq.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,

seq = read_seqbegin(&rename_lock);
rcu_read_lock();
spin_lock(&autofs4_lock);
spin_lock(&sbi->fs_lock);
for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent)
len += tmp->d_name.len + 1;

if (!len || --len > NAME_MAX) {
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->fs_lock);
rcu_read_unlock();
if (read_seqretry(&rename_lock, seq))
goto rename_retry;
Expand All @@ -218,7 +218,7 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,
p -= tmp->d_name.len;
strncpy(p, tmp->d_name.name, tmp->d_name.len);
}
spin_unlock(&autofs4_lock);
spin_unlock(&sbi->fs_lock);
rcu_read_unlock();
if (read_seqretry(&rename_lock, seq))
goto rename_retry;
Expand Down

0 comments on commit e785472

Please sign in to comment.