Skip to content

Commit

Permalink
get rid of autofs_info->active_count
Browse files Browse the repository at this point in the history
autofs_add_active() is always called only once (and on a dentry
with freshly allocated ino, at that).  autofs_del_active() is
never called more than once.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 27, 2019
1 parent ff09297 commit c4931db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
1 change: 0 additions & 1 deletion fs/autofs/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ struct autofs_info {
struct completion expire_complete;

struct list_head active;
int active_count;

struct list_head expiring;

Expand Down
33 changes: 6 additions & 27 deletions fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -539,7 +516,9 @@ static struct dentry *autofs_lookup(struct inode *dir,
dentry->d_fsdata = ino;
ino->dentry = dentry;

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

0 comments on commit c4931db

Please sign in to comment.