All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sage Weil <sage@newdream.net>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, hch@lst.de, Sage Weil <sage@newdream.net>
Subject: [PATCH 02/19] vfs: remove dget() from dentry_unhash()
Date: Tue, 24 May 2011 13:06:05 -0700	[thread overview]
Message-ID: <1306267582-5347-3-git-send-email-sage@newdream.net> (raw)
In-Reply-To: <1306267582-5347-1-git-send-email-sage@newdream.net>

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 <sage@newdream.net>
---
 fs/hpfs/namei.c     |    3 ---
 fs/namei.c          |    5 +----
 fs/reiserfs/xattr.c |    1 -
 3 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 1f05839..0f89a64 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -395,7 +395,6 @@ again:
 
 		dentry_unhash(dentry);
 		if (!d_unhashed(dentry)) {
-			dput(dentry);
 			hpfs_unlock(dir->i_sb);
 			return -ENOSPC;
 		}
@@ -403,7 +402,6 @@ again:
 		    !S_ISREG(inode->i_mode) ||
 		    get_write_access(inode)) {
 			d_rehash(dentry);
-			dput(dentry);
 		} else {
 			struct iattr newattrs;
 			/*printk("HPFS: truncating file before delete.\n");*/
@@ -411,7 +409,6 @@ again:
 			newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
 			err = notify_change(dentry, &newattrs);
 			put_write_access(inode);
-			dput(dentry);
 			if (!err)
 				goto again;
 		}
diff --git a/fs/namei.c b/fs/namei.c
index 1df3361..4866bff 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2645,10 +2645,9 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, int, mode)
  */
 void dentry_unhash(struct dentry *dentry)
 {
-	dget(dentry);
 	shrink_dcache_parent(dentry);
 	spin_lock(&dentry->d_lock);
-	if (dentry->d_count == 2)
+	if (dentry->d_count == 1)
 		__d_drop(dentry);
 	spin_unlock(&dentry->d_lock);
 }
@@ -2675,7 +2674,6 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
 				dentry->d_inode->i_flags |= S_DEAD;
 				dont_mount(dentry);
 			}
-			dput(dentry);
 		}
 	}
 	mutex_unlock(&dentry->d_inode->i_mutex);
@@ -3102,7 +3100,6 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
 		mutex_unlock(&target->i_mutex);
 		if (d_unhashed(new_dentry))
 			d_rehash(new_dentry);
-		dput(new_dentry);
 	}
 	if (!error)
 		if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE))
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 47d2a44..50f1abc 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -105,7 +105,6 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
 	mutex_unlock(&dentry->d_inode->i_mutex);
 	if (!error)
 		d_delete(dentry);
-	dput(dentry);
 
 	return error;
 }
-- 
1.7.0


  parent reply	other threads:[~2011-05-24 19:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24 20:06 [PATCH 00/19] Do not dentry_unhash in VFS (v3) Sage Weil
2011-05-24 20:06 ` [PATCH 01/19] vfs: dentry_unhash immediately prior to rmdir Sage Weil
2011-05-24 20:06 ` Sage Weil [this message]
2011-05-24 20:06 ` [PATCH 03/19] vfs: push dentry_unhash on rmdir into file systems Sage Weil
2011-05-24 20:06 ` [PATCH 04/19] vfs: push dentry_unhash on rename_dir " Sage Weil
2011-05-24 20:06 ` [PATCH 05/19] vfs: update dentry_unhash() comment Sage Weil
2011-05-24 20:06 ` [PATCH 06/19] libfs: drop unneeded dentry_unhash Sage Weil
2011-05-24 20:06 ` [PATCH 07/19] vfs: fix vfs_rename_dir for FS_RENAME_DOES_D_MOVE filesystems Sage Weil
2011-05-24 20:06 ` [PATCH 08/19] vfs: clean up vfs_rmdir Sage Weil
2011-05-24 20:06 ` [PATCH 09/19] vfs: clean up vfs_rename_dir Sage Weil
2011-05-24 20:06 ` [PATCH 10/19] vfs: clean up vfs_rename_other Sage Weil
2011-05-24 20:06 ` [PATCH 11/19] ceph: remove unnecessary dentry_unhash calls Sage Weil
2011-05-24 20:06 ` [PATCH 12/19] btrfs: remove unnecessary dentry_unhash in rmdir/rename_dir Sage Weil
2011-05-24 20:06 ` [PATCH 13/19] ext4: remove unnecessary dentry_unhash on rmdir/rename_dir Sage Weil
2011-05-24 20:06 ` [PATCH 14/19] ext3: " Sage Weil
2011-05-24 20:38   ` Jan Kara
2011-05-24 23:57     ` Sage Weil
2011-05-25  2:44   ` Yongqiang Yang
2011-05-25  3:44     ` Sage Weil
2011-05-24 20:06 ` [PATCH 15/19] ext2: " Sage Weil
     [not found] ` <1306267582-5347-1-git-send-email-sage-BnTBU8nroG7k1uMJSBkQmQ@public.gmane.org>
2011-05-24 20:06   ` [PATCH 16/19] nfs: " Sage Weil
2011-05-24 20:06     ` Sage Weil
2011-05-24 20:06 ` [PATCH 17/19] exofs: " Sage Weil
2011-05-24 20:06 ` [PATCH 18/19] ocfs2: " Sage Weil
2011-05-24 20:06   ` [Ocfs2-devel] " Sage Weil
2011-05-24 20:06 ` [PATCH 19/19] cifs: " Sage Weil
2011-05-27  9:46 ` [PATCH 00/19] Do not dentry_unhash in VFS (v3) Christoph Hellwig
2011-05-27 14:15   ` Jan Kara
2011-05-27 19:11   ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306267582-5347-3-git-send-email-sage@newdream.net \
    --to=sage@newdream.net \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.