ext4: discard preallocation when restarting a transaction during truncate
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 2 Nov 2009 23:50:49 +0000 (18:50 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 2 Nov 2009 23:50:49 +0000 (18:50 -0500)
When restart a transaction during a truncate operation, we drop and
reacquire i_data_sem.  After reacquiring i_data_sem, we need to
discard any inode-based preallocation that might have been grabbed
while we released i_data_sem (for example, if pdflush is allocating
blocks and racing against the truncate).

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/inode.c

index 5c5bc5d..d1ec698 100644 (file)
@@ -193,7 +193,7 @@ static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
  * so before we call here everything must be consistently dirtied against
  * this transaction.
  */
- int ext4_truncate_restart_trans(handle_t *handle, struct inode *inode,
+int ext4_truncate_restart_trans(handle_t *handle, struct inode *inode,
                                 int nblocks)
 {
        int ret;
@@ -209,6 +209,7 @@ static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
        up_write(&EXT4_I(inode)->i_data_sem);
        ret = ext4_journal_restart(handle, blocks_for_truncate(inode));
        down_write(&EXT4_I(inode)->i_data_sem);
+       ext4_discard_preallocations(inode);
 
        return ret;
 }