aboutsummaryrefslogtreecommitdiff
path: root/fs/autofs/root.c
diff options
context:
space:
mode:
authorLinus Torvalds <[email protected]>2019-09-19 10:14:22 -0700
committerLinus Torvalds <[email protected]>2019-09-19 10:14:22 -0700
commit8e6ee05d8aa9c802d999c79aa22f3f6ca92d7d27 (patch)
tree739d2f62c631b31ceb4ec85f2e30f9bbe644d17d /fs/autofs/root.c
parentbc7d9aee3f3ce0c0633c20ea55b81efb3ca7984d (diff)
parent5f68056ca50fdd3954a93ae66fea7452abddb66f (diff)
Merge branch 'work.autofs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull autofs updates from Al Viro: "The most interesting part here is getting rid of the last trylock loop on dentry->d_lock. The ones in fs/dcache.c had been dealt with several years ago, but there'd been leftovers in fs/autofs/expire.c" * 'work.autofs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: autofs_lookup(): hold ->d_lock over playing with ->d_flags get rid of autofs_info->active_count autofs: simplify get_next_positive_...(), get rid of trylocks
Diffstat (limited to 'fs/autofs/root.c')
-rw-r--r--fs/autofs/root.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index e646569c75ed..29abafc0ce31 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -60,38 +60,15 @@ const struct dentry_operations autofs_dentry_operations = {
.d_release = autofs_dentry_release,
};
-static void autofs_add_active(struct dentry *dentry)
-{
- struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
- struct autofs_info *ino;
-
- ino = autofs_dentry_ino(dentry);
- if (ino) {
- spin_lock(&sbi->lookup_lock);
- if (!ino->active_count) {
- if (list_empty(&ino->active))
- list_add(&ino->active, &sbi->active_list);
- }
- ino->active_count++;
- spin_unlock(&sbi->lookup_lock);
- }
-}
-
static void autofs_del_active(struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
struct autofs_info *ino;
ino = autofs_dentry_ino(dentry);
- if (ino) {
- spin_lock(&sbi->lookup_lock);
- ino->active_count--;
- if (!ino->active_count) {
- if (!list_empty(&ino->active))
- list_del_init(&ino->active);
- }
- spin_unlock(&sbi->lookup_lock);
- }
+ spin_lock(&sbi->lookup_lock);
+ list_del_init(&ino->active);
+ spin_unlock(&sbi->lookup_lock);
}
static int autofs_dir_open(struct inode *inode, struct file *file)
@@ -527,19 +504,22 @@ static struct dentry *autofs_lookup(struct inode *dir,
if (!autofs_oz_mode(sbi) && !IS_ROOT(dentry->d_parent))
return ERR_PTR(-ENOENT);
- /* Mark entries in the root as mount triggers */
- if (IS_ROOT(dentry->d_parent) &&
- autofs_type_indirect(sbi->type))
- __managed_dentry_set_managed(dentry);
-
ino = autofs_new_ino(sbi);
if (!ino)
return ERR_PTR(-ENOMEM);
+ spin_lock(&sbi->lookup_lock);
+ spin_lock(&dentry->d_lock);
+ /* Mark entries in the root as mount triggers */
+ if (IS_ROOT(dentry->d_parent) &&
+ autofs_type_indirect(sbi->type))
+ __managed_dentry_set_managed(dentry);
dentry->d_fsdata = ino;
ino->dentry = dentry;
- autofs_add_active(dentry);
+ list_add(&ino->active, &sbi->active_list);
+ spin_unlock(&sbi->lookup_lock);
+ spin_unlock(&dentry->d_lock);
}
return NULL;
}