Commit e9eef9fe authored by Mingming Cao's avatar Mingming Cao Committed by Linus Torvalds

[PATCH] ext2: discard preallocation in last iput

Currently the ext2 preallocation is discarded on every iput() (via
ext2_put_inode()).  We should only discard the preallocation on the last
iput() (via ext2_clear_inode()).
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 512c3373
......@@ -116,7 +116,6 @@ extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
/* inode.c */
extern void ext2_read_inode (struct inode *);
extern int ext2_write_inode (struct inode *, int);
extern void ext2_put_inode (struct inode *);
extern void ext2_delete_inode (struct inode *);
extern int ext2_sync_inode (struct inode *);
extern void ext2_discard_prealloc (struct inode *);
......
......@@ -52,19 +52,6 @@ static inline int ext2_inode_is_fast_symlink(struct inode *inode)
inode->i_blocks - ea_blocks == 0);
}
/*
* Called at each iput().
*
* The inode may be "bad" if ext2_read_inode() saw an error from
* ext2_get_inode(), so we need to check that to avoid freeing random disk
* blocks.
*/
void ext2_put_inode(struct inode *inode)
{
if (!is_bad_inode(inode))
ext2_discard_prealloc(inode);
}
/*
* Called at the last iput() if i_nlink is zero.
*/
......
......@@ -181,10 +181,9 @@ static void destroy_inodecache(void)
printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n");
}
#ifdef CONFIG_EXT2_FS_POSIX_ACL
static void ext2_clear_inode(struct inode *inode)
{
#ifdef CONFIG_EXT2_FS_POSIX_ACL
struct ext2_inode_info *ei = EXT2_I(inode);
if (ei->i_acl && ei->i_acl != EXT2_ACL_NOT_CACHED) {
......@@ -195,18 +194,17 @@ static void ext2_clear_inode(struct inode *inode)
posix_acl_release(ei->i_default_acl);
ei->i_default_acl = EXT2_ACL_NOT_CACHED;
}
#endif
if (!is_bad_inode(inode))
ext2_discard_prealloc(inode);
}
#else
# define ext2_clear_inode NULL
#endif
static struct super_operations ext2_sops = {
.alloc_inode = ext2_alloc_inode,
.destroy_inode = ext2_destroy_inode,
.read_inode = ext2_read_inode,
.write_inode = ext2_write_inode,
.put_inode = ext2_put_inode,
.delete_inode = ext2_delete_inode,
.put_super = ext2_put_super,
.write_super = ext2_write_super,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment