From: "koraynilay" <koray.fra@gmail.com>
To: "Amir Goldstein" <amir73il@gmail.com>,
"koraynilay" <koray.fra@gmail.com>
Cc: "David Sterba" <dsterba@suse.com>,
"Namjae Jeon" <linkinjeon@kernel.org>,
"Sungjong Seo" <sj1557.seo@samsung.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Trond Myklebust" <trondmy@kernel.org>,
"Anna Schumaker" <anna@kernel.org>,
"Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>,
"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
"Paulo Alcantara" <pc@manguebit.org>,
"Chris Mason" <mason@kernel.org>,
"Yuezhang Mo" <yuezhang.mo@sony.com>, "Jan Kara" <jack@suse.cz>,
NeilBrown <neil@brown.name>,
"Olga Kornievskaia" <okorniev@redhat.com>,
"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
"Ronnie Sahlberg" <ronniesahlberg@gmail.com>,
"Shyam Prasad N" <sprasad@microsoft.com>,
"Bharath SM" <bharathsm@microsoft.com>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
ChenXiaoSong <chenxiaosong@chenxiaosong.com>,
"Darrick J . Wong" <djwong@kernel.org>,
"Sean Smith" <defendthedisabled@gmail.com>,
"Andrey Albershteyn" <aalbersh@kernel.org>,
"Pedro Falcato" <pfalcato@suse.de>,
"Pali Rohár" <pali@kernel.org>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, exfat@lists.linux.dev,
ntfs3@lists.linux.dev, linux-cifs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-api@vger.kernel.org
Subject: Re: [RFC PATCH v4 08/10] nfs: add provenance time (ptime) via FATTR4_TIME_CREATE
Date: Thu, 19 Nov 2026 23:10:04 +0100 [thread overview]
Message-ID: <DMZJ4PL1JVA4.2YEB7EPYJR5Q7@gmail.com> (raw)
In-Reply-To: <CAOQ4uxgoNsOH82FyrCxc+qSoid_CFmbmpL0qgWFw-e8E689fFA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 12703 bytes --]
On Thu Nov 19, 2026 at 7:06 PM CET, Amir Goldstein wrote:
> On Sun, Nov 15, 2026 at 7:04 PM koraynilay <koray.fra@gmail.com> wrote:
>>
>> Implement provenance time (ptime) in the NFS client, as introduced in a
>> previous commit ("vfs: add provenance time (ptime)").
>>
>> Support reading ptime via statx(2) and file_getattr(), returning the
>> cached creation time when the server advertises NFS_ATTR_FATTR_BTIME.
>>
>> Implement sending FATTR4_TIME_CREATE, asking the server to persist the
>> file creation time using ptime on the underlying filesystem.
>>
>> Also add .fileattr_set to struct nfs_rpc_ops and set it to
>> nfs4_fileattr_set() in nfs_v4_clientops. Provide a generic
>> nfs_fileattr_set() dispatcher so even symlinks can update ptime under
>> NFSv4 while cleanly returning -EOPNOTSUPP on NFSv2/v3.
>>
>> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7
>> Signed-off-by: koraynilay <koray.fra@gmail.com>
>> ---
>> fs/nfs/inode.c | 27 ++++++++++++++++----
>> fs/nfs/internal.h | 2 ++
>> fs/nfs/nfs4proc.c | 56 ++++++++++++++++++++++++++++++++++++++---
>> fs/nfs/nfs4xdr.c | 19 +++++++++-----
>> fs/nfs/symlink.c | 1 +
>> include/linux/nfs_xdr.h | 3 +++
>> 6 files changed, 93 insertions(+), 15 deletions(-)
>>
>> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
>> index e0a2e92952af..2ddcfd872616 100644
>> --- a/fs/nfs/inode.c
>> +++ b/fs/nfs/inode.c
>> @@ -955,7 +955,7 @@ static u32 nfs_get_valid_attrmask(struct inode *inode)
>> reply_mask |= STATX_BLOCKS;
>> if (!(cache_validity & NFS_INO_INVALID_BTIME) &&
>> (fattr_valid & NFS_ATTR_FATTR_BTIME))
>> - reply_mask |= STATX_BTIME;
>> + reply_mask |= STATX_BTIME | STATX_PTIME;
>> if (!(cache_validity & NFS_INO_INVALID_CHANGE))
>> reply_mask |= STATX_CHANGE_COOKIE;
>> return reply_mask;
>> @@ -978,10 +978,10 @@ int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> request_mask &= STATX_TYPE | STATX_MODE | STATX_NLINK | STATX_UID |
>> STATX_GID | STATX_ATIME | STATX_MTIME | STATX_CTIME |
>> STATX_INO | STATX_SIZE | STATX_BLOCKS | STATX_BTIME |
>> - STATX_CHANGE_COOKIE;
>> + STATX_PTIME | STATX_CHANGE_COOKIE;
>>
>> if (!(fattr_valid & NFS_ATTR_FATTR_BTIME))
>> - request_mask &= ~STATX_BTIME;
>> + request_mask &= ~(STATX_BTIME | STATX_PTIME);
>>
>> if ((query_flags & AT_STATX_DONT_SYNC) && !force_sync) {
>> if (readdirplus_enabled)
>> @@ -1015,7 +1015,7 @@ int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> if (!(request_mask & (STATX_MODE|STATX_NLINK|STATX_ATIME|STATX_CTIME|
>> STATX_MTIME|STATX_UID|STATX_GID|
>> STATX_SIZE|STATX_BLOCKS|STATX_BTIME|
>> - STATX_CHANGE_COOKIE)))
>> + STATX_PTIME|STATX_CHANGE_COOKIE)))
>> goto out_no_revalidate;
>>
>> /* Check whether the cached attributes are stale */
>> @@ -1038,7 +1038,7 @@ int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> do_update |= cache_validity & NFS_INO_INVALID_OTHER;
>> if (request_mask & STATX_BLOCKS)
>> do_update |= cache_validity & NFS_INO_INVALID_BLOCKS;
>> - if (request_mask & STATX_BTIME)
>> + if (request_mask & (STATX_BTIME | STATX_PTIME))
>> do_update |= cache_validity & NFS_INO_INVALID_BTIME;
>>
>> if (do_update) {
>> @@ -1061,6 +1061,7 @@ int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> if (S_ISDIR(inode->i_mode))
>> stat->blksize = NFS_SERVER(inode)->dtsize;
>> stat->btime = NFS_I(inode)->btime;
>> + stat->ptime = NFS_I(inode)->btime;
>>
>
> As an example of what would be needed per the mutable btime proposal,
> adding stat->ptime and STATX_PTIME will not be needed...
>
>> /* Special handling for STATX_DIOALIGN and STATX_DIO_READ_ALIGN
>> * - NFS doesn't have DIO alignment constraints, avoid getting
>> @@ -1092,10 +1093,26 @@ int nfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
>> }
>> if (nfs_server_capable(inode, NFS_CAP_CASE_NONPRESERVING))
>> fa->fsx_xflags |= FS_XFLAG_CASENONPRESERVING;
>
> This would need:
> fa->fsx_xflags |= FS_XFLAG_CASEFOLD;
> + fa->fsx_xflags_mask |= FS_XFLAG_CASEFOLD;
> + fa->fsx_xflags_ro_mask |= FS_XFLAG_CASEFOLD;
> + /* unlink other fs FS_CASEFOLD_FL is read-only */
(oh, s/unlink/unlike/?)
> fa->flags |= FS_CASEFOLD_FL;
With the new API and vfs helpers, this would need to get removed, as vfs
would already handle this for legacy ioctls, correct?
> }
> fa->fsx_xflags |= FS_XFLAG_CASENONPRESERVING;
> + fa->fsx_xflags_mask |= FS_XFLAG_CASENONPRESERVING;
> + fa->fsx_xflags_ro_mask |= FS_XFLAG_CASENONPRESERVING;
Uhm, why both in _mask and _ro_mask? If it's a RDONLY flag shouldn't
it *only* be in _ro_mask? (same for CASEFOLD)
>
>> + if (NFS_SERVER(inode)->fattr_valid & NFS_ATTR_FATTR_BTIME) {
>> + fa->fsx_xflags |= FS_XFLAG_PTIME;
>> + fa->fsx_xflags_mask |= FS_XFLAG_PTIME;
>> + fa->fsx_ptime = NFS_I(inode)->btime;
>> + }
>
> + fa->fsx_xflags |= FS_XFLAG_BTIME;
> + fa->fsx_xflags_mask |= FS_XFLAG_BTIME;
> + fa->fsx_btime = NFS_I(inode)->btime;
>
> Fs with immutable btime could either not advertise the BTIME flag
> in xflags/xflags_mask or advertise the flag also in xflags_ro_mask.
That makes sense.
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(nfs_fileattr_get);
>>
>> +int nfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
>> + struct file_kattr *fa)
>> +{
>> + const struct nfs_rpc_ops *ops = NFS_PROTO(d_inode(dentry));
>> +
>> + if (ops->fileattr_set)
>> + return ops->fileattr_set(idmap, dentry, fa);
>> + return -EOPNOTSUPP;
>> +}
>> +EXPORT_SYMBOL_GPL(nfs_fileattr_set);
>> +
>> static void nfs_init_lock_context(struct nfs_lock_context *l_ctx)
>> {
>> refcount_set(&l_ctx->count, 1);
>> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
>> index 5af6a032f145..0e47fad944de 100644
>> --- a/fs/nfs/internal.h
>> +++ b/fs/nfs/internal.h
>> @@ -458,6 +458,8 @@ extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
>>
>> struct file_kattr;
>> int nfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
>> +int nfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
>> + struct file_kattr *fa);
>>
>> #if IS_ENABLED(CONFIG_NFS_LOCALIO)
>> /* localio.c */
>> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
>> index e1018b03c1cb..31d58ceb4dc0 100644
>> --- a/fs/nfs/nfs4proc.c
>> +++ b/fs/nfs/nfs4proc.c
>> @@ -55,6 +55,7 @@
>> #include <linux/utsname.h>
>> #include <linux/freezer.h>
>> #include <linux/iversion.h>
>> +#include <linux/fileattr.h>
>>
>> #include "nfs4_fs.h"
>> #include "delegation.h"
>> @@ -98,7 +99,8 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
>> struct nfs_fattr *fattr, struct inode *inode);
>> static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
>> struct nfs_fattr *fattr, struct iattr *sattr,
>> - struct nfs_open_context *ctx, struct nfs4_label *ilabel);
>> + struct nfs_open_context *ctx, struct nfs4_label *ilabel,
>> + const struct timespec64 *time_create);
>> static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
>> const struct cred *cred,
>> struct nfs4_slot *slot,
>> @@ -3216,7 +3218,7 @@ static int _nfs4_do_open(struct inode *dir,
>> nfs_fattr_init(opendata->o_res.f_attr);
>> status = nfs4_do_setattr(state->inode, cred,
>> opendata->o_res.f_attr, sattr,
>> - ctx, label);
>> + ctx, label, NULL);
>> if (status == 0) {
>> nfs_setattr_update_inode(state->inode, sattr,
>> opendata->o_res.f_attr);
>> @@ -3380,7 +3382,8 @@ static int _nfs4_do_setattr(struct inode *inode,
>>
>> static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
>> struct nfs_fattr *fattr, struct iattr *sattr,
>> - struct nfs_open_context *ctx, struct nfs4_label *ilabel)
>> + struct nfs_open_context *ctx, struct nfs4_label *ilabel,
>> + const struct timespec64 *time_create)
>> {
>> struct nfs_server *server = NFS_SERVER(inode);
>> __u32 bitmask[NFS4_BITMASK_SZ];
>> @@ -3391,6 +3394,7 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
>> .server = server,
>> .bitmask = bitmask,
>> .label = ilabel,
>> + .time_create = time_create,
>> };
>> struct nfs_setattrres res = {
>> .fattr = fattr,
>> @@ -3414,6 +3418,9 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
>> if (sattr->ia_valid & ATTR_MTIME)
>> adjust_flags |= NFS_INO_INVALID_MTIME;
>>
>> + if (time_create)
>> + adjust_flags |= NFS_INO_INVALID_BTIME;
>> +
>> do {
>> nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, fattr->label),
>> inode, adjust_flags);
>> @@ -4587,7 +4594,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
>> if ((sattr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
>> nfs4_inode_make_writeable(inode);
>>
>> - status = nfs4_do_setattr(inode, cred, fattr, sattr, ctx, NULL);
>> + status = nfs4_do_setattr(inode, cred, fattr, sattr, ctx, NULL, NULL);
>> if (status == 0) {
>> nfs_setattr_update_inode(inode, sattr, fattr);
>> nfs_setsecurity(inode, fattr);
>> @@ -10845,6 +10852,44 @@ static void nfs4_disable_swap(struct inode *inode)
>> wake_up_var(&clp->cl_state);
>> }
>>
>> +#define NFS4_SUPPORTED_XFLAGS (FS_XFLAG_PTIME)
>> +static int nfs4_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
>> + struct file_kattr *fa)
>> +{
>> + struct inode *inode = d_inode(dentry);
>> + struct nfs_server *server = NFS_SERVER(inode);
>> + struct nfs_fattr *fattr;
>> + struct iattr sattr = { .ia_valid = 0 };
>> + const struct timespec64 *time_create = NULL;
>> + int error;
>> +
>> + if (!(server->fattr_valid & NFS_ATTR_FATTR_BTIME))
>> + return -EOPNOTSUPP;
>> +
>> + if (fa->flags_valid)
>> + return -EOPNOTSUPP;
>> +
>> + if (fileattr_has_fsx_mask(fa, NFS4_SUPPORTED_XFLAGS))
>> + return -EOPNOTSUPP;
>> +
>> + if (fa->fsx_xflags_mask & ~NFS4_SUPPORTED_XFLAGS)
>> + return -EOPNOTSUPP;
>> +
>
> These two checks look semantically identical.
> I am not sure yet what you intention was with the
> fileattr_has_fsx_mask() helper - I know you had reservations about it
> but at least in this code, it doesn't look like it is needed at all.
Eh, the name is not the best, but they aren't, _mask & check the _mask
field, has_fsx_mask checks the xflags field (which is why I added the
question of keeping its name as it is or changing it to
"fileattr_has_unsupported_fsx").
But I'm not even sure we still need this helper, so I may just drop it.
Thanks,
koraynilay
>> + if (fa->fsx_xflags_mask & FS_XFLAG_PTIME)
>> + time_create = &fa->fsx_ptime;
>
> This would be BTIME/btime but otherwise the same.
>
> Thanks,
> Amir.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-19 22:10 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 18:03 [RFC PATCH v4 00/10] add provenance time (ptime) koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 01/10] vfs: " koraynilay
2026-11-16 20:10 ` Amir Goldstein
2026-11-16 20:53 ` koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 02/10] vfs: add fileattr_has_fsx_mask() koraynilay
2026-11-19 19:36 ` Amir Goldstein
2026-11-19 22:12 ` koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 03/10] ntfs3: make crtime user-settable using ptime koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 04/10] exfat: " koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 05/10] btrfs: add provenance time (ptime) koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 06/10] vfs: add __vfs_fileattr_set_locked() for inode_lock()'d callers koraynilay
2026-11-16 13:52 ` Amir Goldstein
2026-11-16 15:55 ` koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 07/10] nfsd: add provenance time (ptime) via FATTR4_TIME_CREATE koraynilay
2026-11-17 22:01 ` Chuck Lever
2026-11-18 0:35 ` koraynilay
2026-11-18 7:44 ` Amir Goldstein
2026-11-18 16:09 ` Chuck Lever
2026-11-18 16:36 ` Amir Goldstein
2026-11-18 17:14 ` Chuck Lever
2026-11-18 17:23 ` koraynilay
2026-11-18 17:37 ` Amir Goldstein
2026-11-15 18:03 ` [RFC PATCH v4 08/10] nfs: " koraynilay
2026-11-19 18:06 ` Amir Goldstein
2026-11-19 22:10 ` koraynilay [this message]
2026-11-15 18:03 ` [RFC PATCH v4 09/10] ksmbd: add provenance time (ptime) and map it to CreationTime koraynilay
2026-11-19 17:34 ` Amir Goldstein
2026-11-19 21:51 ` koraynilay
2026-11-19 22:09 ` Pali Rohár
2026-11-19 22:25 ` koraynilay
2026-11-15 18:03 ` [RFC PATCH v4 10/10] cifs: add provenance time (ptime) and map it to SMB's CreationTime koraynilay
2026-11-19 18:32 ` Amir Goldstein
2026-11-19 22:02 ` koraynilay
2026-11-17 23:53 ` [RFC PATCH v4 00/10] add provenance time (ptime) Jeff Layton
2026-11-18 1:09 ` koraynilay
2026-11-18 8:14 ` Amir Goldstein
2026-11-18 9:34 ` koraynilay
2026-11-18 13:39 ` Amir Goldstein
2026-11-18 13:58 ` koraynilay
2026-11-18 13:45 ` Jeff Layton
2026-11-18 14:03 ` koraynilay
2026-11-18 14:26 ` Pali Rohár
2026-11-18 14:58 ` koraynilay
2026-11-18 15:16 ` Pali Rohár
2026-11-18 16:50 ` koraynilay
2026-11-18 17:22 ` Pali Rohár
2026-11-18 17:28 ` Amir Goldstein
2026-11-18 17:36 ` Jeff Layton
2026-11-18 17:50 ` Amir Goldstein
2026-11-18 17:37 ` Pali Rohár
2026-11-18 17:42 ` Amir Goldstein
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=DMZJ4PL1JVA4.2YEB7EPYJR5Q7@gmail.com \
--to=koray.fra@gmail.com \
--cc=Dai.Ngo@oracle.com \
--cc=aalbersh@kernel.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=amir73il@gmail.com \
--cc=anna@kernel.org \
--cc=bharathsm@microsoft.com \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=chenxiaosong@chenxiaosong.com \
--cc=defendthedisabled@gmail.com \
--cc=djwong@kernel.org \
--cc=dsterba@suse.com \
--cc=exfat@lists.linux.dev \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=mason@kernel.org \
--cc=neil@brown.name \
--cc=ntfs3@lists.linux.dev \
--cc=okorniev@redhat.com \
--cc=pali@kernel.org \
--cc=pc@manguebit.org \
--cc=pfalcato@suse.de \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=sj1557.seo@samsung.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=yuezhang.mo@sony.com \
/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