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/inode.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/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0801ee6a173e..2693fcda30d8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -55,10 +55,17 @@ static inline int ext4_begin_ordered_truncate(struct inode *inode, | |||
55 | loff_t new_size) | 55 | loff_t new_size) |
56 | { | 56 | { |
57 | trace_ext4_begin_ordered_truncate(inode, new_size); | 57 | trace_ext4_begin_ordered_truncate(inode, new_size); |
58 | return jbd2_journal_begin_ordered_truncate( | 58 | /* |
59 | EXT4_SB(inode->i_sb)->s_journal, | 59 | * If jinode is zero, then we never opened the file for |
60 | &EXT4_I(inode)->jinode, | 60 | * writing, so there's no need to call |
61 | new_size); | 61 | * jbd2_journal_begin_ordered_truncate() since there's no |
62 | * outstanding writes we need to flush. | ||
63 | */ | ||
64 | if (!EXT4_I(inode)->jinode) | ||
65 | return 0; | ||
66 | return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode), | ||
67 | EXT4_I(inode)->jinode, | ||
68 | new_size); | ||
62 | } | 69 | } |
63 | 70 | ||
64 | static void ext4_invalidatepage(struct page *page, unsigned long offset); | 71 | static void ext4_invalidatepage(struct page *page, unsigned long offset); |
@@ -4054,7 +4061,7 @@ int ext4_block_truncate_page(handle_t *handle, | |||
4054 | if (ext4_should_journal_data(inode)) { | 4061 | if (ext4_should_journal_data(inode)) { |
4055 | err = ext4_handle_dirty_metadata(handle, inode, bh); | 4062 | err = ext4_handle_dirty_metadata(handle, inode, bh); |
4056 | } else { | 4063 | } else { |
4057 | if (ext4_should_order_data(inode)) | 4064 | if (ext4_should_order_data(inode) && EXT4_I(inode)->jinode) |
4058 | err = ext4_jbd2_file_inode(handle, inode); | 4065 | err = ext4_jbd2_file_inode(handle, inode); |
4059 | mark_buffer_dirty(bh); | 4066 | mark_buffer_dirty(bh); |
4060 | } | 4067 | } |