aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/namei.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 30842f5cf590..be3f8676a438 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -773,7 +773,7 @@ static int ocfs2_remote_dentry_delete(struct dentry *dentry)
773 return ret; 773 return ret;
774} 774}
775 775
776static inline int inode_is_unlinkable(struct inode *inode) 776static inline int ocfs2_inode_is_unlinkable(struct inode *inode)
777{ 777{
778 if (S_ISDIR(inode->i_mode)) { 778 if (S_ISDIR(inode->i_mode)) {
779 if (inode->i_nlink == 2) 779 if (inode->i_nlink == 2)
@@ -791,6 +791,7 @@ static int ocfs2_unlink(struct inode *dir,
791{ 791{
792 int status; 792 int status;
793 int child_locked = 0; 793 int child_locked = 0;
794 bool is_unlinkable = false;
794 struct inode *inode = dentry->d_inode; 795 struct inode *inode = dentry->d_inode;
795 struct inode *orphan_dir = NULL; 796 struct inode *orphan_dir = NULL;
796 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); 797 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
@@ -865,7 +866,7 @@ static int ocfs2_unlink(struct inode *dir,
865 goto leave; 866 goto leave;
866 } 867 }
867 868
868 if (inode_is_unlinkable(inode)) { 869 if (ocfs2_inode_is_unlinkable(inode)) {
869 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, 870 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
870 OCFS2_I(inode)->ip_blkno, 871 OCFS2_I(inode)->ip_blkno,
871 orphan_name, &orphan_insert); 872 orphan_name, &orphan_insert);
@@ -873,6 +874,7 @@ static int ocfs2_unlink(struct inode *dir,
873 mlog_errno(status); 874 mlog_errno(status);
874 goto leave; 875 goto leave;
875 } 876 }
877 is_unlinkable = true;
876 } 878 }
877 879
878 handle = ocfs2_start_trans(osb, ocfs2_unlink_credits(osb->sb)); 880 handle = ocfs2_start_trans(osb, ocfs2_unlink_credits(osb->sb));
@@ -892,15 +894,6 @@ static int ocfs2_unlink(struct inode *dir,
892 894
893 fe = (struct ocfs2_dinode *) fe_bh->b_data; 895 fe = (struct ocfs2_dinode *) fe_bh->b_data;
894 896
895 if (inode_is_unlinkable(inode)) {
896 status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name,
897 &orphan_insert, orphan_dir);
898 if (status < 0) {
899 mlog_errno(status);
900 goto leave;
901 }
902 }
903
904 /* delete the name from the parent dir */ 897 /* delete the name from the parent dir */
905 status = ocfs2_delete_entry(handle, dir, &lookup); 898 status = ocfs2_delete_entry(handle, dir, &lookup);
906 if (status < 0) { 899 if (status < 0) {
@@ -923,6 +916,14 @@ static int ocfs2_unlink(struct inode *dir,
923 mlog_errno(status); 916 mlog_errno(status);
924 if (S_ISDIR(inode->i_mode)) 917 if (S_ISDIR(inode->i_mode))
925 inc_nlink(dir); 918 inc_nlink(dir);
919 goto leave;
920 }
921
922 if (is_unlinkable) {
923 status = ocfs2_orphan_add(osb, handle, inode, fe_bh,
924 orphan_name, &orphan_insert, orphan_dir);
925 if (status < 0)
926 mlog_errno(status);
926 } 927 }
927 928
928leave: 929leave: