autofs: get rid of pointless checks around ->count handling
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 18 Sep 2019 03:23:08 +0000 (23:23 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 18 Sep 2019 03:23:08 +0000 (23:23 -0400)
* 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 <viro@zeniv.linux.org.uk>
fs/autofs/root.c

index 2065281..7806b11 100644 (file)
@@ -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);
 
@@ -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;
@@ -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));
@@ -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);