Skip to content

Commit 3cb2ec4

Browse files
josephhztorvalds
authored andcommitted
ocfs2: adjust code to match locking/unlocking order
Unlocking order in ocfs2_unlink and ocfs2_rename mismatches the corresponding locking order, although it won't cause issues, adjust the code so that it looks more reasonable. Signed-off-by: Joseph Qi <joseph.qi@huawei.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bf59e66 commit 3cb2ec4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

fs/ocfs2/namei.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,18 +1035,18 @@ static int ocfs2_unlink(struct inode *dir,
10351035
if (handle)
10361036
ocfs2_commit_trans(osb, handle);
10371037

1038-
if (child_locked)
1039-
ocfs2_inode_unlock(inode, 1);
1040-
1041-
ocfs2_inode_unlock(dir, 1);
1042-
10431038
if (orphan_dir) {
10441039
/* This was locked for us in ocfs2_prepare_orphan_dir() */
10451040
ocfs2_inode_unlock(orphan_dir, 1);
10461041
mutex_unlock(&orphan_dir->i_mutex);
10471042
iput(orphan_dir);
10481043
}
10491044

1045+
if (child_locked)
1046+
ocfs2_inode_unlock(inode, 1);
1047+
1048+
ocfs2_inode_unlock(dir, 1);
1049+
10501050
brelse(fe_bh);
10511051
brelse(parent_node_bh);
10521052

@@ -1633,28 +1633,28 @@ static int ocfs2_rename(struct inode *old_dir,
16331633
ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
16341634
status = 0;
16351635
bail:
1636-
if (rename_lock)
1637-
ocfs2_rename_unlock(osb);
1638-
16391636
if (handle)
16401637
ocfs2_commit_trans(osb, handle);
16411638

1642-
if (parents_locked)
1643-
ocfs2_double_unlock(old_dir, new_dir);
1644-
1645-
if (old_child_locked)
1646-
ocfs2_inode_unlock(old_inode, 1);
1647-
1648-
if (new_child_locked)
1649-
ocfs2_inode_unlock(new_inode, 1);
1650-
16511639
if (orphan_dir) {
16521640
/* This was locked for us in ocfs2_prepare_orphan_dir() */
16531641
ocfs2_inode_unlock(orphan_dir, 1);
16541642
mutex_unlock(&orphan_dir->i_mutex);
16551643
iput(orphan_dir);
16561644
}
16571645

1646+
if (new_child_locked)
1647+
ocfs2_inode_unlock(new_inode, 1);
1648+
1649+
if (old_child_locked)
1650+
ocfs2_inode_unlock(old_inode, 1);
1651+
1652+
if (parents_locked)
1653+
ocfs2_double_unlock(old_dir, new_dir);
1654+
1655+
if (rename_lock)
1656+
ocfs2_rename_unlock(osb);
1657+
16581658
if (new_inode)
16591659
sync_mapping_buffers(old_inode->i_mapping);
16601660

0 commit comments

Comments
 (0)