Re: [PATCH 2/3] vfs: add xflags mask to fileattr API
From: Amir Goldstein
Date: Thu Nov 26 2026 - 04:23:44 EST
On Thu, Nov 26, 2026 at 9:59 AM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
...
> >> > Attributes that have X_value like fsx_projid have few types:
> >> > 1. 0 means disabled (all existing values incl. projid)
> >> > 2. 0 is a valid value but cannot be unset (btime)
> >> > 3. 0 is a valid value and NULL/unset is also a valid value
> >> >
> >> > Only for type 3 does can the interpretation of
> >> > (!XFLAG_X && !fsx_X) be considered as an "unset"
> >> > and anyway, this will require support in individual fs.
> >>
> >> IMO !(xflags & XFLAG) && (rw_mask & XFLAG) should clear/unset the value
> >> in all cases, ignoring what's in fsx_X.
> >>
> >> And all existing values would be of type 1 for VER0, but of type 1 + 3
> >> for VER1.
> >>
> >
> > I agree that this will be more consistent.
> >
> > With explicit opt-in to FILEATTR_MASKS API
> > vfs can determine that
> > (!XFLAG_X && !!fsx_X) is alway -EINVAL
> >
> > When fsx_X == 0, the value of XFLAG_X does not really matter
> > so filesystems can decide themselves if they want to act on
> > an "unset" flag or not.
>
> Hmm, I think fsx_xflags should have priority over the value in this
> _masks API.
>
> In my mind, to clear PROJID a userspace program would only need to do:
>
> struct file_attr fa = {
> .fsx_xflags = 0,
> .fsx_xflags_rw_mask = FS_XFLAG_PROJID
> };
> file_setattr(&fa, AT_FILE_ATTR_MASKS);
If the program (e.g. chattr -p) internationally sets rw_mask = FS_XFLAG_PROJID
what do we gain from not requiring the program to also set fsx_projid = 0?
I just don't see any wins for anyone from this design choice.
Maybe I am missing something.
>
> and have projid cleared (same for EXTSIZE/EXTSZINHERIT/COWEXTESIZE),
> while to set/change it:
>
> struct file_attr fa = {
> .fsx_xflags = FS_XFLAG_PROJID,
> .fsx_xflags_rw_mask = FS_XFLAG_PROJID,
> .fsx_projid = 67,
> };
> file_setattr(&fa, AT_FILE_ATTR_MASKS);
>
> and this:
>
> struct file_attr fa = {
> .fsx_xflags = FS_XFLAG_PROJID,
> .fsx_xflags_rw_mask = FS_XFLAG_PROJID,
> .fsx_projid = 0,
> };
> file_setattr(&fa, AT_FILE_ATTR_MASKS);
>
> would have the same result as the first snippet, but not the same
> meaning, since this would mean "set projid to 0" while the first snippet
> means "clear/unset projid" (but in this case, for projid and all the
> other already existing fsx_* it would have the same result).
>
As I wrote it could matter per attribute and per filesystem
whether set to 0 or unset is different.
The man page language should be flexible enough about this point.
It only needs to document the invalid combinations.
When proposing an UAPI change I often included a man-page draft
as a proof that the UAPI can make sense to human readers.
Thanks,
Amir.