Commit 353eb83c authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: drop i_state_flags on architectures with 64-bit longs

We can store the dynamic inode state flags in the high bits of
EXT4_I(inode)->i_flags, and eliminate i_state_flags.  This saves 8
bytes from the size of ext4_inode_info structure, which when
multiplied by the number of the number of in the inode cache, can save
a lot of memory.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 8a2005d3
...@@ -764,7 +764,9 @@ struct ext4_inode_info { ...@@ -764,7 +764,9 @@ struct ext4_inode_info {
*/ */
ext4_group_t i_block_group; ext4_group_t i_block_group;
ext4_lblk_t i_dir_start_lookup; ext4_lblk_t i_dir_start_lookup;
#if (BITS_PER_LONG < 64)
unsigned long i_state_flags; /* Dynamic state flags */ unsigned long i_state_flags; /* Dynamic state flags */
#endif
unsigned long i_flags; unsigned long i_flags;
#ifdef CONFIG_EXT4_FS_XATTR #ifdef CONFIG_EXT4_FS_XATTR
...@@ -1239,22 +1241,36 @@ enum { ...@@ -1239,22 +1241,36 @@ enum {
EXT4_STATE_DELALLOC_RESERVED, /* blks already reserved for delalloc */ EXT4_STATE_DELALLOC_RESERVED, /* blks already reserved for delalloc */
}; };
#define EXT4_INODE_BIT_FNS(name, field) \ #define EXT4_INODE_BIT_FNS(name, field, offset) \
static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ static inline int ext4_test_inode_##name(struct inode *inode, int bit) \
{ \ { \
return test_bit(bit, &EXT4_I(inode)->i_##field); \ return test_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
} \ } \
static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ static inline void ext4_set_inode_##name(struct inode *inode, int bit) \
{ \ { \
set_bit(bit, &EXT4_I(inode)->i_##field); \ set_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
} \ } \
static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \
{ \ { \
clear_bit(bit, &EXT4_I(inode)->i_##field); \ clear_bit(bit + (offset), &EXT4_I(inode)->i_##field); \
} }
EXT4_INODE_BIT_FNS(flag, flags) EXT4_INODE_BIT_FNS(flag, flags, 0)
EXT4_INODE_BIT_FNS(state, state_flags) #if (BITS_PER_LONG < 64)
EXT4_INODE_BIT_FNS(state, state_flags, 0)
static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
{
(ei)->i_state_flags = 0;
}
#else
EXT4_INODE_BIT_FNS(state, flags, 32)
static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
{
/* We depend on the fact that callers will set i_flags */
}
#endif
#else #else
/* Assume that user mode programs are passing in an ext4fs superblock, not /* Assume that user mode programs are passing in an ext4fs superblock, not
* a kernel struct super_block. This will allow us to call the feature-test * a kernel struct super_block. This will allow us to call the feature-test
......
...@@ -1027,7 +1027,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, ...@@ -1027,7 +1027,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
inode->i_generation = sbi->s_next_generation++; inode->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock); spin_unlock(&sbi->s_next_gen_lock);
ei->i_state_flags = 0; ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
ext4_set_inode_state(inode, EXT4_STATE_NEW); ext4_set_inode_state(inode, EXT4_STATE_NEW);
ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
......
...@@ -4868,7 +4868,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) ...@@ -4868,7 +4868,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
} }
inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
ei->i_state_flags = 0; ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
ei->i_dir_start_lookup = 0; ei->i_dir_start_lookup = 0;
ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
/* We now have enough fields to check if the inode was active or not. /* We now have enough fields to check if the inode was active or not.
...@@ -5127,7 +5127,7 @@ static int ext4_do_update_inode(handle_t *handle, ...@@ -5127,7 +5127,7 @@ static int ext4_do_update_inode(handle_t *handle,
if (ext4_inode_blocks_set(handle, raw_inode, ei)) if (ext4_inode_blocks_set(handle, raw_inode, ei))
goto out_brelse; goto out_brelse;
raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
raw_inode->i_flags = cpu_to_le32(ei->i_flags); raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
cpu_to_le32(EXT4_OS_HURD)) cpu_to_le32(EXT4_OS_HURD))
raw_inode->i_file_acl_high = raw_inode->i_file_acl_high =
......
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