Re: [PATCH v5 05/12] fs: add initial implementation of xflags masks to fileattr API

From: koraynilay

Date: Sun Dec 06 2026 - 09:29:55 EST


On Sun Dec 6, 2026 at 3:12 PM CET, Amir Goldstein wrote:
> On Sun, Dec 6, 2026 at 3:05 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>>
>> On Sun Dec 6, 2026 at 2:22 PM CET, Amir Goldstein wrote:
>> > On Sat, Dec 5, 2026 at 3:24 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>> >>
>> >
>> > fs: add initial implementation of xflags masks to fileattr API
>> >
>> > "initial implementation" is too vague, this patch implements
>> > the vfs parts of the fileattr mask api so just say so
>> >
>> >> Add read-write and read-only masks to the fileattr API to let
>> >
>> > to the vfs fileattr API, to avoid ambiguity
>> >
>> >> filesystems advertise their support for specific xflags, like
>> >> statx.stx_attributes_mask, and to let userspace specify only which
>> >> xflags it wants to change without needing a RMW cycle.
>> >>
>> >> The masks have the following semantics:
>> >> - read-write mask:
>> >> * for filesystems: advertise which xflags they support changing
>> >> * for userspace: specify which xflags it wants to modify
>> >> - read-only mask:
>> >> * for filesystems: advertise which xflags they support only reading
>> >> * for userspace: ignored
>> >>
>> >> And they should be filled according to the following:
>> >> - GET:
>> >> each filesystem that wants to implement this new API fills the masks
>> >> according to its supported read-write and read-only xflags,
>> >> then:
>> >> * for boolean xflags: it fills fsx_xflags with the current on-disk value;
>> >> * for value xflags: it sets the xflag bit to 1 in fsx_xflags and the
>> >> xflag value in the struct field;
>> >> - SET:
>> >> userspace fills the rw_mask with the bits of the xflags it wants to
>> >> change, then:
>> >> * for boolean xflags: it provides the xflag value as a bit in fsx_xflags;
>> >> * for value xflags: it sets the xflag bit to 1 in fsx_xflags and then
>> >> provides the value in the struct field; if the xflag bit is set to 0
>> >> instead and the value is 0, this informs the kernel to unset/clear
>> >> that value (if the value field is non-zero it should get rejected
>> >> with -EINVAL).
>> >>
>> >> To achieve this, add fsx_xflags_{rw,ro}_mask fields and {has,use}_masks
>> >> selectors to struct file_kattr, so we can know when a user of this API
>> >> (userspace or filesystem) supports them.
>> >>
>> >> To eventually make both non-masks and masks programs interact correctly
>> >> with both non-masks and masks filesystems, add:
>> >> - fileattr_set_{from,to}_masks(): convert between non-masks
>> >> read-modify-write API and masks API;
>> >> - fileattr_set_convert(): handles calling the above helpers as needed,
>> >> then calls fileattr_set_preserve() if neither userspace nor filesystem
>> >> has masks.
>> >>
>> >> Note that this is only the initial internal VFS implementation: it
>> >
>> > Drop "initial"
>> >
>> >> doesn't include any changes to UAPI yet, nor does it include
>> >> FS_XFLAG_PROJID, so with only this patch it's not possible to set the
>> >> project ID using masks.
>> >
>> > odd remark - user cannot set anything with masks yet.
>>
>> Should I remove this paragraph altogether or change it to something like
>> "Since we have no FS_XFLAG_PROJID yet, return changing it as
>> unsupported"? (or something else?)
>>
>
> I think removing it is fine. I don't see what value it adds.

Ok, I thought I had to say something about PROJID since it gets rejected
in this patch (because of course we don't have the flag yet).
I initially just wanted to remove the projid handling from this patch
without adding any special cases, but the bot advised on handling it
anyway (hence the return -EOPNOTSUPP for projid in set_to_masks()),
which makese sense so the code is "complete".

Thanks,
koraynilay

> Thanks,
> Amir.


Attachment: signature.asc
Description: PGP signature