Re: [PATCH v3 2/5] vfs: add xflags masks to fileattr API

From: koraynilay

Date: Mon Nov 30 2026 - 16:29:20 EST


On Mon Nov 30, 2026 at 10:25 PM CET, koraynilay wrote:
> On Mon Nov 30, 2026 at 10:04 PM CET, Amir Goldstein wrote:
>> On Mon, Nov 30, 2026 at 6:22 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>>>
>> ...
>>> >> >>>
>>> >> >>> For PROJID, personally it could also just be put in FS_XFLAGS_MASK, my
>>> >> >>> concern is that it may break programs, even tho fsx_xflags is already
>>> >> >>> expected to grow (as per your 276e136bff7e ("fs: prepare for extending
>>> >> >>> file_get/setattr()")).
>>> >> >>>
>>> >> >>
>>> >> >> I am too concerned that this would break programs.
>>> >> >
>>> >> > Hmm, I'll ask the robot a bit about solutions to this, but...
>>> >> > what about adding an exception for PROJID that it must never be set in
>>> >> > fsx_xflags and only used in rw_mask (so for chattr -p)?
>>> >> >
>>> >
>>> > I don't think this is the answer. Let's see what the bot has to offer.
>>>
>>> So the bot said that keeping PROJID outside of FS_FILE_ATTR_XFLAGS_MASK
>>
>> Don't you mean the other way around?
>>
>> PROJID is in FS_FILE_ATTR_XFLAGS_MASK and not in
>> FS_XFLAGS_FSXATTR_MASK?
>
> Ah yes, typo.
>
>>> is the best solution, and suggested adding
>>>
>>> #define FS_XFLAGS_FSXATTR_RW_MASK \
>>> ((FS_XFLAGS_FSXATTR_MASK & ~FS_XFLAG_RDONLY_MASK) | FS_XFLAG_PROJID)
>>>
>>> to be used in the code/docs.
>>> I'm not sure this is the best, but it would simplify reading the code.
>>>
>>
>> This is exactly what I was looking for.
>> PROJID is only singled out in one place (here) when defining the macro
>> and a comment above the macro explains why.
>> From this point on the macro describes a trait, which has a very clear
>> meaning, without mentioning any specific flag.
>>
>> Good job, bot ;)
>
> Yes, though, when trying to change the current code to use it, I'm not
> liking the name too much, since it seems like it's a subset of
> FS_XFLAGS_FSXATTR_MASK, while it's actually not, since
> FS_XFLAGS_FSXATTR_MASK does not include PROJID.

Another option for FS_XFLAGS_FSXATTR_RW_MASK is FS_XFLAGS_NOMASK_RW,
which I like a bit more but I'm not sure.

(Forgot in the previous reply)

>>> Also, could we change FS_XFLAGS_FSXATTR_MASK to FS_XFLAGS_FSXATTR? (and
>>> so also FS_XFLAGS_FSXATTR_RW)
>>
>> This reduces readability considerably IMO.
>> There needs to be a clear separation between the
>> flag macros and the flag collection macros (traits if you will).
>
> Hmm, fair, I proposed this change because the names are getting a bit
> long and formatting the code is harder, also they have FLAG*S* that can
> indicate it's a collection, but that's easily missable (and indeed, I
> can never remember if it's FS_XFLAG_MASK or FS_XFLAGS_MASK, one more
> reason removing the _MASK may be beneficial, at least to me lol).
>
>>> And I'd also change FS_FILE_ATTR_XFLAGS_MASK to maybe only
>>> FS_FILE_ATTR_MASK, so it's not too long.
>>
>> Losing the FS_XFLAGS_ prefix is not good IMO.
>> I did want to offer a change to FS_XFLAGS_FILEATTR_MASK
>> to be consistent with the rest of the collection/trait macros.
>
> Hmm, right, FS_XFLAGS_FILEATTR_MASK does indeed look better, though it
> is getting a bit hard to distinguish between them when they have such a
> long prefix.
>
> FS_*_FL are easier to read.
> Actually, could we maybe do something like FSX_ as prefix, if the FS_
> prefix is not that important?
>
> FSX_IMMUTABLE
> FSX_PROJID
>
> FSX_RDONLY_MASK
> FSX_FSXATTR_MASK
> FSX_FILEATTR_MASK
>
> or if FS_ is important:
>
> FS_FSX_IMMUTABLE
> FS_FSX_PROJID
>
> FS_FSX_RDONLY_MASK
> FS_FSX_FSXATTR_MASK
> FS_FSX_FILEATTR_MASK
>
> or maybe?
>
> FS_XFL_IMMUTABLE
> FS_XFL_PROJID
>
> FS_XFL_RDONLY_MASK
> FS_XFL_FSXATTR_MASK
> FS_XFL_FILEATTR_MASK
>
> or something else that is shorter, idk.
>
>>>
>>> And at this point, we should consider all _MASKs to be frozen and only
>>> expand FS_FILE_ATTR_MASK, with the exception of converterd FS_*_FL
>>> flags.
>>
>> This is something that we can definitely document as a guideline -
>> use the latest v1 syscall uapi for new flags, with the exception of
>> xflags for existing FS_*_FL flags.
>
> Yes.
>
>> However, a filesystem can only report a new flag after it has opted into
>> masks,
>
> Report as RW or as RO?
>
> Since for RO reporting it doesn't need to, it just needs to do that for
> get (and actually, only for the wanted xflag, it probably doesn't even
> need to report all its xflags in rw/ro masks apart from e.g. MAYSHARE...
> or maybe not even in the masks, since on the set path vfs treats it as a
> "legacy RMW"/VER0 filesystem).
>
>> so if a new flag requires converting many filesystems,
>> it may not be realistic to maintain the freeze rule.
>>
>> Hopefully, the work on the may-share flag came just at the right time
>> to allow for the ro_mask exception, so observing the guideline for
>> new read-only flags seems doable.
>
> Yes, MAYSHARE for testing read-only, BTIME for testing read-write (and
> read-only).
>
>>
>>>
>>> so:
>>>
>>> FS_XFLAGS_FSXATTR would have the ones that are in right now + all new
>>> FS_*_FL converted ones (same for RDONLY and COMMON, etc)
>>>
>>> FS_FILE_ATTR_MASK would have all FS_XFLAGS_FSXATTR + all new ones
>>> (MAYSHARE, BTIME, ...).
>>>
>>
>> Yes, it sounds like we are converging :)
>
> Yes, though that has been my thinking since the first time I wrote
> "FS_FILE_ATTR_MASK" for the ptime patch :D
>
>>> > Isn't PROJID in FS_XFLAGS_FILE_ATTR_MASK, but not in
>>> > FS_XFLAGS_FSXATTR_MASK?
>>> > Is there more to it than that?
>>>
>>> Currently it's set like this, and there shouldn't be anything more to
>>> it.
>>>
>>
>> Nice. Looking forward to v4.
>> I hope I have some time to rest before, but probably not :)
>
> I should take >= 1 breaks too instead of working on this when I'm not
> doing other stuff, but I already know I won't :)
>
> Thanks,
> koraynilay
>
>> Thanks,
>> Amir.


Attachment: signature.asc
Description: PGP signature