Re: [RFC PATCH v4 08/10] nfs: add provenance time (ptime) via FATTR4_TIME_CREATE
From: Amir Goldstein
Date: Fri Nov 20 2026 - 11:17:20 EST
On Fri, Nov 20, 2026 at 4:21 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> On Fri Nov 20, 2026 at 3:55 PM CET, Amir Goldstein wrote:
> > On Fri, Nov 20, 2026 at 2:34 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
> >>
> >> On Fri Nov 20, 2026 at 7:45 AM CET, Amir Goldstein wrote:
> >> > On Thu, Nov 19, 2026 at 11:10 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
> >
> >> >> > 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)
> >> >>
> >> >
> >> > Good question. Maybe
> >> > I guess if you want to follow some percent
> >> > FS_FL_USER_MODIFIABLE is a subset of FS_FL_USER_VISIBLE
> >> > but I think that exporting ro_mask and _mask is going to be easier and
> >> > cleaner than rw_mask but not sure.
> >>
> >> Hmm I asked that also because you said in the xfs shared extent thread:
> >>
> >> > The advantage being that it makes the interface symmetric.
> >> > User can alway setattr() with the buffer they got from getattr()
> >> > and instead of randomly ignoring flags in set, the fsx_ro_mask
> >> > along with fsx_mask defines the behavior exactly.
> >>
> >> But by putting the ro flags in _mask too, a user would have to clean
> >> them out or vfs will reject the call with -EINVAL/something else, since
> >> in that case the vfs would see the user say "I want to change this [ro]
> >> flag".
> >>
> >
> > That's just a matter of interpretation.
> >
> > You could say that if flag FS_XFLAG_CASENONPRESERVING
> > is in ro_mask then its value may not be modified and fs needs to
> > fail the set
>
> Yes, that's what I was thinking.
>
> > if the user given value is not a match to the current
> > kernel's value.
>
> Since this is a new API, I think it's fine to -EINVAL if it's in _mask
> anyway, even if the value is the same, no?
>
The question is only about when a flag is set in _ro_mask
and say that it is not in _rw_mask
what do you do with the value of this flag in _xflags?
You can simply ignore it, mask it out as copy_fsxattr_to_user()
is doing today and this is probably the right choice.
But you could also take a more conservative approach
like ntfs_fileattr_set() in fs/ntfs/file.c:
/* chattr passes the unchanged read-only flags back to us too. */
if (NInoCompressed(ni) || NInoWofCompressed(ni))
readonly |= FS_COMPR_FL;
if (NInoEncrypted(ni))
readonly |= FS_ENCRYPT_FL;
if ((fa->flags ^ readonly) & (FS_COMPR_FL | FS_ENCRYPT_FL))
return -EOPNOTSUPP;
This is stronger, because userspace can express:
set flag X while making sure the flag Y is not set
in this case xflags = X, xflags_rw_mask = X, xflags_ro_mask = Y
It does not have to mean that Y is a readonly attribute
the filesystem itself could set it in rw_mask, but when user
puts it in ro_mask its a verification_mask rather than an ignore_mask
In both interpretations (verify/ignore) the sequence:
ret = get_fileattr(&fa)
ret = set_fileattr(&fa)
should work fine most of the time, but if some rdonly flag
can flip between the two calls (e.g. FS_XFLAG_PREALLOC)
then the set call would fail and this is not the expectation
wrt the existing FS_XFLAG_RDONLY_MASK flags.
Thanks,
Amir.