diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-01-10 12:29:43 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-01-10 12:29:43 -0500 |
commit | 8aefcd557d26d0023a36f9ec5afbf55e59f8f26b (patch) | |
tree | e13143306cd64525cddd2cc2513c448275a1d95a /fs/ext4/super.c | |
parent | 353eb83c1422c6326eaab30ce044a179c6018169 (diff) |
ext4: dynamically allocate the jbd2_inode in ext4_inode_info as necessary
Replace the jbd2_inode structure (which is 48 bytes) with a pointer
and only allocate the jbd2_inode when it is needed --- that is, when
the file system has a journal present and the inode has been opened
for writing. This allows us to further slim down the ext4_inode_info
structure.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f5960d673e4e..1cd4326c530b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -818,12 +818,6 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
818 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); | 818 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); |
819 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 819 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
820 | spin_lock_init(&ei->i_prealloc_lock); | 820 | spin_lock_init(&ei->i_prealloc_lock); |
821 | /* | ||
822 | * Note: We can be called before EXT4_SB(sb)->s_journal is set, | ||
823 | * therefore it can be null here. Don't check it, just initialize | ||
824 | * jinode. | ||
825 | */ | ||
826 | jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode); | ||
827 | ei->i_reserved_data_blocks = 0; | 821 | ei->i_reserved_data_blocks = 0; |
828 | ei->i_reserved_meta_blocks = 0; | 822 | ei->i_reserved_meta_blocks = 0; |
829 | ei->i_allocated_meta_blocks = 0; | 823 | ei->i_allocated_meta_blocks = 0; |
@@ -832,6 +826,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
832 | #ifdef CONFIG_QUOTA | 826 | #ifdef CONFIG_QUOTA |
833 | ei->i_reserved_quota = 0; | 827 | ei->i_reserved_quota = 0; |
834 | #endif | 828 | #endif |
829 | ei->jinode = NULL; | ||
835 | INIT_LIST_HEAD(&ei->i_completed_io_list); | 830 | INIT_LIST_HEAD(&ei->i_completed_io_list); |
836 | spin_lock_init(&ei->i_completed_io_lock); | 831 | spin_lock_init(&ei->i_completed_io_lock); |
837 | ei->cur_aio_dio = NULL; | 832 | ei->cur_aio_dio = NULL; |
@@ -900,9 +895,12 @@ void ext4_clear_inode(struct inode *inode) | |||
900 | end_writeback(inode); | 895 | end_writeback(inode); |
901 | dquot_drop(inode); | 896 | dquot_drop(inode); |
902 | ext4_discard_preallocations(inode); | 897 | ext4_discard_preallocations(inode); |
903 | if (EXT4_JOURNAL(inode)) | 898 | if (EXT4_I(inode)->jinode) { |
904 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, | 899 | jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode), |
905 | &EXT4_I(inode)->jinode); | 900 | EXT4_I(inode)->jinode); |
901 | jbd2_free_inode(EXT4_I(inode)->jinode); | ||
902 | EXT4_I(inode)->jinode = NULL; | ||
903 | } | ||
906 | } | 904 | } |
907 | 905 | ||
908 | static inline void ext4_show_quota_options(struct seq_file *seq, | 906 | static inline void ext4_show_quota_options(struct seq_file *seq, |