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,  					      loff_t new_size)  {  	trace_ext4_begin_ordered_truncate(inode, new_size); -	return jbd2_journal_begin_ordered_truncate( -					EXT4_SB(inode->i_sb)->s_journal, -					&EXT4_I(inode)->jinode, -					new_size); +	/* +	 * If jinode is zero, then we never opened the file for +	 * writing, so there's no need to call +	 * jbd2_journal_begin_ordered_truncate() since there's no +	 * outstanding writes we need to flush. +	 */ +	if (!EXT4_I(inode)->jinode) +		return 0; +	return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode), +						   EXT4_I(inode)->jinode, +						   new_size);  }  static void ext4_invalidatepage(struct page *page, unsigned long offset); @@ -4054,7 +4061,7 @@ int ext4_block_truncate_page(handle_t *handle,  	if (ext4_should_journal_data(inode)) {  		err = ext4_handle_dirty_metadata(handle, inode, bh);  	} else { -		if (ext4_should_order_data(inode)) +		if (ext4_should_order_data(inode) && EXT4_I(inode)->jinode)  			err = ext4_jbd2_file_inode(handle, inode);  		mark_buffer_dirty(bh);  	} | 
