Re: [PATCH v5 03/12] fs: move fileattr sizes out of uapi and factor out set_preserve()
From: Amir Goldstein
Date: Sun Dec 06 2026 - 08:49:31 EST
On Sun, Dec 6, 2026 at 12:39 AM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> On Sat Dec 5, 2026 at 11:15 PM CET, Amir Goldstein wrote:
> > On Sat, Dec 5, 2026 at 3:24 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
> >>
> >> Move FILE_ATTR_SIZE_* constants from the user-facing
> >> include/uapi/linux/fs.h to the internal include/linux/fileattr.h.
> >>
> >> Move old flags preservation from vfs_fileattr_set() to a dedicated
> >> helper in preparation for the addition of masks to the fileattr API.
> >
> > This is a combination of two very random unrelated things so no.
> Fair.
> > Please move the move of flags to the definition of VER1 unless
> > you have a good reason otherwise.
> Yeah, I did it like this because the robot suggested it and I thought it
> was a fine since it's a preparatory patch.
> (Moved the SIZE changes to the uapi patch now)
>
> >
> >>
> >> Signed-off-by: koraynilay <koray.fra@xxxxxxxxx>
> >> ---
> >> fs/file_attr.c | 26 +++++++++++++++++---------
> >> include/linux/fileattr.h | 4 ++++
> >> include/uapi/linux/fs.h | 3 ---
> >> 3 files changed, 21 insertions(+), 12 deletions(-)
> >>
> >> diff --git a/fs/file_attr.c b/fs/file_attr.c
> >> index cc1621d3b710..77e2f1bc22ad 100644
> >> --- a/fs/file_attr.c
> >> +++ b/fs/file_attr.c
> >> @@ -175,6 +175,22 @@ static int copy_fsxattr_from_user(struct file_kattr *fa,
> >> return 0;
> >> }
> >>
> >> +static void fileattr_set_preserve(struct file_kattr *fa,
> >> + const struct file_kattr *old_ma)
> >> +{
> >> + if (fa->flags_valid) {
> >> + /* FS_IOC_SETFLAGS */
> >> + fa->fsx_xflags |= old_ma->fsx_xflags & ~FSX_COMMON;
> >> + fa->fsx_extsize = old_ma->fsx_extsize;
> >> + fa->fsx_nextents = old_ma->fsx_nextents;
> >> + fa->fsx_projid = old_ma->fsx_projid;
> >> + fa->fsx_cowextsize = old_ma->fsx_cowextsize;
> >> + } else {
> >> + /* FS_IOC_FSSETXATTR or file_setattr */
> >> + fa->flags |= old_ma->flags & ~FS_COMMON_FL;
> >> + }
> >> +}
> >> +
> >
> >
> > Excellent way to make the code more readable and break into
> Nice.
> > understandable pieces but this non trivial helpers needs a comment to
> > explain what it does, similar to the not trivial comment that you added
> > above FSX_COMMON.
> Ah yeah, makes sense.
And for just the factor out of preserve (with matching subject), feel
free to add
Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>
Thanks,
Amir.