ext4: reduce per-inode memory overhead
Subsystems (3)
cover ext4: reduce per-inode memory overhead
This series reduces the size of struct ext4_inode_info by improving timestamp packing and allowing fast commit and bigalloc support to be omitted at compile time.
The incremental reductions are:
Disable CONFIG_EXT4_FS_FAST_COMMIT 48 bytes
Disable CONFIG_EXT4_FS_BIGALLOC 8 bytes
Compact creation time, with fast commit off 8 bytes
--------
Total 64 bytes
On our production server with 35 million ext4 inode objects (a big fscache partition), this saves 2.1 GB RAM.
Both new Kconfig options default to enabled. Without fast commit support, clean filesystems use ordinary journal commits; journals requiring fast commit recovery are rejected. Without bigalloc support, bigalloc filesystems are rejected before journal recovery, including for read-only mounts.
Max Kellermann (3):
ext4: make fast commit support optional
ext4: make bigalloc support optional
ext4: store creation time in separate seconds and nanoseconds
Documentation/filesystems/ext4/bigalloc.rst | 6 ++ Documentation/filesystems/ext4/journal.rst | 7 ++ fs/ext4/Kconfig | 31 ++++++++ fs/ext4/Makefile | 3 +- fs/ext4/ext4.h | 83 +++++++++++++++++++-- fs/ext4/extents_status.c | 44 ++++++++++- fs/ext4/extents_status.h | 15 ++++ fs/ext4/ialloc.c | 3 +- fs/ext4/inode.c | 8 +- fs/ext4/super.c | 40 ++++++++-- fs/ext4/sysfs.c | 6 ++ include/trace/events/ext4.h | 3 + 12 files changed, 227 insertions(+), 22 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 ext4: make fast commit support optional
Add CONFIG_EXT4_FS_FAST_COMMIT, enabled by default, to allow builds without fast commit support. Disabling it saves 48 bytes per inode.
Fall back to ordinary journal commits and reject journals requiring fast commit recovery.
--- Documentation/filesystems/ext4/journal.rst | 7 +++ fs/ext4/Kconfig | 16 ++++++ fs/ext4/Makefile | 3 +- fs/ext4/ext4.h | 63 ++++++++++++++++++++++ fs/ext4/inode.c | 4 +- fs/ext4/super.c | 30 ++++++++--- fs/ext4/sysfs.c | 6 +++ include/trace/events/ext4.h | 3 ++ 8 files changed, 121 insertions(+), 11 deletions(-)
Documentation/filesystems/ext4/journal.rst +7 -0
@@ -39,6 +39,13 @@ A full commit invalidates all the fast commits that happened before it and thus it makes the fast commit area empty for further fast commits. This feature needs to be enabled at mkfs time. +Fast commit support can be omitted with ``CONFIG_EXT4_FS_FAST_COMMIT=n`` +to reduce the memory used by each in-memory inode. Such kernels use +ordinary journal commits and can mount clean filesystems with the +``fast_commit`` feature. If the journal advertises fast commit records, +mounting with journal loading is refused; recover the filesystem first +using a kernel or e2fsck with fast commit support. + The journal inode is typically inode 8. The first 68 bytes of the journal inode are replicated in the ext4 superblock. The journal itself is normal (but hidden) file within the filesystem. The file usually
fs/ext4/Kconfig +16 -0
@@ -43,6 +43,22 @@ config EXT4_USE_FOR_EXT2 compiled kernel size by using one file system driver for ext2, ext3, and ext4 file systems. +config EXT4_FS_FAST_COMMIT + bool "Ext4 fast commit support" + depends on EXT4_FS + default y + help + Fast commits reduce journal commit latency by logging metadata + changes instead of complete metadata blocks. They are used on + filesystems with the fast_commit feature enabled. + + Say N to reduce memory usage per inode and omit fast commit code. + Clean filesystems with the fast_commit feature can still be mounted + using ordinary journaling, but journals containing fast commits must + first be recovered by a kernel or e2fsck with fast commit support. + + If unsure, say Y. + config EXT4_FS_POSIX_ACL bool "Ext4 POSIX Access Control Lists" depends on EXT4_FS
fs/ext4/Makefile +2 -1
@@ -10,8 +10,9 @@ ext4-y := balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \ indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \ mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \ super.o symlink.o sysfs.o xattr.o xattr_hurd.o xattr_trusted.o \ - xattr_user.o fast_commit.o orphan.o + xattr_user.o orphan.o +ext4-$(CONFIG_EXT4_FS_FAST_COMMIT) += fast_commit.o ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o ext4-test-objs += inode-test.o mballoc-test.o \
fs/ext4/ext4.h +63 -0
119 lines not on this page · raw message
fs/ext4/inode.c +2 -2
@@ -395,7 +395,7 @@ void ext4_evict_inode(struct inode *inode)*/ WARN_ON_ONCE (!list_empty_careful (&inode->i_io_list)); -if (!list_empty (&EXT4_I (inode)->i_fc_list)) +if (ext4_fc_inode_tracked (inode))ext4_fc_mark_ineligible (inode->i_sb,EXT4_FC_REASON_NOMEM ,NULL );ext4_clear_inode (inode);/* We must guarantee clearing of inode... */ }
@@ -3587,7 +3587,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) EXT4_I(inode)->i_datasync_tid))return false;if (test_opt2 (inode->i_sb,JOURNAL_FAST_COMMIT )) -return !list_empty (&EXT4_I (inode)->i_fc_list); +return ext4_fc_inode_tracked (inode);return true; }
fs/ext4/super.c +22 -8
@@ -1457,7 +1457,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) ei->i_datasync_tid =0 ;INIT_WORK (&ei->i_rsv_conversion_work, ext4_end_io_rsv_work);ext4_fc_init_inode (&ei->vfs_inode); +#ifdef CONFIG_EXT4_FS_FAST_COMMIT spin_lock_init (&ei->i_fc_lock); +#endif ei->i_metadata_bhs =NULL ;#ifdef CONFIG_LOCKDEP lockdep_set_subclass (&ei->i_data_sem,I_DATA_SEM_NORMAL );
@@ -1480,7 +1482,7 @@ static void ext4_free_in_core_inode(struct inode *inode) {fscrypt_free_inode (inode);kfree (ext4_i_metadata_bhs (inode)); -if (!list_empty (&(EXT4_I (inode)->i_fc_list))) { +if (ext4_fc_inode_tracked (inode)) {pr_warn ("%s: inode %llu still in fc list" , __func__, inode->i_ino); }
@@ -1757,7 +1759,7 @@ enum { Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, Opt_buffered_iomap, Opt_nobuffered_iomap, Opt_errors, Opt_data, Opt_data_err, Opt_jqfmt, Opt_dax_type, -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG) && defined(CONFIG_EXT4_FS_FAST_COMMIT) Opt_fc_debug_max_replay, Opt_fc_debug_force #endif };
@@ -1877,7 +1879,7 @@ static const struct fs_parameter_spec ext4_param_specs[] = { fsparam_u32 ("init_itable", Opt_init_itable), fsparam_flag ("init_itable", Opt_init_itable), fsparam_flag ("noinit_itable", Opt_noinit_itable), -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG ) && defined(CONFIG_EXT4_FS_FAST_COMMIT ) fsparam_flag ("fc_debug_force", Opt_fc_debug_force), fsparam_u32 ("fc_debug_max_replay", Opt_fc_debug_max_replay),#endif
@@ -1993,7 +1995,7 @@ static const struct mount_opts { MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, {Opt_nobuffered_iomap, EXT4_MOUNT2_BUFFERED_IOMAP, MOPT_CLEAR | MOPT_2 | MOPT_EXT4_ONLY}, -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG) && defined(CONFIG_EXT4_FS_FAST_COMMIT) {Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT, MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, #endif
@@ -2048,7 +2050,7 @@ struct ext4_fs_context {char *s_qf_names[EXT4_MAXQUOTAS ];struct fscrypt_dummy_policy dummy_enc_policy;int s_jquota_fmt;/* Format of quota to use */ -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG ) && defined(CONFIG_EXT4_FS_FAST_COMMIT )int s_fc_debug_max_replay;#endif unsigned short qname_spec;
@@ -2354,7 +2356,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) ctx->s_max_dir_size_kb = result.uint_32; ctx->spec |= EXT4_SPEC_s_max_dir_size_kb;return 0 ; -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG ) && defined(CONFIG_EXT4_FS_FAST_COMMIT )case Opt_fc_debug_max_replay: ctx->s_fc_debug_max_replay = result.uint_32; ctx->spec |= EXT4_SPEC_s_fc_debug_max_replay;
@@ -2934,7 +2936,7 @@ static void ext4_apply_options(struct fs_context *fc, struct super_block *sb)APPLY (s_resgid);APPLY (s_resuid); -#ifdef CONFIG_EXT4_DEBUG +#if defined(CONFIG_EXT4_DEBUG ) && defined(CONFIG_EXT4_FS_FAST_COMMIT )APPLY (s_fc_debug_max_replay);#endif
@@ -4462,7 +4464,8 @@ static void ext4_set_def_opts(struct super_block *sb,#ifdef CONFIG_EXT4_FS_POSIX_ACL set_opt (sb,POSIX_ACL );#endif -if (ext4_has_feature_fast_commit (sb)) +if (IS_ENABLED (CONFIG_EXT4_FS_FAST_COMMIT ) && +ext4_has_feature_fast_commit (sb))set_opt2 (sb,JOURNAL_FAST_COMMIT );/* don't forget to enable journal_csum when metadata_csum is enabled. */ if (ext4_has_feature_metadata_csum (sb))
@@ -4590,6 +4593,7 @@ static void ext4_atomic_write_init(struct super_block *sb)static void ext4_fast_commit_init (struct super_block *sb) { +#ifdef CONFIG_EXT4_FS_FAST_COMMIT struct ext4_sb_info *sbi =EXT4_SB (sb);/* Initialize fast commit stuff */
@@ -4611,6 +4615,7 @@ static void ext4_fast_commit_init(struct super_block *sb) sbi->s_fc_replay_state.fc_modified_inodes =NULL ; sbi->s_fc_replay_state.fc_modified_inodes_size =0 ; sbi->s_fc_replay_state.fc_modified_inodes_used =0 ; +#endif } static int ext4_inode_info_init(struct super_block *sb,
@@ -6196,6 +6201,15 @@ static int ext4_load_journal(struct super_block *sb,return PTR_ERR (journal); } +/* Never let JBD2 skip fast commit recovery without a replay callback. */ +if (!IS_ENABLED (CONFIG_EXT4_FS_FAST_COMMIT ) && +jbd2_has_feature_fast_commit (journal)) { +ext4_msg (sb,KERN_ERR , +"journal requires CONFIG_EXT4_FS_FAST_COMMIT recovery support" ); + err = -EOPNOTSUPP ; + goto err_out; + } + journal_dev_ro =bdev_read_only (journal->j_dev); really_read_only =bdev_read_only (sb->s_bdev) | journal_dev_ro;
fs/ext4/sysfs.c +6 -0
@@ -361,7 +361,9 @@ EXT4_ATTR_FEATURE(casefold);EXT4_ATTR_FEATURE (verity);#endif EXT4_ATTR_FEATURE (metadata_csum_seed); +#ifdef CONFIG_EXT4_FS_FAST_COMMIT EXT4_ATTR_FEATURE (fast_commit); +#endif #if IS_ENABLED (CONFIG_UNICODE ) && defined(CONFIG_FS_ENCRYPTION )EXT4_ATTR_FEATURE (encrypted_casefold);#endif
@@ -384,7 +386,9 @@ static struct attribute *ext4_feat_attrs[] = { ATTR_LIST(verity), #endif ATTR_LIST(metadata_csum_seed), +#ifdef CONFIG_EXT4_FS_FAST_COMMIT ATTR_LIST(fast_commit), +#endif #if IS_ENABLED (CONFIG_UNICODE ) && defined(CONFIG_FS_ENCRYPTION ) ATTR_LIST(encrypted_casefold),#endif
@@ -631,8 +635,10 @@ int ext4_register_sysfs(struct super_block *sb)proc_create_single_data ("es_shrinker_info" ,S_IRUGO , sbi->s_proc, ext4_seq_es_shrinker_info_show, sb); +#ifdef CONFIG_EXT4_FS_FAST_COMMIT proc_create_single_data ("fc_info" ,0444 , sbi->s_proc, ext4_fc_info_show, sb); +#endif proc_create_seq_data ("mb_groups" ,S_IRUGO , sbi->s_proc, &ext4_mb_seq_groups_ops, sb); proc_create_single_data("mb_stats", 0444, sbi->s_proc,
include/trace/events/ext4.h +3 -0
@@ -2738,6 +2738,7 @@ TRACE_EVENT(ext4_lazy_itable_init, MAJOR(__entry->dev), MINOR(__entry->dev), __entry->group) ); +#ifdef CONFIG_EXT4_FS_FAST_COMMIT TRACE_EVENT(ext4_fc_replay_scan, TP_PROTO(struct super_block *sb, int error, int off),
@@ -3060,6 +3061,8 @@ TRACE_EVENT(ext4_fc_cleanup, __entry->j_fc_off, __entry->full, __entry->tid) ); +#endif /* CONFIG_EXT4_FS_FAST_COMMIT */ + TRACE_EVENT(ext4_update_sb, TP_PROTO(struct super_block *sb, ext4_fsblk_t fsblk, unsigned int flags),
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 1/3] ext4: make fast commit support optional
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ext4: build failure exporting static inline ext4_fc_init_inode() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ext4: build failure exporting static inline ext4_fc_init_inode()
--
commit 2b96da3e6bb4354cc67ea3393ddf5ce91b735978
Author: Max Kellermann <[email protected]>
ext4: make fast commit support optional
This commit adds CONFIG_EXT4_FS_FAST_COMMIT to allow compiling out fast commit support and reducing in-memory inode size.
Quoted 4 lines
fs/ext4/ext4.h +0
-0
[ ... ]
fs/ext4/ext4.h void ext4_fc_destroy_dentry_cache(void); · line 3133
Quoted 12 lines
fs/ext4/ext4.h +8
-0@@ -3109,6 +3123,55 @@ void ext4_fc_destroy_dentry_cache(void);int ext4_fc_record_regions (struct super_block *sb,int ino,ext4_lblk_t lblk,ext4_fsblk_t pblk,int len,int replay); +#else +static inline bool ext4_fc_inode_tracked (struct inode *inode) +{ +return false; +} + +static inline void ext4_fc_init (struct super_block *sb,journal_t *journal) {} +static inline void ext4_fc_init_inode (struct inode *inode) {}
[Severity: Medium]
Does making ext4_fc_init_inode() a static inline stub break the build when CONFIG_EXT4_FS_FAST_COMMIT is disabled and CONFIG_EXT4_KUNIT_TESTS is enabled?
fs/ext4/mballoc.c unconditionally exports ext4_fc_init_inode() for KUnit tests:
fs/ext4/mballoc.c:
...
EXPORT_SYMBOL_FOR_EXT4_TEST(mb_set_bits);
EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_fc_init_inode);
EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_context);
#endifWith CONFIG_EXT4_FS_FAST_COMMIT=n, exporting the static inline function causes a static/non-static declaration conflict or fails in modpost with a local symbol export error.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/3] ext4: make fast commit support optional
Quoted 2 lines · On Wed, Nov 11, 2026 at 2:15 PM <[email protected]> wrote:
- [Medium] ext4: build failure exporting static inline
ext4_fc_init_inode()
Indeed I was not careful enough when I ported my patch from our 6.18 branch to linus/master. I'll fix that in v2 (if these patches are generally welcome).
Signature · 8 lines
Max Kellermann Principal Architect Hosting Technology cm4all | Im Mediapark 6a | 50670 Köln | Germany General information about the company can be found here: https://www.cm4all.com/impressum A member of the IONOS Group
PATCH 2/3 ext4: make bigalloc support optional
In reply to Max KellermannAdd CONFIG_EXT4_FS_BIGALLOC, enabled by default. Disabling it omits pending cluster reservation tracking and saves 8 bytes per inode.
Reject bigalloc filesystems before journal recovery, including on read-only mounts.
--- Documentation/filesystems/ext4/bigalloc.rst | 6 +++ fs/ext4/Kconfig | 15 +++++++ fs/ext4/ext4.h | 2 + fs/ext4/extents_status.c | 44 +++++++++++++++++++-- fs/ext4/extents_status.h | 15 +++++++ fs/ext4/super.c | 10 +++++ 6 files changed, 89 insertions(+), 3 deletions(-)
Documentation/filesystems/ext4/bigalloc.rst +6 -0
@@ -3,6 +3,12 @@ Bigalloc -------- +Bigalloc support is enabled by default with ``CONFIG_EXT4_FS_BIGALLOC``. +Disabling this option removes the per-inode pending cluster reservation +tree and its tracking code. Such kernels reject filesystems with the +``bigalloc`` feature, including read-only mounts, before journal recovery. +Filesystems without this feature remain supported. + At the moment, the default size of a block is 4KiB, which is a commonly supported page size on most MMU-capable hardware. This is fortunate, as ext4 code is not prepared to handle the case where the block size
fs/ext4/Kconfig +15 -0
@@ -43,6 +43,21 @@ config EXT4_USE_FOR_EXT2 compiled kernel size by using one file system driver for ext2, ext3, and ext4 file systems. +config EXT4_FS_BIGALLOC + bool "Ext4 bigalloc support" + depends on EXT4_FS + default y + help + Support filesystems with the bigalloc feature, which allocate space + in clusters of multiple blocks to reduce allocation overhead for + large files. + + Say N to omit pending cluster reservation tracking and reduce memory + usage per inode. Filesystems with the bigalloc feature cannot be + mounted, including read-only mounts, when this option is disabled. + + If unsure, say Y. + config EXT4_FS_FAST_COMMIT bool "Ext4 fast commit support" depends on EXT4_FS
fs/ext4/ext4.h +2 -0
@@ -1194,8 +1194,10 @@ struct ext4_inode_info {/* ialloc */ ext4_group_t i_last_alloc_group; +#ifdef CONFIG_EXT4_FS_BIGALLOC /* pending cluster reservations for bigalloc file systems */ struct ext4_pending_tree i_pending_tree; +#endif /* on-disk additional length */ __u16 i_extra_isize;
fs/ext4/extents_status.c +41 -3
135 lines not on this page · raw message
fs/ext4/extents_status.h +15 -0
@@ -242,11 +242,26 @@ extern void ext4_es_destroy_stats(struct ext4_sb_info *sbi);extern int ext4_seq_es_shrinker_info_show (struct seq_file *seq,void *v); +#ifdef CONFIG_EXT4_FS_BIGALLOC extern int __init ext4_init_pending (void );extern void ext4_exit_pending (void );extern void ext4_init_pending_tree (struct ext4_pending_tree *tree);extern void ext4_remove_pending (struct inode *inode,ext4_lblk_t lblk);extern bool ext4_is_pending (struct inode *inode,ext4_lblk_t lblk); +#else +static inline int ext4_init_pending (void ) +{ +return 0 ; +} + +static inline void ext4_exit_pending (void ) {} +static inline void ext4_remove_pending (struct inode *inode,ext4_lblk_t lblk) {} +static inline bool ext4_is_pending (struct inode *inode,ext4_lblk_t lblk) +{ +return false; +} +#endif +extern void ext4_es_insert_delayed_extent (struct inode *inode,ext4_lblk_t lblk,ext4_lblk_t len,bool lclu_allocated,bool end_allocated);
fs/ext4/super.c +10 -0
@@ -1438,7 +1438,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) ei->i_es_seq =0 ; ei->i_reserved_data_blocks =0 ;spin_lock_init (&(ei->i_block_reservation_lock)); +#ifdef CONFIG_EXT4_FS_BIGALLOC ext4_init_pending_tree (&ei->i_pending_tree); +#endif #ifdef CONFIG_QUOTA ei->i_reserved_quota =0 ;memset (&ei->i_dquot,0 ,sizeof (ei->i_dquot));
@@ -3698,6 +3700,14 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly)return 0 ; } +/* Read-only mounts can still replay the journal. */ +if (!IS_ENABLED (CONFIG_EXT4_FS_BIGALLOC ) && +ext4_has_feature_bigalloc (sb)) { +ext4_msg (sb,KERN_ERR , +"Filesystem with bigalloc feature cannot be mounted without CONFIG_EXT4_FS_BIGALLOC" ); +return 0 ; + } +if (readonly)return 1 ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 2/3] ext4: make bigalloc support optional
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
Add
CONFIG_EXT4_FS_BIGALLOC, enabled by default. Disabling it omits pending cluster reservation tracking and saves 8 bytes per inode.Reject bigalloc filesystems before journal recovery, including on read-only mounts.
Signed-off-by Max Kellermann <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/3 ext4: store creation time in separate seconds and nanoseconds
In reply to Max KellermannKeep 64-bit seconds and 32-bit nanoseconds and place the latter next to i_raw_lock. Preserve the existing on-disk encoding and timestamp range while saving 8 bytes per inode without fast commit.
--- fs/ext4/ext4.h | 18 +++++++++++++----- fs/ext4/ialloc.c | 3 ++- fs/ext4/inode.c | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-)
fs/ext4/ext4.h +13 -5
@@ -930,9 +930,15 @@ do { \ EXT4_INODE_SET_XTIME_VAL(i_ctime, inode, raw_inode, inode_get_ctime(inode))#define EXT4_EINODE_SET_XTIME (xtime, einode, raw_inode) \ +do { \ + struct timespec64 ts = { \ + .tv_sec = (einode)->xtime ## _sec, \ + .tv_nsec = (einode)->xtime ## _nsec, \ + }; \ if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \ EXT4_INODE_SET_XTIME_VAL(xtime, &((einode)->vfs_inode), \ - raw_inode, (einode)->xtime) + raw_inode, ts); \ +} while (0)#define EXT4_INODE_GET_XTIME_VAL (xtime, inode, raw_inode) \ (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra) ? \
@@ -962,12 +968,13 @@ do { \#define EXT4_EINODE_GET_XTIME (xtime, einode, raw_inode) \ do { \ + struct timespec64 ts = { 0, 0 }; \ if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \ - (einode)->xtime = \ + ts = \ EXT4_INODE_GET_XTIME_VAL(xtime, &(einode->vfs_inode), \ raw_inode); \ - else \ - (einode)->xtime = (struct timespec64){0, 0}; \ + (einode)->xtime ## _sec = ts.tv_sec; \ + (einode)->xtime ## _nsec = ts.tv_nsec; \ } while (0)#define i_disk_version osd1.linux1.l_i_version
@@ -1123,6 +1130,7 @@ struct ext4_inode_info {#endif spinlock_t i_raw_lock;/* protects updates to the raw inode */ +u32 i_crtime_nsec;#ifdef CONFIG_EXT4_FS_FAST_COMMIT /*
@@ -1168,7 +1176,7 @@ struct ext4_inode_info {* File creation time. Its function is same as that of * struct timespec64 i_{a,c,m}time in the generic inode. */ -struct timespec64 i_crtime; +time64_t i_crtime_sec;/* mballoc */ atomic_t i_prealloc_active;
fs/ext4/ialloc.c +2 -1
@@ -1261,7 +1261,8 @@ struct inode *__ext4_new_inode(const struct mnt_idmap *idmap,/* This is the optimal IO size (for stat), not the fs block size */ inode->i_blocks =0 ;simple_inode_init_ts (inode); - ei->i_crtime =inode_get_mtime (inode); + ei->i_crtime_sec =inode_get_mtime_sec (inode); + ei->i_crtime_nsec =inode_get_mtime_nsec (inode);memset (ei->i_data,0 ,sizeof (ei->i_data)); ei->i_dir_start_lookup =0 ;
fs/ext4/inode.c +2 -2
@@ -7190,8 +7190,8 @@ int ext4_getattr(const struct mnt_idmap *idmap, const struct path *path,if ((request_mask &STATX_BTIME ) &&EXT4_FITS_IN_INODE (raw_inode, ei, i_crtime)) { stat->result_mask |=STATX_BTIME ; - stat->btime.tv_sec = ei->i_crtime.tv_sec; - stat->btime.tv_nsec = ei->i_crtime.tv_nsec; + stat->btime.tv_sec = ei->i_crtime_sec; + stat->btime.tv_nsec = ei->i_crtime_nsec; }/* Return the DIO alignment restrictions if requested. */
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 3/3] ext4: store creation time in separate seconds and nanoseconds
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Keep 64-bit seconds and 32-bit nanoseconds and place the latter next to
i_raw_lock. Preserve the existing on-disk encoding and timestamp range while saving 8 bytes per inode without fast commit.Signed-off-by Max Kellermann <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3