ocfs2: re-order ocfs2_empty_dir checks

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, April 3, 2009 - 5:59 pm

Gitweb:     http://git.kernel.org/linus/b80b549c3520b31d3bbc4b36e37e0a5102da0b94
Commit:     b80b549c3520b31d3bbc4b36e37e0a5102da0b94
Parent:     3a8df2b9c365a9f366b76bbbce479e1cc18ddc16
Author:     Mark Fasheh <mfasheh@suse.com>
AuthorDate: Wed Feb 18 11:41:38 2009 -0800
Committer:  Mark Fasheh <mfasheh@suse.com>
CommitDate: Fri Apr 3 11:39:17 2009 -0700

    ocfs2: re-order ocfs2_empty_dir checks
    
    ocfs2_empty_dir() is far more expensive than checking link count. Since both
    need to be checked at the same time, we can improve performance by checking
    link count first.
    
    Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/namei.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 67113cf..58c318d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -834,10 +834,7 @@ static int ocfs2_unlink(struct inode *dir,
 	child_locked = 1;
 
 	if (S_ISDIR(inode->i_mode)) {
-	       	if (!ocfs2_empty_dir(inode)) {
-			status = -ENOTEMPTY;
-			goto leave;
-		} else if (inode->i_nlink != 2) {
+		if (inode->i_nlink != 2 || !ocfs2_empty_dir(inode)) {
 			status = -ENOTEMPTY;
 			goto leave;
 		}
@@ -1280,8 +1277,8 @@ static int ocfs2_rename(struct inode *old_dir,
 
 	if (target_exists) {
 		if (S_ISDIR(new_inode->i_mode)) {
-			if (!ocfs2_empty_dir(new_inode) ||
-			    new_inode->i_nlink != 2) {
+			if (new_inode->i_nlink != 2 ||
+			    !ocfs2_empty_dir(new_inode)) {
 				status = -ENOTEMPTY;
 				goto bail;
 			}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ocfs2: re-order ocfs2_empty_dir checks, Linux Kernel Mailing ..., (Fri Apr 3, 5:59 pm)