Skip to content

Commit

Permalink
autofs_lookup(): hold ->d_lock over playing with ->d_flags
Browse files Browse the repository at this point in the history
... as well as setting ->d_fsdata, etc.  Make all of that
atomic.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 27, 2019
1 parent c4931db commit 5f68056
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,21 +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;

spin_lock(&sbi->lookup_lock);
list_add(&ino->active, &sbi->active_list);
spin_unlock(&sbi->lookup_lock);
spin_unlock(&dentry->d_lock);
}
return NULL;
}
Expand Down

0 comments on commit 5f68056

Please sign in to comment.