mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] nilfs2: atime support
@ 2026-11-17  6:47 Ryusuke Konishi
  2026-11-17  6:47 ` [PATCH 1/2] nilfs2: add atime compat_ro feature Ryusuke Konishi
  2026-11-17  6:47 ` [PATCH 2/2] nilfs2: introduce atime support Ryusuke Konishi
  0 siblings, 2 replies; 3+ messages in thread
From: Ryusuke Konishi @ 2026-11-17  6:47 UTC (permalink / raw)
  To: Viacheslav Dubeyko; +Cc: Wang Jianjian, linux-nilfs, LKML

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/20260219204343.70117-1-slava@dubeyko.com
[2] https://lore.kernel.org/all/tencent_E3847A19056D4E914FACD269A3C77BAF0905@qq.com
[3] https://lore.kernel.org/all/tencent_F3CAF2061A8AE294D88513588FD3DE1F4806@qq.com
[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(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] nilfs2: add atime compat_ro feature
  2026-11-17  6:47 [PATCH 0/2] nilfs2: atime support Ryusuke Konishi
@ 2026-11-17  6:47 ` Ryusuke Konishi
  2026-11-17  6:47 ` [PATCH 2/2] nilfs2: introduce atime support Ryusuke Konishi
  1 sibling, 0 replies; 3+ messages in thread
From: Ryusuke Konishi @ 2026-11-17  6:47 UTC (permalink / raw)
  To: Viacheslav Dubeyko; +Cc: Wang Jianjian, linux-nilfs, LKML

From: Wang Jianjian <wangjianjian0@foxmail.com>

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]

Signed-off-by: Wang Jianjian <wangjianjian0@foxmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
 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(-)

diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 2e3b591c117c..f92bcf1a9544 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -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;
 }
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index 4776a70f01ae..5143dbae5788 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -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;
diff --git a/include/uapi/linux/nilfs2_ondisk.h b/include/uapi/linux/nilfs2_ondisk.h
index b3442b16ff6a..19587700c92c 100644
--- a/include/uapi/linux/nilfs2_ondisk.h
+++ b/include/uapi/linux/nilfs2_ondisk.h
@@ -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
 
 /*
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] nilfs2: introduce atime support
  2026-11-17  6:47 [PATCH 0/2] nilfs2: atime support Ryusuke Konishi
  2026-11-17  6:47 ` [PATCH 1/2] nilfs2: add atime compat_ro feature Ryusuke Konishi
@ 2026-11-17  6:47 ` Ryusuke Konishi
  1 sibling, 0 replies; 3+ messages in thread
From: Ryusuke Konishi @ 2026-11-17  6:47 UTC (permalink / raw)
  To: Viacheslav Dubeyko; +Cc: Wang Jianjian, linux-nilfs, LKML

From: Viacheslav Dubeyko <slava@dubeyko.com>

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/loop51
MOUNT_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

Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Co-developed-by: Wang Jianjian <wangjianjian0@foxmail.com>
Signed-off-by: Wang Jianjian <wangjianjian0@foxmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
---
 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(-)

diff --git a/fs/nilfs2/Kconfig b/fs/nilfs2/Kconfig
index 0a5ace60e6ab..79b99c33af06 100644
--- a/fs/nilfs2/Kconfig
+++ b/fs/nilfs2/Kconfig
@@ -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
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 6ddef3ab0c19..b217eee57c36 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -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);
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 40dd42133dc6..1cf9e38152a6 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -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 |		\
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index af0c3560444f..68b640a7aa5b 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -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));
 
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index f92bcf1a9544..ddad1e4f55ce 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -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;
 }
 
diff --git a/include/uapi/linux/nilfs2_ondisk.h b/include/uapi/linux/nilfs2_ondisk.h
index 19587700c92c..e94593137adb 100644
--- a/include/uapi/linux/nilfs2_ondisk.h
+++ b/include/uapi/linux/nilfs2_ondisk.h
@@ -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
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-17  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  6:47 [PATCH 0/2] nilfs2: atime support Ryusuke Konishi
2026-11-17  6:47 ` [PATCH 1/2] nilfs2: add atime compat_ro feature Ryusuke Konishi
2026-11-17  6:47 ` [PATCH 2/2] nilfs2: introduce atime support Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®