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,
"Miklos Szeredi" <miklos@szeredi.hu>
Subject: Re: [RFC PATCH v4 10/10] cifs: add provenance time (ptime) and map it to SMB's CreationTime
Date: Fri, 20 Nov 2026 15:05:53 +0100 [thread overview]
Message-ID: <DN03GJ80ZWNZ.9GM35HM4T48N@gmail.com> (raw)
In-Reply-To: <CAOQ4uxg8aVcWyNiFDk8djdn-M3xJcu_7-kRxVq9jjFsbcGp1ew@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 13086 bytes --]
On Fri Nov 20, 2026 at 7:34 AM CET, Amir Goldstein wrote:
> On Thu, Nov 19, 2026 at 11:02 PM koraynilay <koray.fra@gmail.com> wrote:
>>
>> On Thu Nov 19, 2026 at 7:32 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 cifs, as introduced in a
>> >> previous commit ("vfs: add provenance time (ptime)").
>> >>
>> >> Map it to SMB's CreationTime, making it settable from userspace and
>> >> propagating it to the SMB server via FILE_BASIC_INFO.
>> >>
>> >> Support reading ptime via statx(2) and fileattr_get() from the cached
>> >> CreationTime.
>> >>
>> >> Update cifs_fileattr_set() to check xflags instead of only legacy flags
>> >> and add the cifs_set_file_crtime() helper to wrap the RPC call to the
>> >> SMB server.
>> >>
>> >> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7
>> >> Signed-off-by: koraynilay <koray.fra@gmail.com>
>> >> ---
>> >> fs/smb/client/cifsfs.c | 8 +++
>> >> fs/smb/client/inode.c | 7 ++-
>> >> fs/smb/client/ioctl.c | 109 ++++++++++++++++++++++++++++++-----------
>> >> 3 files changed, 94 insertions(+), 30 deletions(-)
>> >>
>> >> diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
>> >> index 8cff7857b450..c2f557e406d3 100644
>> >> --- a/fs/smb/client/cifsfs.c
>> >> +++ b/fs/smb/client/cifsfs.c
>> >> @@ -1307,6 +1307,14 @@ int cifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
>> >> if (READ_ONCE(CIFS_I(inode)->cifsAttrs) & ATTR_COMPRESSED)
>> >> fa->flags |= FS_COMPR_FL;
>> >>
>> >> + /* Report provenance time (ptime) to userspace */
>> >> + if (CIFS_I(inode)->createtime) {
>> >> + fa->fsx_xflags |= FS_XFLAG_PTIME;
>> >> + fa->fsx_xflags_mask |= FS_XFLAG_PTIME;
>> >> + fa->fsx_ptime =
>> >> + cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
>> >> + }
>> >> +
>> >> /*
>> >> * FS_CASEFOLD_FL is defined by UAPI as a folder attribute,
>> >> * and userspace tools (e.g., lsattr) display it only on
>> >> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
>> >> index 2647785ec1e4..f0b20a72b9c2 100644
>> >> --- a/fs/smb/client/inode.c
>> >> +++ b/fs/smb/client/inode.c
>> >> @@ -222,6 +222,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,
>> >>
>> >> cifs_i->cifsAttrs = fattr->cf_cifsattrs;
>> >> cifs_i->reparse_tag = fattr->cf_cifstag;
>> >> + cifs_i->createtime = fattr->cf_createtime;
>> >>
>> >> if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
>> >> cifs_i->time = 0;
>> >> @@ -2958,7 +2959,8 @@ int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> >> * We need to be sure that all dirty pages are written and the server
>> >> * has actual ctime, mtime and file length.
>> >> */
>> >> - if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE | STATX_BLOCKS)) &&
>> >> + if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_PTIME
>> >> + | STATX_SIZE | STATX_BLOCKS)) &&
>> >> !CIFS_CACHE_READ(CIFS_I(inode)) &&
>> >> inode->i_mapping && inode->i_mapping->nrpages != 0) {
>> >> rc = filemap_fdatawait(inode->i_mapping);
>> >> @@ -2992,6 +2994,9 @@ int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
>> >> stat->result_mask |= STATX_BTIME;
>> >> stat->btime =
>> >> cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
>> >> + stat->result_mask |= STATX_PTIME;
>> >> + stat->ptime =
>> >> + cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
>> >> }
>> >>
>> >> stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED);
>> >> diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c
>> >> index bb8808289a46..19a9556d39b4 100644
>> >> --- a/fs/smb/client/ioctl.c
>> >> +++ b/fs/smb/client/ioctl.c
>> >> @@ -181,6 +181,41 @@ static int cifs_set_compression(unsigned int xid, struct dentry *dentry,
>> >> compression_state);
>> >> }
>> >>
>> >> +static int cifs_set_file_crtime(unsigned int xid, struct dentry *dentry,
>> >> + struct cifs_tcon *tcon, u64 crtime)
>> >> +{
>> >> + struct inode *inode = d_inode(dentry);
>> >> + struct TCP_Server_Info *server = tcon->ses->server;
>> >> + FILE_BASIC_INFO info_buf = {};
>> >> + const char *full_path;
>> >> + void *page;
>> >> + int rc;
>> >> +
>> >> + if (!server->ops->set_file_info)
>> >> + return -EOPNOTSUPP;
>> >> +
>> >> + info_buf.CreationTime = cpu_to_le64(crtime);
>> >> +
>> >> + page = alloc_dentry_path();
>> >> + full_path = build_path_from_dentry(dentry, page);
>> >> + if (IS_ERR(full_path)) {
>> >> + rc = PTR_ERR(full_path);
>> >> + goto out;
>> >> + }
>> >> +
>> >> + rc = server->ops->set_file_info(inode, full_path, &info_buf, xid);
>> >> + if (rc == 0) {
>> >> + CIFS_I(inode)->createtime = crtime;
>> >> + CIFS_I(inode)->time = 0;
>> >> + inode_set_ctime_current(inode);
>> >> + }
>> >> +
>> >> +out:
>> >> + free_dentry_path(page);
>> >> + return rc;
>> >> +}
>> >> +
>> >> +#define CIFS_SUPPORTED_XFLAGS (FS_XFLAG_PTIME)
>> >> int cifs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
>> >> struct file_kattr *fa)
>> >> {
>> >> @@ -193,49 +228,65 @@ int cifs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
>> >> bool enable_compression;
>> >> struct cifs_tcon *tcon;
>> >> unsigned int xid;
>> >> - int rc;
>> >> + int rc = 0;
>> >>
>> >> - if (!fa->flags_valid)
>> >> + if (fileattr_has_fsx_mask(fa, CIFS_SUPPORTED_XFLAGS))
>> >> return -EOPNOTSUPP;
>> >
>> > What is this supposed to check that is not already checked
>> > explicitly with fsx_xflags_mask below?
>>
>> It should work for FS_IOC_FSSETXATTR, where mask is 0... but it's also
>> there because when I started writing the various filesystems code I
>> hadn't added _mask yet, so I'll need to take a little step back and
>> revisit.
>>
>
> Yes, I see.
> I think the helper may still have value for fs that still parse the
> two types of flags.
Yeah maybe, I'll see after I the first vfs-only patch I think.
> To reduce the scope of your patch set this may be better.
>
>> >>
>> >> - /*
>> >> - * chattr writes back all flags returned by fileattr_get(). Accept
>> >> - * FS_CASEFOLD_FL only when it reflects the share's casefold state.
>> >> - */
>> >> - if (fa->flags & FS_CASEFOLD_FL) {
>> >> - rc = cifs_fileattr_get(dentry, ¤t_fa);
>> >> - if (rc)
>> >> - return rc;
>> >> - if (current_fa.flags & FS_CASEFOLD_FL)
>> >> - allowed |= FS_CASEFOLD_FL;
>> >> - }
>> >> - if (fa->flags & ~allowed)
>> >> + if (fa->fsx_xflags_mask & ~CIFS_SUPPORTED_XFLAGS)
>> >> return -EOPNOTSUPP;
>> >>
>> >> - enable_compression = fa->flags & FS_COMPR_FL;
>> >> - compression_state = enable_compression ? COMPRESSION_FORMAT_DEFAULT :
>> >> - COMPRESSION_FORMAT_NONE;
>> >> + if (fa->flags_valid) {
>> >> + /*
>> >> + * chattr writes back all flags returned by fileattr_get(). Accept
>> >> + * FS_CASEFOLD_FL only when it reflects the share's casefold state.
>> >> + */
>> >> + if (fa->flags & FS_CASEFOLD_FL) {
>> >> + rc = cifs_fileattr_get(dentry, ¤t_fa);
>> >> + if (rc)
>> >> + return rc;
>> >> + if (current_fa.flags & FS_CASEFOLD_FL)
>> >> + allowed |= FS_CASEFOLD_FL;
>> >> + }
>> >> + if (fa->flags & ~allowed)
>> >> + return -EOPNOTSUPP;
>> >
>> > This whole mess could be sorted out by switching the cifs
>> > implementation to the new API
>>
>> ("new API" you mean _mask right?)
>>
>
> Yes and ro_mask, but it probably also means converting all the
> read-only CASEFOLD fs to new api, so that FS_XFLAG_CASEFOLD
> could be taken out of FS_XFLAG_RDONLY_MASK
Can all flags currently in FS_XFLAG_RDONLY_MASK be rw for some
filesystems or only some?
Should they all be removed from FS_XFLAG_RDONLY_MASK and left to each
filesystem to define them as ro (to put in _ro_mask)?
>> > and implementing a generic vfs
>> > helper which does something like the above code to handle the
>> > old ioctls.
>> > FS_XFLAG_CASEFOLD would then be removed from
>> > FS_XFLAG_RDONLY_MASK and set explicitly in xflags_ro_mask
>> > by fs which don't allow to set if (e.g. nfs) and added to
>> > FS_COMMON_FL/FS_XFLAG_COMMON
>> >
>> > cifs would advertise FS_XFLAG_CASEFOLD in its ro_mask
>> > and then the generic helper would mask it and the new syscall
>> > will not allow it.
>> >
>> >> + }
>> >> [...]
>> >> + cifs_dbg(FYI, "set compress flag rc %d\n", rc);
>> >
>> > I think that the roadmap should be to slowly define all the old FS_*_FL
>> > flags as FS_XFLAGS_* and let the generic helpers deal with the conversion.
>>
>> > But it is not so hard to convert one filesystem at a time in a way that
>> > fa->fsx_valid will have to be true, because, for example, here
>> > all the relevant flags would be supported by the new xflags API.
>>
>> So, something like what fileattr_fill_{x,}flags() do now, but for
>> file_attr_to_fileattr()?
>>
>
> Yes, something like this (maybe)
>
> void fileattr_fill_flags(struct file_kattr *fa, u32 flags)
> {
> fa->flags_valid = true;
> + fa->fsx_valid = !(flags & ~FS_COMMON_FL);
> + fa->fsx_xflags_mask = FS_XFLAG_COMMON;
> fa->flags = flags;
So, for the filesystems that switch to the new API, these new/changed
helpers should handle giving userspace the legacy FS_*_FL flags (if
userspace uses FS_IOC_GETFLAGS) by converting them from the FS_XFLAG_*
reported by the filesystem?
But did you write this
> + fa->fsx_valid = !(flags & ~FS_COMMON_FL);
> + fa->fsx_xflags_mask = FS_XFLAG_COMMON;
while thinking about FS_IOC_SETFLAGS, so from userspace to filesystem,
and this would be needed because that filesystem wouldn't know what
FS_*_FL are, so it will use the _mask and the converted xflags?
But why the opposite of (flags & ~FS_COMMON_FL) as fsx_valid?
Why fsx_valid = 0 if the passed flags also contain non-FS_COMMON_FL
flags and fsx_valid = 1 if the passed flags contain only FS_COMMON_FL
flags?
(if I understood correctly)
> But in this model FS_XFLAG_COMMON are only the ones that
> are mutable from the old ioctl.
>
> We would need to define FS_READONLY_FL to deal with the
> group of read-only legacy flags, if some fs needs them and wants
> to use the new API.
So the those filesystems can put it in _ro_mask on GET you mean?
>> > No need to do that now, as part of this patch set which is complicated
>> > enough, just need to see the road ahead of us that we have a way
>> > forward out of this messy flags_valid/fsx_valid inside filesystem
>> > implementations.
>>
>> I think it's probably better to clean up the API now, before introducing
>> new flags (like FS_XFLAG_BTIME/PTIME or the shared extent one in the
>> other thread) and as I'll say in that reply (I'll write it in a bit) I
>> think it's even better to first split the _mask changes into their own
>> RFC PATCH series, then have a separate one for ptime/btime.
>>
>
> Agree.
>
> It's even two different changes -
> The vfs internal _mask change and the UAPI _mask change.
> chattr -p implementation with new API would be the perfect
> champion to drive this UAPI change IMO.
Ah, right, they could even be made in 2 separate patches but it's
probably better to keep both in only one, since otherwise there would
need to be temporary vfs functions to convert xflags to xflags_mask and
back.
>> > My understanding is that Miklos introduced those hints to reduce the
>> > work needed per filesystem for the initial implementation of the
>> > vfs methods.
>>
>> Ah yeah that would make sense.
>>
>
> BTW the trigger for the vfs interface was ovl_copy_fileattr()
> so this is a user of the new vfs _mask API that we need to
> pay attention to.
Ah ok, I'll look into that too then.
> Thanks,
> Amir.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-20 14:06 UTC|newest]
Thread overview: 63+ 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-20 15:58 ` Amir Goldstein
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
2026-11-20 6:45 ` Amir Goldstein
2026-11-20 13:33 ` koraynilay
2026-11-20 14:55 ` Amir Goldstein
2026-11-20 15:21 ` koraynilay
2026-11-20 16:16 ` Amir Goldstein
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-20 6:03 ` Amir Goldstein
2026-11-20 13:23 ` 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-20 6:34 ` Amir Goldstein
2026-11-20 14:05 ` koraynilay [this message]
2026-11-20 15:55 ` Amir Goldstein
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
2026-11-20 17:16 ` Christian Brauner
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=DN03GJ80ZWNZ.9GM35HM4T48N@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=miklos@szeredi.hu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.