From: "koraynilay" <koray.fra@gmail.com>
To: "Amir Goldstein" <amir73il@gmail.com>,
"koraynilay" <koray.fra@gmail.com>
Cc: "Namjae Jeon" <linkinjeon@kernel.org>,
"Hyunchul Lee" <hyc.lee@gmail.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>, "Jan Kara" <jack@suse.cz>,
"Darrick J . Wong" <djwong@kernel.org>,
"Andrey Albershteyn" <aalbersh@kernel.org>,
"Pali Rohár" <pali@kernel.org>,
"Lauri Gates" <lauri.gates@gmail.com>,
"Christoph Hellwig" <hch@infradead.org>,
"Dave Chinner" <dgc@kernel.org>,
linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
ntfs@lists.linux.dev, linux-nfs@vger.kernel.org,
linux-api@vger.kernel.org
Subject: Re: [PATCH 2/3] vfs: add xflags mask to fileattr API
Date: Thu, 26 Nov 2026 09:59:50 +0100 [thread overview]
Message-ID: <DN50PH7HHSWZ.3H4T25JFPQECY@gmail.com> (raw)
In-Reply-To: <CAOQ4uxhpJygZH-arLFSUYEEfqFG96Sr3_6CWakfSkdWxEsOxMg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6836 bytes --]
On Thu Nov 26, 2026 at 8:07 AM CET, Amir Goldstein wrote:
> On Wed, Nov 25, 2026 at 9:22 PM koraynilay <koray.fra@gmail.com> wrote:
>>
>> On Wed Nov 25, 2026 at 5:51 PM CET, Amir Goldstein wrote:
> ...
>> >>
>> >> My robot proposed 2 fixes: either don't introduce FS_XFLAG_PROJID
>> >> (which, eh, not the best imo)
>> >
>> > Me neither. It's inconsistent IMO.
>> >
>> > But it is inconsistent in that we want to have a way for chattr -p to say with
>> > the new API "set only projid", so we must have the flag, but we
>> > mostly need it for the mask, we don't really care about its value in
>> > fsx_flags.
>> >
>> >> or add a new flag to be used in at_flags,
>> >> like AT_FILEATTR_MASKS, which would resolve all our legacy vs non-legacy
>> >> problems, but it would be in *at*_flags, so doesn't really make sense
>> >> semantically (but it would work well since file_getattr already rejects
>> >> unknown at_flags, so it wouldn't cause problems for old programs).
>> >
>> > I think this is an overkill as well.
>>
>> Semantics issue aside, I think this shuold be the way to go, because
>> it's explicit and doesn't rely on guessing based on struct size or mask
>> values.
>>
>
> Yes this is a good argument.
>
>> > We discussed this before.
>> >
>> > 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);
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).
>> > fileattr_set_prepare() already treats the existing values as:
>> > fsx_X == 0 => clear XFLAG_X
>> >
>> > And xfs returns EINVAL for !!(fsx_X) != !!(XFLAGX)
>> >
>> > A simple solution is to fix the flag according to val in fileattr_set_prepare()
>> (This should be in file_attr_to_fileattr() I think, but yeah)
>> > if rw_mask contains this flag:
>> >
>> > if (fa->fsx_xflags_rw_mask & FS_XFLAG_PROJID) {
>> > /* Possibly legacy chattr -p compiled with new headers unaware of PROJID */
>> > if (fa->fsx_projid == 0)
>> > fa->fsx_xflags &= ~FS_XFLAG_PROJID;
>> > else
>> > fa->fsx_xflags |= FS_XFLAG_PROJID;
>> > }
>>
>> I think this would be a bit too overcomplicated to understand, and
>
> True
>
>> robot says (with the current v2 code at least) it would make e.g. ntfs
>> return 0 instead of -EOPNOTSUPP for e.g. chattr +S.
>>
>
> I suspected that existing filesystems may have different legacy behaviors..
(By the way I meant ntfs as in "mask aware filesystems" (I said ntfs
because that was the robot's example since it's the only one currently
implementing masks), but yeah)
>> It also told me that statx already has AT_STATX_* flags that don't match
>> the at_flags semantics (and indeed, AT_STATX_FORCE_SYNC/DONT_SYNC don't
>> really make sense for "at"_flags semantics), so my only blocker for that
>> solution is gone and I would really prefer that approach since it's way
>> simpler and way cleaner.
>
> Git history claims that I suggested making this an official UAPI policy:
>
> b4fef22c2fb97 uapi: explain how per-syscall AT_* flags should be allocated
>
> So definitely no objection to AT_FILEATTR_ semantics.
Oh, yes that's the comments I used as docs to add AT_FILE_ATTR_MASKS to
fcntl.h ahah.
>>
>> One more thing gemini told me is that if we don't want to use AT_*, we
>> have to choose between (copy-pasted, "ntfs" meaning any mask-aware fs):
>> 1. Keep clamping fattr->fa_xflags & rw_user_mask (VER1 masked semantics
>> are clean, but recompiled VER0 RMW tools setting unsupported
>> flags/projid on ntfs silently return 0)
>> 2. Reject unexpected non-zero bits/fields outside rw_user_mask | ro_mask
>> (protects recompiled VER0 RMW error reporting on ntfs, at the cost that
>> VER1 callers must zero or mask fa_xflags / fa_projid / fa_extsize
>> themselves rather than expecting bits outside rw_mask to be ignored).
>>
>> So I would *really* prefer adding AT_FILEATTR_MASKS and setting
>> has_masks based only on that.
>> This way we can keep the whole legacy path frozen and not have to worry
>> about weird edge cases (well, converters code aside of course).
>>
>> And personally in this way I can reason about the changes a lot more
>> clearly and I can finally take a better look at the whole code and maybe
>> simplify it in some cases (probably not, but I'll have to see).
>>
>
> All very good reasons IMO.
>
>> (Unless there is something equivalent to AT_FILEATTR_MASKS to filter on,
>> like maybe a FS_XFLAG_MASKS (?), but that would be even worse
>> semantically I think)
>
> It's an option, but I think AT_FILEATTR_MASKS is cleaner.
Yes I agree, I also thought a bit about other options, e.g. even having
FS_XFLAGS_HASMASKS (like HASATTR), and stripping it right away in the
syscall (or even using it instead of fa->has_masks) but they would all
be worse options than AT_FILE_ATTR_MASKS.
Today or tomorrow I'll send out v2.
Thanks,
koraynilay
> Thanks,
> Amir.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-26 8:59 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 0:08 [PATCH 0/3] Add f*_xflags_{rw,ro}_mask flags to the fileattr API koraynilay
2026-11-22 0:08 ` [PATCH 1/3] vfs: use goto out on error in vfs_fileattr_set() koraynilay
2026-11-23 8:42 ` Andrey Albershteyn
2026-11-23 14:15 ` koraynilay
2026-11-23 14:18 ` Amir Goldstein
2026-11-23 14:22 ` koraynilay
2026-11-22 0:08 ` [PATCH 2/3] vfs: add xflags mask to fileattr API koraynilay
2026-11-23 13:24 ` Amir Goldstein
2026-11-23 13:58 ` koraynilay
2026-11-23 15:29 ` Amir Goldstein
2026-11-25 15:01 ` koraynilay
2026-11-25 16:51 ` Amir Goldstein
2026-11-25 20:22 ` koraynilay
2026-11-26 7:07 ` Amir Goldstein
2026-11-26 8:59 ` koraynilay [this message]
2026-11-26 9:23 ` Amir Goldstein
2026-11-26 9:47 ` koraynilay
2026-11-22 0:08 ` [PATCH 3/3] ntfs: switch to the new xflags " koraynilay
2026-11-22 12:49 ` liubaolin
2026-11-23 0:38 ` koraynilay
2026-11-23 3:06 ` liubaolin
2026-11-23 14:13 ` koraynilay
2026-11-23 13:00 ` Amir Goldstein
2026-11-23 13:50 ` koraynilay
2026-11-23 14:14 ` Amir Goldstein
[not found] ` <DN2NVGUNO0GA.89JAB2PVI0LA@gmail.com>
2026-11-23 14:55 ` Amir Goldstein
2026-11-23 15:18 ` Amir Goldstein
2026-11-23 13:35 ` [PATCH 0/3] Add f*_xflags_{rw,ro}_mask flags to the " Amir Goldstein
2026-11-23 14:10 ` koraynilay
2026-11-23 15:42 ` Amir Goldstein
2026-11-23 17:58 ` koraynilay
2026-11-23 21:45 ` koraynilay
2026-11-23 22:47 ` Amir Goldstein
2026-11-23 22:56 ` koraynilay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN50PH7HHSWZ.3H4T25JFPQECY@gmail.com \
--to=koray.fra@gmail.com \
--cc=aalbersh@kernel.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=dgc@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=hyc.lee@gmail.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=lauri.gates@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ntfs@lists.linux.dev \
--cc=pali@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox