mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: Xuewen Wang <wangxuewen@kylinos.cn>,
	linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	Baolin Liu <liubaolin@kylinos.cn>
Subject: Re: [PATCH v1] ntfs: support persistent noatime attribute
Date: Fri, 16 Oct 2026 12:23:03 +0800	[thread overview]
Message-ID: <3f23f6d5-0699-4c16-a1c0-a3d97139e5dc@163.com> (raw)
In-Reply-To: <20261016030957.1053110-1-wangxuewen@kylinos.cn>



在 2026/10/16 11:09, Xuewen Wang 写道:
> NTFS currently rejects FS_NOATIME_FL in its fileattr setter. This prevents
> users from disabling automatic access-time updates on individual files or
> directories with chattr +A.
> 
> Store noatime in bit 3 of the private $LINUXFLAGS EA and restore S_NOATIME
> when loading an inode. Report and accept FS_NOATIME_FL in the fileattr
> callbacks, updating the in-memory flag only after the EA update succeeds.
> The VFS then suppresses automatic atime updates for the inode, while
> chattr -A restores the mount's atime policy.
> 
> Document the new on-disk bit and that newly created children do not inherit
> the attribute.
> 
> Suggested-by: Baolin Liu <liubaolin@kylinos.cn>
> Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
> Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>
> ---
> Tested in QEMU (x86-64, UP, NTFS debug and lockdep enabled) on disposable
> NTFS images mounted with strictatime. The unpatched kernel rejects +A on
> files and directories with EOPNOTSUPP. With this patch, chattr +A prevents
> atime updates on reads and directory enumeration, and chattr -A restores
> them. The attribute survives cache dropping, read-only/read-write remounts,
> unmount/mount and a fresh boot; clearing it also survives a fresh boot.
> 
> Also checked the on-disk EA value, non-inheritance by new children,
> combinations with immutable/append-only/nodump, FSGETXATTR/FSSETXATTR,
> owner/nonowner permissions, EROFS on a read-only mount, rejection of direct
> EA writes, and preservation of unrelated EAs and unknown flag bits.
> 
>   Documentation/filesystems/ntfs.rst | 15 ++++++++++-----
>   fs/ntfs/ea.c                       |  2 ++
>   fs/ntfs/ea.h                       |  4 +++-
>   fs/ntfs/file.c                     | 11 +++++++++--
>   4 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/filesystems/ntfs.rst b/Documentation/filesystems/ntfs.rst
> index 699e91f884d4..d5819da6ab53 100644
> --- a/Documentation/filesystems/ntfs.rst
> +++ b/Documentation/filesystems/ntfs.rst
> @@ -38,15 +38,20 @@ The project is available at:
>   Linux file attributes
>   =====================
>   
> -The driver supports lsattr(1) and chattr(1). Immutable, append-only and
> -nodump are stored in a private ``$LINUXFLAGS`` extended attribute within the
> +The driver supports lsattr(1) and chattr(1). Immutable, append-only, nodump
> +and noatime are stored in a private ``$LINUXFLAGS`` extended attribute within the
>   standard NTFS ``$EA``/``$EA_INFORMATION`` attributes. Its value is a
>   32-bit little-endian bitmask: bit 0 is immutable, bit 1 is append-only,
> -and bit 2 is nodump. Unknown bits are preserved when updating the flags;
> -the entry is removed when the entire value becomes zero. These settings
> +bit 2 is nodump, and bit 3 is noatime. Unknown bits are preserved when updating
> +the flags; the entry is removed when the entire value becomes zero. These settings
>   survive inode eviction, unmount and reboot. Direct writes to this EA
>   through setxattr(2) or removexattr(2) are rejected; use chattr(1) instead.
>   
> +The noatime attribute (``chattr +A``) suppresses automatic access-time
> +updates for the inode, including when mounted with ``strictatime``. It
> +applies to directories as well as files, but is not inherited by newly
> +created children. Use ``chattr -A`` to restore the mount's access-time policy.
> +
>   System metadata files and files protected by the ``sys_immutable`` mount
>   option cannot have their immutable protection cleared with chattr(1).
>   Protection derived solely from the mount option is not stored in the EA.
> @@ -55,7 +60,7 @@ configured per file. Compression and encryption are reported but cannot
>   be changed through chattr(1).
>   
>   These Linux flags are enforced by Linux. Storing them in an NTFS EA does
> -not make Windows enforce immutable, append-only or nodump semantics.
> +not make Windows enforce immutable, append-only, nodump or noatime semantics.
>   
>   
>   Supported mount options
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index a1f948c4d2ec..fd97da73ff5c 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -501,6 +501,8 @@ int ntfs_ea_get_linuxflags(struct inode *inode)
>   		inode->i_flags |= S_IMMUTABLE;
>   	if (ni->linuxflags & NTFS_LINUXFLAGS_APPEND)
>   		inode->i_flags |= S_APPEND;
> +	if (ni->linuxflags & NTFS_LINUXFLAGS_NOATIME)
> +		inode->i_flags |= S_NOATIME;
>   	return 0;
>   }
>   
> diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
> index 8f144fa4f9bb..3ad20431877b 100644
> --- a/fs/ntfs/ea.h
> +++ b/fs/ntfs/ea.h
> @@ -11,8 +11,10 @@
>   #define NTFS_LINUXFLAGS_IMMUTABLE	BIT(0)
>   #define NTFS_LINUXFLAGS_APPEND	BIT(1)
>   #define NTFS_LINUXFLAGS_NODUMP	BIT(2)
> +#define NTFS_LINUXFLAGS_NOATIME	BIT(3)
>   #define NTFS_LINUXFLAGS_MASK	(NTFS_LINUXFLAGS_IMMUTABLE | \
> -				 NTFS_LINUXFLAGS_APPEND | NTFS_LINUXFLAGS_NODUMP)
> +				 NTFS_LINUXFLAGS_APPEND | NTFS_LINUXFLAGS_NODUMP | \
> +				 NTFS_LINUXFLAGS_NOATIME)
>   
>   extern const struct xattr_handler *const ntfs_xattr_handlers[];
>   
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 58aad7f5c6c5..2cbe780758e3 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -167,6 +167,8 @@ int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
>   		flags |= FS_IMMUTABLE_FL;
>   	if (vi->i_flags & S_APPEND)
>   		flags |= FS_APPEND_FL;
> +	if (vi->i_flags & S_NOATIME)
> +		flags |= FS_NOATIME_FL;
>   	if (ni->linuxflags & NTFS_LINUXFLAGS_NODUMP)
>   		flags |= FS_NODUMP_FL;
>   	if (!NVolCaseSensitive(ni->vol))
> @@ -200,7 +202,8 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
>   {
>   	struct inode *vi = d_inode(dentry);
>   	struct ntfs_inode *ni = NTFS_I(vi);
> -	u32 allowed = FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL;
> +	u32 allowed = FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL |
> +		      FS_NOATIME_FL;
>   	u32 readonly = 0;
>   	u32 linuxflags = ni->linuxflags & ~NTFS_LINUXFLAGS_MASK;
>   	unsigned int new_fl = 0;
> @@ -245,6 +248,10 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
>   	}
>   	if (fa->flags & FS_NODUMP_FL)
>   		linuxflags |= NTFS_LINUXFLAGS_NODUMP;
> +	if (fa->flags & FS_NOATIME_FL) {
> +		new_fl |= S_NOATIME;
> +		linuxflags |= NTFS_LINUXFLAGS_NOATIME;
> +	}
>   
>   	mutex_lock(&ni->mrec_lock);
>   	err = ntfs_ea_set_linuxflags(vi, linuxflags);
> @@ -252,7 +259,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
>   	if (err)
>   		return err;
>   
> -	inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND);
> +	inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND | S_NOATIME);
>   	inode_set_ctime_current(vi);
>   	mark_inode_dirty(vi);
>   	return 0;


Looks good to me.

Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>


  reply	other threads:[~2026-10-16  4:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  3:09 Xuewen Wang
2026-10-16  4:23 ` liubaolin [this message]
2026-10-16  6:41 ` Hyunchul Lee
2026-10-17  1:34 ` Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f23f6d5-0699-4c16-a1c0-a3d97139e5dc@163.com \
    --to=liubaolin12138@163.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin@kylinos.cn \
    --cc=ntfs@lists.linux.dev \
    --cc=wangxuewen@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®