diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-01-10 12:18:25 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-01-10 12:18:25 -0500 |
commit | 353eb83c1422c6326eaab30ce044a179c6018169 (patch) | |
tree | fd43e39b344de5ee43d82c90f0affda68a65f2df /fs/ext4 | |
parent | 8a2005d3f84457b7d7d8646ab5195341d9e5f06a (diff) |
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: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4.h | 28 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 2 | ||||
-rw-r--r-- | fs/ext4/inode.c | 4 |
3 files changed, 25 insertions, 9 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 50e3d24483fb..2fb531cfd48b 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -764,7 +764,9 @@ struct ext4_inode_info { | |||
764 | */ | 764 | */ |
765 | ext4_group_t i_block_group; | 765 | ext4_group_t i_block_group; |
766 | ext4_lblk_t i_dir_start_lookup; | 766 | ext4_lblk_t i_dir_start_lookup; |
767 | #if (BITS_PER_LONG < 64) | ||
767 | unsigned long i_state_flags; /* Dynamic state flags */ | 768 | unsigned long i_state_flags; /* Dynamic state flags */ |
769 | #endif | ||
768 | unsigned long i_flags; | 770 | unsigned long i_flags; |
769 | 771 | ||
770 | #ifdef CONFIG_EXT4_FS_XATTR | 772 | #ifdef CONFIG_EXT4_FS_XATTR |
@@ -1239,22 +1241,36 @@ enum { | |||
1239 | EXT4_STATE_DELALLOC_RESERVED, /* blks already reserved for delalloc */ | 1241 | EXT4_STATE_DELALLOC_RESERVED, /* blks already reserved for delalloc */ |
1240 | }; | 1242 | }; |
1241 | 1243 | ||
1242 | #define EXT4_INODE_BIT_FNS(name, field) \ | 1244 | #define EXT4_INODE_BIT_FNS(name, field, offset) \ |
1243 | static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ | 1245 | static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ |
1244 | { \ | 1246 | { \ |
1245 | return test_bit(bit, &EXT4_I(inode)->i_##field); \ | 1247 | return test_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1246 | } \ | 1248 | } \ |
1247 | static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ | 1249 | static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ |
1248 | { \ | 1250 | { \ |
1249 | set_bit(bit, &EXT4_I(inode)->i_##field); \ | 1251 | set_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1250 | } \ | 1252 | } \ |
1251 | static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ | 1253 | static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ |
1252 | { \ | 1254 | { \ |
1253 | clear_bit(bit, &EXT4_I(inode)->i_##field); \ | 1255 | clear_bit(bit + (offset), &EXT4_I(inode)->i_##field); \ |
1254 | } | 1256 | } |
1255 | 1257 | ||
1256 | EXT4_INODE_BIT_FNS(flag, flags) | 1258 | EXT4_INODE_BIT_FNS(flag, flags, 0) |
1257 | EXT4_INODE_BIT_FNS(state, state_flags) | 1259 | #if (BITS_PER_LONG < 64) |
1260 | EXT4_INODE_BIT_FNS(state, state_flags, 0) | ||
1261 | |||
1262 | static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | ||
1263 | { | ||
1264 | (ei)->i_state_flags = 0; | ||
1265 | } | ||
1266 | #else | ||
1267 | EXT4_INODE_BIT_FNS(state, flags, 32) | ||
1268 | |||
1269 | static inline void ext4_clear_state_flags(struct ext4_inode_info *ei) | ||
1270 | { | ||
1271 | /* We depend on the fact that callers will set i_flags */ | ||
1272 | } | ||
1273 | #endif | ||
1258 | #else | 1274 | #else |
1259 | /* Assume that user mode programs are passing in an ext4fs superblock, not | 1275 | /* Assume that user mode programs are passing in an ext4fs superblock, not |
1260 | * a kernel struct super_block. This will allow us to call the feature-test | 1276 | * a kernel struct super_block. This will allow us to call the feature-test |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 1ce240a23ebb..eb9097aec6f0 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -1027,7 +1027,7 @@ got: | |||
1027 | inode->i_generation = sbi->s_next_generation++; | 1027 | inode->i_generation = sbi->s_next_generation++; |
1028 | spin_unlock(&sbi->s_next_gen_lock); | 1028 | spin_unlock(&sbi->s_next_gen_lock); |
1029 | 1029 | ||
1030 | ei->i_state_flags = 0; | 1030 | ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ |
1031 | ext4_set_inode_state(inode, EXT4_STATE_NEW); | 1031 | ext4_set_inode_state(inode, EXT4_STATE_NEW); |
1032 | 1032 | ||
1033 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; | 1033 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3ae83137cf34..0801ee6a173e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4868,7 +4868,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4868 | } | 4868 | } |
4869 | inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); | 4869 | inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); |
4870 | 4870 | ||
4871 | ei->i_state_flags = 0; | 4871 | ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ |
4872 | ei->i_dir_start_lookup = 0; | 4872 | ei->i_dir_start_lookup = 0; |
4873 | ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); | 4873 | ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); |
4874 | /* We now have enough fields to check if the inode was active or not. | 4874 | /* 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 | if (ext4_inode_blocks_set(handle, raw_inode, ei)) | 5127 | if (ext4_inode_blocks_set(handle, raw_inode, ei)) |
5128 | goto out_brelse; | 5128 | goto out_brelse; |
5129 | raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); | 5129 | raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); |
5130 | raw_inode->i_flags = cpu_to_le32(ei->i_flags); | 5130 | raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF); |
5131 | if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != | 5131 | if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != |
5132 | cpu_to_le32(EXT4_OS_HURD)) | 5132 | cpu_to_le32(EXT4_OS_HURD)) |
5133 | raw_inode->i_file_acl_high = | 5133 | raw_inode->i_file_acl_high = |