nilfs2: atime support
Ryusuke Konishi
maintainercover nilfs2: atime support
Hi Viacheslav,
Please queue the following two patches for persistent atime support in nilfs2 for the next merge window.
This series builds upon your original patch [1], which Wang Jianjian followed up on to address review comments and add compat_ro feature flag support [2][3]. I have made minor modifications to those patches, including filling in missing kernel-doc comments and adjusting the commit messages (such as fixing the Co-developed-by tags).
To use this feature, install the updated nilfs-utils from the 'atime-support' branch of the development repository [4] (which will be merged into the master branch once this patchset is queued), and either format a new filesystem with the atime feature enabled:
$ sudo mkfs -t nilfs2 -O atime /dev/<device>
or enable the feature flag on an existing filesystem image using nilfs-tune:
$ sudo nilfs-tune -O atime /dev/<device>
Once the atime feature flag is set, the filesystem can only be mounted read-only on currently deployed kernels that lack support for it (until the flag is cleared with "nilfs-tune -O ^atime /dev/<device>"). To avoid confusing users, this feature will remain optional in mkfs.nilfs2 for the time being, though I plan to enable it by default in a future release of nilfs-utils.
Note that when enabling the feature on an existing filesystem, inodes written by older mkfs or kernels have their on-disk atime fields initialized to 0, which will expose the epoch date (1970-01-01). nilfs-tune warns about this when setting the flag, and image conversion (such as copying mtime to atime) is not supported.
The series consists of two patches:
- Patch 1/2 introduces the read-only compat feature flag (NILFS_FEATURE_COMPAT_RO_ATIME) to manage on-disk format compatibility for atime support.
- Patch 2/2 reads atime from on-disk inodes when the compat_ro flag is enabled and stops unconditionally setting SB_NOATIME on the superblock, switching VFS behavior accordingly.
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]
[4] https://github.com/nilfs-dev/nilfs-utils.git
Thanks,
Ryusuke Konishi
Viacheslav Dubeyko (1):
nilfs2: introduce atime support
Wang Jianjian (1):
nilfs2: add atime compat_ro feature
fs/nilfs2/Kconfig | 2 +- fs/nilfs2/inode.c | 11 +++++++++-- fs/nilfs2/nilfs.h | 4 ---- fs/nilfs2/segment.c | 2 -- fs/nilfs2/super.c | 11 ++++++----- fs/nilfs2/the_nilfs.h | 6 ++++++ include/uapi/linux/nilfs2_ondisk.h | 12 +++++++----- 7 files changed, 29 insertions(+), 19 deletions(-)
Signature · 1 line
2.53.0
Ryusuke Konishi
maintainerPATCH 1/2 nilfs2: add atime compat_ro feature
From: Wang Jianjian <[email protected]>
To prepare following atime support:
1. add read-only compat feature NILFS_FEATURE_COMPAT_RO_ATIME.
2. add the_nilfs.ns_feature_compat/compat_ro/incompat.
[ryusuke: added missing kernel-doc comments]
--- fs/nilfs2/super.c | 3 +++ fs/nilfs2/the_nilfs.h | 6 ++++++ include/uapi/linux/nilfs2_ondisk.h | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-)
fs/nilfs2/super.c +3 -0
@@ -872,6 +872,9 @@ int nilfs_store_magic(struct super_block *sb, nilfs->ns_resgid =le16_to_cpu (sbp->s_def_resgid); nilfs->ns_interval =le32_to_cpu (sbp->s_c_interval); nilfs->ns_watermark =le32_to_cpu (sbp->s_c_block_max); + nilfs->ns_feature_compat =le64_to_cpu (sbp->s_feature_compat); + nilfs->ns_feature_compat_ro =le64_to_cpu (sbp->s_feature_compat_ro); + nilfs->ns_feature_incompat =le64_to_cpu (sbp->s_feature_incompat);return 0 ; }
fs/nilfs2/the_nilfs.h +6 -0
@@ -86,6 +86,9 @@ enum {* @ns_inode_size: size of on-disk inode * @ns_first_ino: first not-special inode number * @ns_crc_seed: seed value of CRC32 calculation +* @ns_feature_compat: compat feature flags +* @ns_feature_compat_ro: read-only compat feature flags +* @ns_feature_incompat: incompat feature flags * @ns_dev_kobj: /sys/fs/<nilfs>/<device> * @ns_dev_kobj_unregister: completion state * @ns_dev_subgroups: <device> subgroups pointer
@@ -178,6 +181,9 @@ struct the_nilfs {int ns_inode_size;unsigned int ns_first_ino;u32 ns_crc_seed; +__u64 ns_feature_compat; +__u64 ns_feature_compat_ro; +__u64 ns_feature_incompat;/* /sys/fs/<nilfs>/<device> */ struct kobject ns_dev_kobj;
include/uapi/linux/nilfs2_ondisk.h +3 -1
@@ -253,9 +253,11 @@ struct nilfs_super_block {* doesn't know about, it should refuse to mount the filesystem. */ #define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 0x00000001ULL +#define NILFS_FEATURE_COMPAT_RO_ATIME 0x00000002ULL#define NILFS_FEATURE_COMPAT_SUPP 0ULL -#define NILFS_FEATURE_COMPAT_RO_SUPP NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT +#define NILFS_FEATURE_COMPAT_RO_SUPP (NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT |\ + NILFS_FEATURE_COMPAT_RO_ATIME)#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL/*
Signature · 1 line
2.53.0
Ryusuke Konishi
maintainerPATCH 2/2 nilfs2: introduce atime support
In reply to Ryusuke KonishiFrom: Viacheslav Dubeyko <[email protected]>
Currently, NILFS2 doesn't support atime. And it is possible to see the evidence of it by running generic/003 test-case of xfstests suite:
sudo ./check generic/003
FSTYP -- nilfs2
PLATFORM -- Linux/x86_64 hfsplus-testing-0001 6.18.0-rc1+ #10 SMP PREEMPT_DYNAMIC Fri Nov 28 20:48:25 PST 2025 MKFS_OPTIONS -- /dev/loop51MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch
generic/003 35s ... - output mismatch (see xfstests-dev/results//generic/003.out.bad)
This patch replaces i_xattr with i_atime and i_pad with i_atime_nsec in struct nilfs_inode of the on-disk layout, and instead of unconditionally disabling filesystem-level atime support, makes it toggleable via the atime compat_ro feature flag. Also, it modifies nilfs_read_inode_common() and nilfs_write_inode_common() with the goal of proper atime support.
sudo ./check generic/003
FSTYP -- nilfs2 PLATFORM -- Linux/x86_64 nilfs2-testing 6.19.0-rc1+ #8 SMP PREEMPT_DYNAMIC Tue Feb 17 16:21:59 PST 2026 MKFS_OPTIONS -- /dev/loop51
MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch
generic/003 30s ... 34s
Ran: generic/003
Passed all 1 tests
[1] https://github.com/nilfs-dev/nilfs2/issues/7
--- fs/nilfs2/Kconfig | 2 +- fs/nilfs2/inode.c | 11 +++++++++-- fs/nilfs2/nilfs.h | 4 ---- fs/nilfs2/segment.c | 2 -- fs/nilfs2/super.c | 8 +++----- include/uapi/linux/nilfs2_ondisk.h | 8 ++++---- 6 files changed, 17 insertions(+), 18 deletions(-)
fs/nilfs2/Kconfig +1 -1
@@ -20,7 +20,7 @@ config NILFS2_FS snapshot is mountable as a read-only file system concurrently with its writable mount, and this feature is convenient for online backup. - Some features including atime, extended attributes, and POSIX ACLs, + Some features including extended attributes, and POSIX ACLs, are not supported yet. To compile this file system support as a module, choose M here: the
fs/nilfs2/inode.c +9 -2
@@ -387,6 +387,7 @@ void nilfs_set_inode_flags(struct inode *inode)int nilfs_read_inode_common (struct inode *inode,struct nilfs_inode *raw_inode) { +struct the_nilfs *nilfs = inode->i_sb->s_fs_info;struct nilfs_inode_info *ii =NILFS_I (inode);int err;
@@ -395,8 +396,12 @@ int nilfs_read_inode_common(struct inode *inode,i_gid_write (inode,le32_to_cpu (raw_inode->i_gid));set_nlink (inode,le16_to_cpu (raw_inode->i_links_count)); inode->i_size =le64_to_cpu (raw_inode->i_size); -inode_set_atime (inode,le64_to_cpu (raw_inode->i_mtime), -le32_to_cpu (raw_inode->i_mtime_nsec)); +if (nilfs->ns_feature_compat_ro &NILFS_FEATURE_COMPAT_RO_ATIME ) +inode_set_atime (inode,le64_to_cpu (raw_inode->i_atime), +le32_to_cpu (raw_inode->i_atime_nsec)); +else +inode_set_atime (inode,le64_to_cpu (raw_inode->i_mtime), +le32_to_cpu (raw_inode->i_mtime_nsec));inode_set_ctime (inode,le64_to_cpu (raw_inode->i_ctime),le32_to_cpu (raw_inode->i_ctime_nsec)); inode_set_mtime(inode, le64_to_cpu(raw_inode->i_mtime),
@@ -702,8 +707,10 @@ void nilfs_write_inode_common(struct inode *inode, raw_inode->i_gid =cpu_to_le32 (i_gid_read (inode)); raw_inode->i_links_count =cpu_to_le16 (inode->i_nlink); raw_inode->i_size =cpu_to_le64 (inode->i_size); + raw_inode->i_atime =cpu_to_le64 (inode_get_atime_sec (inode)); raw_inode->i_ctime =cpu_to_le64 (inode_get_ctime_sec (inode)); raw_inode->i_mtime =cpu_to_le64 (inode_get_mtime_sec (inode)); + raw_inode->i_atime_nsec =cpu_to_le32 (inode_get_atime_nsec (inode)); raw_inode->i_ctime_nsec =cpu_to_le32 (inode_get_ctime_nsec (inode)); raw_inode->i_mtime_nsec =cpu_to_le32 (inode_get_mtime_nsec (inode)); raw_inode->i_blocks =cpu_to_le64 (inode->i_blocks);
fs/nilfs2/nilfs.h +0 -4
@@ -27,7 +27,6 @@* @i_state: dynamic state flags * @i_bmap: pointer on i_bmap_data * @i_bmap_data: raw block mapping -* @i_xattr: <TODO> * @i_dir_start_lookup: page index of last successful search * @i_cno: checkpoint number for GC inode * @i_assoc_inode: associated inode (B-tree node cache holder or back pointer)
@@ -43,7 +42,6 @@ struct nilfs_inode_info {unsigned long i_state;/* Dynamic state flags */ struct nilfs_bmap *i_bmap;struct nilfs_bmap i_bmap_data; -__u64 i_xattr;/* sector_t ??? */ __u32 i_dir_start_lookup;__u64 i_cno;/* check point number for GC inode */ struct inode *i_assoc_inode;
@@ -234,8 +232,6 @@ static inline int nilfs_init_acl(struct inode *inode, struct inode *dir) }#endif -#define NILFS_ATIME_DISABLE -/* Flags that should be inherited by new inodes from their parent. */ #define NILFS_FL_INHERITED \ (FS_SECRM_FL | FS_UNRM_FL | FS_COMPR_FL | FS_SYNC_FL | \
fs/nilfs2/segment.c +0 -2
@@ -930,8 +930,6 @@ static void nilfs_write_root_mdt_inode(struct inode *inode,nilfs_write_inode_common (inode, raw_inode);/* zero-fill unused portion of raw_inode */ - raw_inode->i_xattr =0 ; - raw_inode->i_pad =0 ;memset ((void *)raw_inode +sizeof (*raw_inode),0 , nilfs->ns_inode_size -sizeof (*raw_inode));
fs/nilfs2/super.c +3 -5
@@ -863,11 +863,6 @@ int nilfs_store_magic(struct super_block *sb, sb->s_magic =le16_to_cpu (sbp->s_magic); -/* FS independent flags */ -#ifdef NILFS_ATIME_DISABLE - sb->s_flags |=SB_NOATIME ; -#endif - nilfs->ns_resuid =le16_to_cpu (sbp->s_def_resuid); nilfs->ns_resgid =le16_to_cpu (sbp->s_def_resgid); nilfs->ns_interval =le32_to_cpu (sbp->s_c_interval);
@@ -876,6 +871,9 @@ int nilfs_store_magic(struct super_block *sb, nilfs->ns_feature_compat_ro =le64_to_cpu (sbp->s_feature_compat_ro); nilfs->ns_feature_incompat =le64_to_cpu (sbp->s_feature_incompat); +if (!(nilfs->ns_feature_compat_ro &NILFS_FEATURE_COMPAT_RO_ATIME )) + sb->s_flags |=SB_NOATIME ; +return 0 ; }
include/uapi/linux/nilfs2_ondisk.h +4 -4
@@ -47,9 +47,9 @@* @i_links_count: links count * @i_flags: file flags * @i_bmap: block mapping -* @i_xattr: extended attributes +* @i_atime: access time (seconds) * @i_generation: file generation (for NFS) -* @i_pad: padding +* @i_atime_nsec: access time (nano seconds) */ struct nilfs_inode {__le64 i_blocks;
@@ -65,9 +65,9 @@ struct nilfs_inode {__le32 i_flags;__le64 i_bmap[NILFS_INODE_BMAP_SIZE ];#define i_device_code i_bmap[0] -__le64 i_xattr; +__le64 i_atime;__le32 i_generation; -__le32 i_pad; +__le32 i_atime_nsec; };#define NILFS_MIN_INODE_SIZE 128
Signature · 1 line
2.53.0
Quoted 74 lines · Ryusuke Konishi
Hi Viacheslav,
Please queue the following two patches for persistent atime support in
nilfs2 for the next merge window.This series builds upon your original patch [1], which Wang Jianjian followed up on to address review comments and add
compat_rofeature flag
support [2][3]. I have made minor modifications to those patches, including filling in missing kernel-doc comments and adjusting the commit messages (such as fixing the Co-developed-by tags).To use this feature, install the updated nilfs-utils from the 'atime-support' branch of the development repository [4] (which will be
merged into the master branch once this patchset is queued), and either
format a new filesystem with the atime feature enabled:$ sudo mkfs -t nilfs2 -O atime /dev/<device>or enable the feature flag on an existing filesystem image using nilfs-tune:
$ sudo nilfs-tune -O atime /dev/<device>Once the atime feature flag is set, the filesystem can only be mounted
read-only on currently deployed kernels that lack support for it (until
the flag is cleared with "nilfs-tune -O ^atime /dev/<device>"). To avoid confusing users, this feature will remain optional in mkfs.nilfs2
for the time being, though I plan to enable it by default in a future release of nilfs-utils.Note that when enabling the feature on an existing filesystem, inodes written by older mkfs or kernels have their on-disk atime fields initialized to 0, which will expose the epoch date (1970-01-01). nilfs-tune warns about this when setting the flag, and image conversion
(such as copying mtime to atime) is not supported.The series consists of two patches:
- Patch 1/2 introduces the read-only compat feature flag (
NILFS_FEATURE_COMPAT_RO_ATIME) to manage on-disk format compatibility
for atime support.
- Patch 2/2 reads atime from on-disk inodes when thecompat_roflag is
enabled and stops unconditionally settingSB_NOATIMEon the superblock,
switching VFS behavior accordingly.[1]
https://lore.kernel.org/all/[email protected]
[2]
https://lore.kernel.org/all/[email protected]
[3]
https://lore.kernel.org/all/[email protected]
[4] https://github.com/nilfs-dev/nilfs-utils.gitThanks,
Ryusuke KonishiViacheslav Dubeyko (1):
nilfs2: introduce atime supportWang Jianjian (1):
nilfs2: add atimecompat_rofeature
Quoted 8 lines
fs/nilfs2/Kconfig | 2 +- fs/nilfs2/inode.c | 11 +++++++++-- fs/nilfs2/nilfs.h | 4 ----fs/nilfs2/segment.c | 2 -- fs/nilfs2/super.c | 11 ++++++----- fs/nilfs2/the_nilfs.h | 6 ++++++
include/uapi/linux/nilfs2_ondisk.h| 12 +++++++-----7 files changed, 29 insertions(+), 19 deletions(-)
Applied.
Thanks,
Slava.