Skip to content

Commit

Permalink
autofs: get rid of pointless checks around ->count handling
Browse files Browse the repository at this point in the history
* IS_ROOT can't be true for unlink or rmdir victim
* any positive autofs dentry has non-NULL autofs_dentry_ino()
* autofs symlink can't have ->count other than 1
* autofs empty directory can't have ->count other than 1

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Sep 18, 2019
1 parent e509d6e commit 41ca197
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,7 @@ static int autofs_dir_symlink(struct inode *dir,
dget(dentry);
atomic_inc(&ino->count);
p_ino = autofs_dentry_ino(dentry->d_parent);
if (p_ino && !IS_ROOT(dentry))
atomic_inc(&p_ino->count);
atomic_inc(&p_ino->count);

dir->i_mtime = current_time(dir);

Expand Down Expand Up @@ -610,11 +609,9 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
if (sbi->flags & AUTOFS_SBI_CATATONIC)
return -EACCES;

if (atomic_dec_and_test(&ino->count)) {
p_ino = autofs_dentry_ino(dentry->d_parent);
if (p_ino && !IS_ROOT(dentry))
atomic_dec(&p_ino->count);
}
atomic_dec(&ino->count);
p_ino = autofs_dentry_ino(dentry->d_parent);
atomic_dec(&p_ino->count);
dput(ino->dentry);

d_inode(dentry)->i_size = 0;
Expand Down Expand Up @@ -706,11 +703,9 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
if (sbi->version < 5)
autofs_clear_leaf_automount_flags(dentry);

if (atomic_dec_and_test(&ino->count)) {
p_ino = autofs_dentry_ino(dentry->d_parent);
if (p_ino && dentry->d_parent != dentry)
atomic_dec(&p_ino->count);
}
atomic_dec(&ino->count);
p_ino = autofs_dentry_ino(dentry->d_parent);
atomic_dec(&p_ino->count);
dput(ino->dentry);
d_inode(dentry)->i_size = 0;
clear_nlink(d_inode(dentry));
Expand Down Expand Up @@ -758,8 +753,7 @@ static int autofs_dir_mkdir(struct inode *dir,
dget(dentry);
atomic_inc(&ino->count);
p_ino = autofs_dentry_ino(dentry->d_parent);
if (p_ino && !IS_ROOT(dentry))
atomic_inc(&p_ino->count);
atomic_inc(&p_ino->count);
inc_nlink(dir);
dir->i_mtime = current_time(dir);

Expand Down

0 comments on commit 41ca197

Please sign in to comment.