diff options
| author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-11-24 15:57:15 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-11-24 16:50:48 -0500 |
| commit | da905873effecd1c0166e578bc4b5006f041b18b (patch) | |
| tree | ba6e699a028ce1e0625a01a3e6f82d83dad04aca | |
| parent | d1d73578e053b981c3611e5a211534290d24a5eb (diff) | |
reiserfs: fix inode mutex - reiserfs lock misordering
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 <fweisbec@gmail.com>
Reported-by: Markus Gapp <markus.gapp@gmx.net>
Reported-by: Jan Kara <jack@suse.cz>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: <stable@kernel.org> [2.6.36.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | fs/reiserfs/ioctl.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index bd9763e76ba..79265fdc317 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c | |||
| @@ -183,12 +183,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp) | |||
| 183 | return 0; | 183 | return 0; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | /* we need to make sure nobody is changing the file size beneath | ||
| 187 | ** us | ||
| 188 | */ | ||
| 189 | reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb); | ||
| 190 | depth = reiserfs_write_lock_once(inode->i_sb); | 186 | depth = reiserfs_write_lock_once(inode->i_sb); |
| 191 | 187 | ||
| 188 | /* we need to make sure nobody is changing the file size beneath us */ | ||
| 189 | reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb); | ||
| 190 | |||
| 192 | write_from = inode->i_size & (blocksize - 1); | 191 | write_from = inode->i_size & (blocksize - 1); |
| 193 | /* if we are on a block boundary, we are already unpacked. */ | 192 | /* if we are on a block boundary, we are already unpacked. */ |
| 194 | if (write_from == 0) { | 193 | if (write_from == 0) { |
