Skip to content

Commit 6cdbb0e

Browse files
committed
fs: optimize out 16 bytes worth of padding in struct inode
Rearrange the fields in struct inode so that on an x86_64 system, fields that require 8-byte alignment don't end up causing 4-byte holes in the structure. It reduces the size of struct inode from 568 bytes to 552 bytes. Also move the fields protected by i_lock (i_blocks, i_bytes, and i_size) into the same cache line as i_lock. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 80e675f commit 6cdbb0e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎include/linux/fs.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,20 +771,20 @@ struct inode {
771771
unsigned long i_ino;
772772
unsigned int i_nlink;
773773
dev_t i_rdev;
774-
loff_t i_size;
775774
struct timespec i_atime;
776775
struct timespec i_mtime;
777776
struct timespec i_ctime;
778-
unsigned int i_blkbits;
777+
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
778+
unsigned short i_bytes;
779779
blkcnt_t i_blocks;
780+
loff_t i_size;
780781

781782
#ifdef __NEED_I_SIZE_ORDERED
782783
seqcount_t i_size_seqcount;
783784
#endif
784785

785786
/* Misc */
786787
unsigned long i_state;
787-
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
788788
struct mutex i_mutex;
789789

790790
unsigned long dirtied_when; /* jiffies of first dirtying */
@@ -798,9 +798,10 @@ struct inode {
798798
struct rcu_head i_rcu;
799799
};
800800
atomic_t i_count;
801+
unsigned int i_blkbits;
801802
u64 i_version;
802-
unsigned short i_bytes;
803803
atomic_t i_dio_count;
804+
atomic_t i_writecount;
804805
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
805806
struct file_lock *i_flock;
806807
struct address_space i_data;
@@ -824,7 +825,6 @@ struct inode {
824825
#ifdef CONFIG_IMA
825826
atomic_t i_readcount; /* struct files open RO */
826827
#endif
827-
atomic_t i_writecount;
828828
void *i_private; /* fs or device private pointer */
829829
};
830830

0 commit comments

Comments
 (0)