Skip to content

Commit

Permalink
ocfs2: re-order ocfs2_empty_dir checks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Fasheh committed Apr 3, 2009
1 parent 3a8df2b commit b80b549
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b80b549

Please sign in to comment.