Re: [RFC PATCH v4 10/10] cifs: add provenance time (ptime) and map it to SMB's CreationTime

From: Amir Goldstein

Date: Fri Nov 20 2026 - 10:57:01 EST


On Fri, Nov 20, 2026 at 3:05 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> > 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, &current_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, &current_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?

No. CASEFOLD is the only one which is MODIFIABLE/SETTABLE
in the old setflags ioctl.

Its twin xflag FS_XFLAG_CASEFOLD was recently added along with
FS_XFLAG_CASENONPRESERVING for a bunch of fs (e.g. nfs) which
advertise it as rdonly attribute.

> 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)?
>

No need to do this.

One flag at a time per demand.

You *need* to get FS_XFLAG_CASEFOLD out when some
fs will want to set it via xflags API.

You *may* get a flag out of FS_XFLAG_RDONLY_MASK
only after *all* of the fs which support it have been converted
to the new xflags_*_mask api.

> >> > 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?
>

I did not look at the implementation details but when you make the
vfs API rich enough with the masks, the should be no problem to
describe in the API what the old ioctls do
"get a subset of attributes"
"set a subset of attributes"

Where "subset" differs depending on the ioctl.

> 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)
>

My interpretation of fsx_valid (for the set side) is:
fs may completely ignore ->flags and get all the information from fsx_*
similarly for flags_valid fs does not need to look at fsx_*

In the case that all requested flags are common, both
fsx_valid and flags_valid can be true.

But what I wrote is nonsense, because the old ioctls have no request_mask
so unset flag does not mean it is not being set.

I think what is needed is something like this helper to be called from
filesystems:

bool fileattr_prepare_xflags(struct file_kattr *fa, u32 xflags, u32 supported)
{
if (fa->flags_valid) {
fa->fsx_valid = !(fa->flags & supported & ~FS_COMMON_FL);
fa->fsx_xflags_mask = supported & FS_XFLAG_COMMON;
}
return fa->fsx_valid;
}

Then cifs_fileattr_set() starts with:

if (!fileattr_prepare_xflags(fa, CIFS_SUPPORTED_XFLAGS))
return -EOPNOTSUPP;

And from here on, talk only xflags and xflags_*mask

For cifs that means to add vfs support for FS_XFLAG_COMPR
<-> FS_COMR_FL conversion in helpers.

FS_COMR_FL is also rdonly flag in some fs and rw in others.

> > 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?
>

Actually, I meant that the old setflags ioctls could be translates to the
new xflags_mask dialect, for example:

bool fileattr_prepare_xflags(struct file_kattr *fa, u32 xflags, u32 supported)
{
if (fa->flags_valid) {
fa->fsx_valid = !(fa->flags & supported & ~FS_COMMON_FL);
fa->fsx_xflags_rw_mask = supported & FS_XFLAG_COMMON &
~FS_XFLAG_RDONLY_MASK;
fa->fsx_xflags_ro_mask = supported & FS_XFLAG_COMMON &
FS_XFLAG_RDONLY_MASK;
}
return fa->fsx_valid;
}

so it will work correctly for example with fs/ntfs which supports
readonly ENCRYPT|COMPR

Thanks,
Amir.