Commit 4f8427d1 authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

autofs4: use helper functions for active list handling

Define some simple helper functions for adding and deleting entries on the
active (and unhashed) dentry list.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Sage Weil <sage@newdream.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andreas Dilger <adilger@sun.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Yehuda Saheh <yehuda@newdream.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9ea9a886
...@@ -75,6 +75,8 @@ struct autofs_info { ...@@ -75,6 +75,8 @@ struct autofs_info {
struct completion expire_complete; struct completion expire_complete;
struct list_head active; struct list_head active;
int active_count;
struct list_head expiring; struct list_head expiring;
struct autofs_sb_info *sbi; struct autofs_sb_info *sbi;
......
...@@ -49,6 +49,7 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino, ...@@ -49,6 +49,7 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
ino->dentry = NULL; ino->dentry = NULL;
ino->size = 0; ino->size = 0;
INIT_LIST_HEAD(&ino->active); INIT_LIST_HEAD(&ino->active);
ino->active_count = 0;
INIT_LIST_HEAD(&ino->expiring); INIT_LIST_HEAD(&ino->expiring);
atomic_set(&ino->count, 0); atomic_set(&ino->count, 0);
} }
......
...@@ -72,6 +72,38 @@ const struct inode_operations autofs4_dir_inode_operations = { ...@@ -72,6 +72,38 @@ const struct inode_operations autofs4_dir_inode_operations = {
.rmdir = autofs4_dir_rmdir, .rmdir = autofs4_dir_rmdir,
}; };
static void autofs4_add_active(struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_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);
}
return;
}
static void autofs4_del_active(struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_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);
}
return;
}
static int autofs4_dir_open(struct inode *inode, struct file *file) static int autofs4_dir_open(struct inode *inode, struct file *file)
{ {
struct dentry *dentry = file->f_path.dentry; struct dentry *dentry = file->f_path.dentry;
...@@ -513,9 +545,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s ...@@ -513,9 +545,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
dentry->d_fsdata = ino; dentry->d_fsdata = ino;
ino->dentry = dentry; ino->dentry = dentry;
spin_lock(&sbi->lookup_lock); autofs4_add_active(dentry);
list_add(&ino->active, &sbi->active_list);
spin_unlock(&sbi->lookup_lock);
d_instantiate(dentry, NULL); d_instantiate(dentry, NULL);
} }
...@@ -624,10 +654,7 @@ static int autofs4_dir_symlink(struct inode *dir, ...@@ -624,10 +654,7 @@ static int autofs4_dir_symlink(struct inode *dir,
if (!ino) if (!ino)
return -ENOMEM; return -ENOMEM;
spin_lock(&sbi->lookup_lock); autofs4_del_active(dentry);
if (!list_empty(&ino->active))
list_del_init(&ino->active);
spin_unlock(&sbi->lookup_lock);
ino->size = strlen(symname); ino->size = strlen(symname);
cp = kmalloc(ino->size + 1, GFP_KERNEL); cp = kmalloc(ino->size + 1, GFP_KERNEL);
...@@ -775,10 +802,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -775,10 +802,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (!ino) if (!ino)
return -ENOMEM; return -ENOMEM;
spin_lock(&sbi->lookup_lock); autofs4_del_active(dentry);
if (!list_empty(&ino->active))
list_del_init(&ino->active);
spin_unlock(&sbi->lookup_lock);
inode = autofs4_get_inode(dir->i_sb, ino); inode = autofs4_get_inode(dir->i_sb, ino);
if (!inode) { if (!inode) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment