Skip to content

Commit

Permalink
ext4: add mutex_is_locked() assertion to ext4_truncate()
Browse files Browse the repository at this point in the history
[ Added fixup from Lukáš Czerner which only checks the assertion when
  the inode is not new and is not being freed. ]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Theodore Ts'o committed Apr 4, 2013
1 parent 819c492 commit 19b5ef6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3788,6 +3788,13 @@ void ext4_truncate(struct inode *inode)
struct address_space *mapping = inode->i_mapping;
loff_t page_len;

/*
* There is a possibility that we're either freeing the inode
* or it completely new indode. In those cases we might not
* have i_mutex locked because it's not necessary.
*/
if (!(inode->i_state & (I_NEW|I_FREEING)))
WARN_ON(!mutex_is_locked(&inode->i_mutex));
trace_ext4_truncate_enter(inode);

if (!ext4_can_truncate(inode))
Expand Down

0 comments on commit 19b5ef6

Please sign in to comment.