Commit 3cb2ec43 authored by Joseph Qi's avatar Joseph Qi Committed by Linus Torvalds

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: default avatarJoseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bf59e662
...@@ -1035,11 +1035,6 @@ static int ocfs2_unlink(struct inode *dir, ...@@ -1035,11 +1035,6 @@ static int ocfs2_unlink(struct inode *dir,
if (handle) if (handle)
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
if (child_locked)
ocfs2_inode_unlock(inode, 1);
ocfs2_inode_unlock(dir, 1);
if (orphan_dir) { if (orphan_dir) {
/* This was locked for us in ocfs2_prepare_orphan_dir() */ /* This was locked for us in ocfs2_prepare_orphan_dir() */
ocfs2_inode_unlock(orphan_dir, 1); ocfs2_inode_unlock(orphan_dir, 1);
...@@ -1047,6 +1042,11 @@ static int ocfs2_unlink(struct inode *dir, ...@@ -1047,6 +1042,11 @@ static int ocfs2_unlink(struct inode *dir,
iput(orphan_dir); iput(orphan_dir);
} }
if (child_locked)
ocfs2_inode_unlock(inode, 1);
ocfs2_inode_unlock(dir, 1);
brelse(fe_bh); brelse(fe_bh);
brelse(parent_node_bh); brelse(parent_node_bh);
...@@ -1633,21 +1633,9 @@ static int ocfs2_rename(struct inode *old_dir, ...@@ -1633,21 +1633,9 @@ static int ocfs2_rename(struct inode *old_dir,
ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir); ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
status = 0; status = 0;
bail: bail:
if (rename_lock)
ocfs2_rename_unlock(osb);
if (handle) if (handle)
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
if (parents_locked)
ocfs2_double_unlock(old_dir, new_dir);
if (old_child_locked)
ocfs2_inode_unlock(old_inode, 1);
if (new_child_locked)
ocfs2_inode_unlock(new_inode, 1);
if (orphan_dir) { if (orphan_dir) {
/* This was locked for us in ocfs2_prepare_orphan_dir() */ /* This was locked for us in ocfs2_prepare_orphan_dir() */
ocfs2_inode_unlock(orphan_dir, 1); ocfs2_inode_unlock(orphan_dir, 1);
...@@ -1655,6 +1643,18 @@ static int ocfs2_rename(struct inode *old_dir, ...@@ -1655,6 +1643,18 @@ static int ocfs2_rename(struct inode *old_dir,
iput(orphan_dir); iput(orphan_dir);
} }
if (new_child_locked)
ocfs2_inode_unlock(new_inode, 1);
if (old_child_locked)
ocfs2_inode_unlock(old_inode, 1);
if (parents_locked)
ocfs2_double_unlock(old_dir, new_dir);
if (rename_lock)
ocfs2_rename_unlock(osb);
if (new_inode) if (new_inode)
sync_mapping_buffers(old_inode->i_mapping); sync_mapping_buffers(old_inode->i_mapping);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment