From: Mingming Cao ext3_discard_reservation() should not be called on every iput(). Now it is moved to ext3_delete_inode(), so it is only called on the last iput(). --- 25-akpm/fs/ext3/inode.c | 16 +++------------- 25-akpm/fs/ext3/super.c | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff -puN fs/ext3/inode.c~ext3-discard-reservation-in-last-iput-fix-patch fs/ext3/inode.c --- 25/fs/ext3/inode.c~ext3-discard-reservation-in-last-iput-fix-patch Wed Apr 28 15:13:21 2004 +++ 25-akpm/fs/ext3/inode.c Wed Apr 28 15:13:21 2004 @@ -177,19 +177,6 @@ static int ext3_journal_test_restart(han } /* - * Called at each iput() - * - * The inode may be "bad" if ext3_read_inode() saw an error from - * ext3_get_inode(), so we need to check that to avoid freeing random disk - * blocks. - */ -void ext3_put_inode(struct inode *inode) -{ - if (!is_bad_inode(inode)) - ext3_discard_reservation(inode); -} - -/* * Called at the last iput() if i_nlink is zero. */ void ext3_delete_inode (struct inode * inode) @@ -199,6 +186,9 @@ void ext3_delete_inode (struct inode * i if (is_bad_inode(inode)) goto no_delete; + /* discard the block reservation */ + ext3_discard_reservation(inode); + handle = start_transaction(inode); if (IS_ERR(handle)) { /* If we're going to skip the normal cleanup, we still diff -puN fs/ext3/super.c~ext3-discard-reservation-in-last-iput-fix-patch fs/ext3/super.c --- 25/fs/ext3/super.c~ext3-discard-reservation-in-last-iput-fix-patch Wed Apr 28 15:13:21 2004 +++ 25-akpm/fs/ext3/super.c Wed Apr 28 15:13:21 2004 @@ -561,7 +561,6 @@ static struct super_operations ext3_sops .read_inode = ext3_read_inode, .write_inode = ext3_write_inode, .dirty_inode = ext3_dirty_inode, - .put_inode = ext3_put_inode, .delete_inode = ext3_delete_inode, .put_super = ext3_put_super, .write_super = ext3_write_super, _