From 41ca19740a0e772eff1f9ba67293649feb836662 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 17 Sep 2019 23:23:08 -0400 Subject: autofs: get rid of pointless checks around ->count handling * 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 --- fs/autofs/root.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'fs/autofs') diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 2065281ee8b1..7806b110e79d 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c @@ -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); -- cgit v1.2.3