Skip to content

Commit

Permalink
reiserfs: fix inode mutex - reiserfs lock misordering
Browse files Browse the repository at this point in the history
reiserfs_unpack() locks the inode mutex with reiserfs_mutex_lock_safe()
to protect against reiserfs lock dependency.  However this protection
requires to have the reiserfs lock to be locked.

This is the case if reiserfs_unpack() is called by reiserfs_ioctl but
not from reiserfs_quota_on() when it tries to unpack tails of quota
files.

Fix the ordering of the two locks in reiserfs_unpack() to fix this
issue.

Signed-off-by: Frederic Weisbecker <[email protected]>
Reported-by: Markus Gapp <[email protected]>
Reported-by: Jan Kara <[email protected]>
Cc: Jeff Mahoney <[email protected]>
Cc: <[email protected]>		[2.6.36.x]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fweisbec authored and torvalds committed Nov 24, 2010
1 parent d1d7357 commit da90587
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs/reiserfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
return 0;
}

/* we need to make sure nobody is changing the file size beneath
** us
*/
reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
depth = reiserfs_write_lock_once(inode->i_sb);

/* we need to make sure nobody is changing the file size beneath us */
reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);

write_from = inode->i_size & (blocksize - 1);
/* if we are on a block boundary, we are already unpacked. */
if (write_from == 0) {
Expand Down

0 comments on commit da90587

Please sign in to comment.