Skip to content

Commit

Permalink
ocfs2: adjust code to match locking/unlocking order
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joseph Qi authored and Linus Torvalds committed Sep 4, 2015
1 parent bf59e66 commit 3cb2ec4
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions fs/ocfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,18 +1035,18 @@ static int ocfs2_unlink(struct inode *dir,
if (handle)
ocfs2_commit_trans(osb, handle);

if (child_locked)
ocfs2_inode_unlock(inode, 1);

ocfs2_inode_unlock(dir, 1);

if (orphan_dir) {
/* This was locked for us in ocfs2_prepare_orphan_dir() */
ocfs2_inode_unlock(orphan_dir, 1);
mutex_unlock(&orphan_dir->i_mutex);
iput(orphan_dir);
}

if (child_locked)
ocfs2_inode_unlock(inode, 1);

ocfs2_inode_unlock(dir, 1);

brelse(fe_bh);
brelse(parent_node_bh);

Expand Down Expand Up @@ -1633,28 +1633,28 @@ static int ocfs2_rename(struct inode *old_dir,
ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
status = 0;
bail:
if (rename_lock)
ocfs2_rename_unlock(osb);

if (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) {
/* This was locked for us in ocfs2_prepare_orphan_dir() */
ocfs2_inode_unlock(orphan_dir, 1);
mutex_unlock(&orphan_dir->i_mutex);
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)
sync_mapping_buffers(old_inode->i_mapping);

Expand Down

0 comments on commit 3cb2ec4

Please sign in to comment.