PATCH 2.5.2.9: ext2 unbork fs.h (part 7/7)
Subsystems (2)
patch7 desc: implement ext2 use of s_op->{alloc,destroy}
fs/ext2/ext2_fs.h +2 -1
@@ -596,7 +596,8 @@extern int ext2_sync_inode (struct inode *);extern void ext2_discard_prealloc (struct inode *);extern void ext2_truncate (struct inode *); -extern void ext2_clear_inode (struct inode *inode); +extern struct inode *ext2_alloc_inode (struct super_block *sb); +extern void ext2_destroy_inode (struct inode *inode);/* ioctl.c */ extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
fs/ext2/ext2_fs_i.h +4 -0
@@ -36,6 +36,10 @@__u32 i_prealloc_count;__u32 i_dir_start_lookup; int i_new_inode:1; /* Is a freshly allocated inode */ + +#ifdef __KERNEL__ +struct inode i_inode_data; +#endif };#endif /* _LINUX_EXT2_FS_I */
fs/ext2/ialloc.c +1 -13
@@ -335,18 +335,7 @@ inode =new_inode (sb);if (!inode)return ERR_PTR (-ENOMEM ); - -/* allocate private per-inode info. note that for -* the error cases below, iput and s_op->clear_inode -* will handle freeing the private area. -*/ - inode->u.ext2_ip =kmem_cache_alloc (ext2_ino_cache,SLAB_NOFS ); -if (!inode->u.ext2_ip) { - err = -ENOMEM ; - goto no_priv; - } - ei = inode->u.ext2_ip; -memset (ei,0 ,sizeof (*ei)); + ei =ext2_i (inode);lock_super (sb);
@@ -439,7 +428,6 @@mark_buffer_dirty (bh2); fail:unlock_super (sb); -no_priv:make_bad_inode (inode);iput (inode);return ERR_PTR (err);
fs/ext2/inode.c +22 -18
@@ -37,7 +37,7 @@MODULE_DESCRIPTION ("Second Extended Filesystem" );MODULE_LICENSE ("GPL" ); - +extern void inode_init_once (void *,kmem_cache_t *,unsigned long );static int ext2_update_inode (struct inode * inode,int do_sync);/*
@@ -890,7 +890,7 @@ {struct super_block *sb = inode->i_sb;struct ext2_sb_info *esb =ext2_sb (sb); -struct ext2_inode_info *ei; +struct ext2_inode_info *ei =ext2_i (inode);struct buffer_head * bh;struct ext2_inode * raw_inode;unsigned long block_group;
@@ -900,12 +900,6 @@unsigned long offset;struct ext2_group_desc * gdp; - inode->u.ext2_ip =kmem_cache_alloc (ext2_ino_cache,SLAB_NOFS ); -if (!inode->u.ext2_ip) - goto bad_inode; - ei = inode->u.ext2_ip; -memset (ei,0 ,sizeof (*ei)); - if ((inode->i_ino != EXT2_ROOT_INO && inode->i_ino != EXT2_ACL_IDX_INO && inode->i_ino != EXT2_ACL_DATA_INO && inode->i_ino < EXT2_FIRST_INO(sb)) ||
@@ -1034,10 +1028,6 @@return ; bad_inode: -if (inode->u.ext2_ip) { -kmem_cache_free (ext2_ino_cache, inode->u.ext2_ip); - inode->u.ext2_ip =NULL ; - }make_bad_inode (inode);return ; }
@@ -1181,12 +1171,26 @@return ext2_update_inode (inode,1 ); } -void ext2_clear_inode (struct inode *inode) +struct inode *ext2_alloc_inode (struct super_block *sb) { -struct ext2_inode_info *ei = inode->u.ext2_ip; +struct ext2_inode_info *ei; +struct inode *inode; -if (ei) { -kmem_cache_free (ext2_ino_cache, ei); - inode->u.ext2_ip =NULL ; - } + ei =kmem_cache_alloc (ext2_ino_cache,SLAB_NOFS ); +if (!ei) +return NULL ; + inode = &ei->i_inode_data; + +memset (ei,0 ,sizeof (*ei)); +inode_init_once (inode, ext2_ino_cache,SLAB_CTOR_CONSTRUCTOR ); + + inode->u.ext2_ip = ei;/* set self-ref */ +return inode; +} + +void ext2_destroy_inode (struct inode *inode) +{ +struct ext2_inode_info *ei =ext2_i (inode); +kmem_cache_free (ext2_ino_cache, ei); } +
fs/ext2/super.c +3 -1
@@ -160,7 +160,9 @@ write_inode: ext2_write_inode, put_inode: ext2_put_inode, delete_inode: ext2_delete_inode, - clear_inode: ext2_clear_inode, + alloc_inode: ext2_alloc_inode, + destroy_inode: ext2_destroy_inode, + put_super: ext2_put_super, write_super: ext2_write_super, statfs: ext2_statfs,
include/linux/fs.h +1 -1
@@ -503,7 +503,7 @@struct socket socket_i;struct jffs2_inode_info jffs2_i; -struct ext2_inode_info *ext2_ip; +struct ext2_inode_info *ext2_ip;/* ref to self */ void *generic_ip; } u;