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>
This commit is contained in:
parent
3a8df2b9c3
commit
b80b549c35
1 changed files with 3 additions and 6 deletions
|
@ -834,10 +834,7 @@ static int ocfs2_unlink(struct inode *dir,
|
||||||
child_locked = 1;
|
child_locked = 1;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
if (!ocfs2_empty_dir(inode)) {
|
if (inode->i_nlink != 2 || !ocfs2_empty_dir(inode)) {
|
||||||
status = -ENOTEMPTY;
|
|
||||||
goto leave;
|
|
||||||
} else if (inode->i_nlink != 2) {
|
|
||||||
status = -ENOTEMPTY;
|
status = -ENOTEMPTY;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
@ -1280,8 +1277,8 @@ static int ocfs2_rename(struct inode *old_dir,
|
||||||
|
|
||||||
if (target_exists) {
|
if (target_exists) {
|
||||||
if (S_ISDIR(new_inode->i_mode)) {
|
if (S_ISDIR(new_inode->i_mode)) {
|
||||||
if (!ocfs2_empty_dir(new_inode) ||
|
if (new_inode->i_nlink != 2 ||
|
||||||
new_inode->i_nlink != 2) {
|
!ocfs2_empty_dir(new_inode)) {
|
||||||
status = -ENOTEMPTY;
|
status = -ENOTEMPTY;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue