Skip to content

Commit 64252c7

Browse files
liewegasAl Viro
authored andcommitted
vfs: remove dget() from dentry_unhash()
This serves no useful purpose that I can discern. All callers (rename, rmdir) hold their own reference to the dentry. A quick audit of all file systems showed no relevant checks on the value of d_count in vfs_rmdir/vfs_rename_dir paths. Signed-off-by: Sage Weil <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 4829369 commit 64252c7

File tree

3 files changed

+1
-8
lines changed

3 files changed

+1
-8
lines changed

fs/hpfs/namei.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,23 +414,20 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
414414
mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
415415
dentry_unhash(dentry);
416416
if (!d_unhashed(dentry)) {
417-
dput(dentry);
418417
hpfs_unlock(dir->i_sb);
419418
return -ENOSPC;
420419
}
421420
if (generic_permission(inode, MAY_WRITE, 0, NULL) ||
422421
!S_ISREG(inode->i_mode) ||
423422
get_write_access(inode)) {
424423
d_rehash(dentry);
425-
dput(dentry);
426424
} else {
427425
struct iattr newattrs;
428426
/*printk("HPFS: truncating file before delete.\n");*/
429427
newattrs.ia_size = 0;
430428
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
431429
err = notify_change(dentry, &newattrs);
432430
put_write_access(inode);
433-
dput(dentry);
434431
if (!err)
435432
goto again;
436433
}

fs/namei.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,10 +2545,9 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, int, mode)
25452545
*/
25462546
void dentry_unhash(struct dentry *dentry)
25472547
{
2548-
dget(dentry);
25492548
shrink_dcache_parent(dentry);
25502549
spin_lock(&dentry->d_lock);
2551-
if (dentry->d_count == 2)
2550+
if (dentry->d_count == 1)
25522551
__d_drop(dentry);
25532552
spin_unlock(&dentry->d_lock);
25542553
}
@@ -2575,7 +2574,6 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
25752574
dentry->d_inode->i_flags |= S_DEAD;
25762575
dont_mount(dentry);
25772576
}
2578-
dput(dentry);
25792577
}
25802578
}
25812579
mutex_unlock(&dentry->d_inode->i_mutex);
@@ -3002,7 +3000,6 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
30023000
mutex_unlock(&target->i_mutex);
30033001
if (d_unhashed(new_dentry))
30043002
d_rehash(new_dentry);
3005-
dput(new_dentry);
30063003
}
30073004
if (!error)
30083005
if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE))

fs/reiserfs/xattr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
105105
mutex_unlock(&dentry->d_inode->i_mutex);
106106
if (!error)
107107
d_delete(dentry);
108-
dput(dentry);
109108

110109
return error;
111110
}

0 commit comments

Comments
 (0)