From: Jeff Layton <jlayton@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH] statx: add STATX_ATTR_MULTIGRAIN_TIMESTAMP
Date: Thu, 29 Oct 2026 12:28:16 -0400 [thread overview]
Message-ID: <20261029-mgtime-statx-v1-1-175b5afdf2fb@kernel.org> (raw)
Userland has no way to tell whether a file's timestamps are multigrain,
i.e. whether successive changes after a query are guaranteed to yield
distinct timestamps.
Add STATX_ATTR_MULTIGRAIN_TIMESTAMP and set it in vfs_getattr_nosec()
when is_mgtime() is true (IOP_MGTIME is set from FS_MGTIME at inode
init). Always advertise it in attributes_mask.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
HCH suggested this when I posted the fstest for multigrain timestamps. I
think it makes sense. If this looks good, I'll plan to send a manpage
update for statx(2).
---
fs/stat.c | 6 +++++-
include/uapi/linux/stat.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/stat.c b/fs/stat.c
index a2e63c6c45b7..67b9f1784b23 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -206,9 +206,13 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
if (IS_VERITY(inode))
stat->attributes |= STATX_ATTR_VERITY;
+ if (is_mgtime(inode))
+ stat->attributes |= STATX_ATTR_MULTIGRAIN_TIMESTAMP;
+
stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT |
STATX_ATTR_DAX |
- STATX_ATTR_VERITY);
+ STATX_ATTR_VERITY |
+ STATX_ATTR_MULTIGRAIN_TIMESTAMP);
idmap = mnt_idmap(path->mnt);
if (inode->i_op->getattr) {
diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h
index 1686861aae20..b978860590b1 100644
--- a/include/uapi/linux/stat.h
+++ b/include/uapi/linux/stat.h
@@ -255,6 +255,7 @@ struct statx {
#define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */
#define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */
#define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */
+#define STATX_ATTR_MULTIGRAIN_TIMESTAMP 0x00800000 /* File uses multigrain timestamps */
#endif /* _UAPI_LINUX_STAT_H */
---
base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
change-id: 20261029-mgtime-statx-26a229f9c3b4
Best regards,
--
Jeff Layton <jlayton@kernel.org>
reply other threads:[~2026-10-29 16:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261029-mgtime-statx-v1-1-175b5afdf2fb@kernel.org \
--to=jlayton@kernel.org \
--cc=brauner@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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