On Sat Dec 5, 2026 at 9:09 PM CET, Amir Goldstein wrote: > On Sat, Dec 5, 2026 at 3:24 PM koraynilay wrote: >> >> Rename FS_XFLAGS_MASK to FSX_FSXATTR_MASK and make the internal xflags >> collection macros' names shorter so the code that uses them can be >> cleaner and more readable. >> >> Add an explanatory comment for FS_COMMON_FL/FSX_COMMON, FSX_RDONLY_MASK >> and FSX_FSXATTR_MASK, so it's clearer which xflags they include. >> >> Also add FSX_EXTSIZE_MASK to avoid long lines caused only by OR'ing >> FS_XFLAG_EXTSIZE and FS_XFLAG_EXTSZINHERIT. >> >> Don't touch the names of the actual xflags macros as those are exposed >> to userspace so they can't be easily changed. >> >> Signed-off-by: koraynilay >> --- >> >> Sorry, dropped Reviewed-by: Amir Goldstein because >> I added FSX_EXTSIZE_MASK. >> (Wasn't sure if I could keep it or not) > > As long as you say what you change the re-review is easy so now > may restore my RVB thanks. Ok thanks. > One comment though > > fs,overlayfs: rename FS_XFLAGS_MASK... > > lose the ",overlayfs" prefix please - it's out of context and > a very robotic thing to do. > > The commit message is NOT a list of changed subsystem > > THIS is an fs: change. As such it can affect several filesystems > it happens to affect only one (overlayfs) Ah ok, yeah that makes sense. Thanks, koraynilay > Thanks, > Amir. > >> >> Thanks. >> >> fs/file_attr.c | 16 ++++++++-------- >> fs/overlayfs/copy_up.c | 2 +- >> fs/overlayfs/inode.c | 2 +- >> include/linux/fileattr.h | 34 +++++++++++++++++++++++----------- >> 4 files changed, 33 insertions(+), 21 deletions(-) >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> index 0f2975c9b7bc..cc1621d3b710 100644 >> --- a/fs/file_attr.c >> +++ b/fs/file_attr.c >> @@ -102,7 +102,7 @@ EXPORT_SYMBOL(vfs_fileattr_get); >> static void fileattr_to_file_attr(const struct file_kattr *fa, >> struct file_attr *fattr) >> { >> - __u32 mask = FS_XFLAGS_MASK; >> + __u32 mask = FSX_FSXATTR_MASK; >> >> memset(fattr, 0, sizeof(struct file_attr)); >> fattr->fa_xflags = fa->fsx_xflags & mask; >> @@ -122,7 +122,7 @@ static void fileattr_to_file_attr(const struct file_kattr *fa, >> int copy_fsxattr_to_user(const struct file_kattr *fa, struct fsxattr __user *ufa) >> { >> struct fsxattr xfa; >> - __u32 mask = FS_XFLAGS_MASK; >> + __u32 mask = FSX_FSXATTR_MASK; >> >> memset(&xfa, 0, sizeof(xfa)); >> xfa.fsx_xflags = fa->fsx_xflags & mask; >> @@ -141,12 +141,12 @@ EXPORT_SYMBOL(copy_fsxattr_to_user); >> static int file_attr_to_fileattr(const struct file_attr *fattr, >> struct file_kattr *fa) >> { >> - __u64 mask = FS_XFLAGS_MASK; >> + __u64 mask = FSX_FSXATTR_MASK; >> >> if (fattr->fa_xflags & ~mask) >> return -EINVAL; >> >> - fileattr_fill_xflags(fa, fattr->fa_xflags & ~FS_XFLAG_RDONLY_MASK); >> + fileattr_fill_xflags(fa, fattr->fa_xflags & ~FSX_RDONLY_MASK); >> fa->fsx_extsize = fattr->fa_extsize; >> fa->fsx_projid = fattr->fa_projid; >> fa->fsx_cowextsize = fattr->fa_cowextsize; >> @@ -158,7 +158,7 @@ static int copy_fsxattr_from_user(struct file_kattr *fa, >> struct fsxattr __user *ufa) >> { >> struct fsxattr xfa; >> - __u32 mask = FS_XFLAGS_MASK; >> + __u32 mask = FSX_FSXATTR_MASK; >> >> if (copy_from_user(&xfa, ufa, sizeof(xfa))) >> return -EFAULT; >> @@ -166,7 +166,7 @@ static int copy_fsxattr_from_user(struct file_kattr *fa, >> if (xfa.fsx_xflags & ~mask) >> return -EOPNOTSUPP; >> >> - fileattr_fill_xflags(fa, xfa.fsx_xflags & ~FS_XFLAG_RDONLY_MASK); >> + fileattr_fill_xflags(fa, xfa.fsx_xflags & ~FSX_RDONLY_MASK); >> fa->fsx_extsize = xfa.fsx_extsize; >> fa->fsx_nextents = xfa.fsx_nextents; >> fa->fsx_projid = xfa.fsx_projid; >> @@ -247,7 +247,7 @@ static int fileattr_set_prepare(struct inode *inode, >> >> /* Extent size hints of zero turn off the flags. */ >> if (fa->fsx_extsize == 0) >> - fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT); >> + fa->fsx_xflags &= ~FSX_EXTSIZE_MASK; >> if (fa->fsx_cowextsize == 0) >> fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE; >> >> @@ -290,7 +290,7 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry, >> >> /* initialize missing bits from old_ma */ >> if (fa->flags_valid) { >> - fa->fsx_xflags |= old_ma.fsx_xflags & ~FS_XFLAG_COMMON; >> + 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; >> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c >> index c147ad155b79..20f369863faf 100644 >> --- a/fs/overlayfs/copy_up.c >> +++ b/fs/overlayfs/copy_up.c >> @@ -220,7 +220,7 @@ static int ovl_copy_fileattr(struct inode *inode, const struct path *old, >> newfa.flags &= ~OVL_COPY_FS_FLAGS_MASK; >> newfa.flags |= (oldfa.flags & OVL_COPY_FS_FLAGS_MASK); >> >> - BUILD_BUG_ON(OVL_COPY_FSX_FLAGS_MASK & ~FS_XFLAG_COMMON); >> + BUILD_BUG_ON(OVL_COPY_FSX_FLAGS_MASK & ~FSX_COMMON); >> newfa.fsx_xflags &= ~OVL_COPY_FSX_FLAGS_MASK; >> newfa.fsx_xflags |= (oldfa.fsx_xflags & OVL_COPY_FSX_FLAGS_MASK); >> >> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c >> index f1c6df39d0ae..92df4f5c071e 100644 >> --- a/fs/overlayfs/inode.c >> +++ b/fs/overlayfs/inode.c >> @@ -709,7 +709,7 @@ int ovl_fileattr_set(const struct mnt_idmap *idmap, >> static void ovl_fileattr_prot_flags(struct inode *inode, struct file_kattr *fa) >> { >> BUILD_BUG_ON(OVL_PROT_FS_FLAGS_MASK & ~FS_COMMON_FL); >> - BUILD_BUG_ON(OVL_PROT_FSX_FLAGS_MASK & ~FS_XFLAG_COMMON); >> + BUILD_BUG_ON(OVL_PROT_FSX_FLAGS_MASK & ~FSX_COMMON); >> >> if (inode->i_flags & S_APPEND) { >> fa->flags |= FS_APPEND_FL; >> diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h >> index 09e32b84e02a..79371aa93a61 100644 >> --- a/include/linux/fileattr.h >> +++ b/include/linux/fileattr.h >> @@ -3,37 +3,49 @@ >> #ifndef _LINUX_FILEATTR_H >> #define _LINUX_FILEATTR_H >> >> -/* Flags shared betwen flags/xflags */ >> +/* >> + * FS_COMMON_FL/FSX_COMMON are preserved through an RMW cycle via either UAPI >> + * flavor. They must NOT include flags that are read-write via one API flavor >> + * and read-only in another (e.g. CASEFOLD). >> + */ >> #define FS_COMMON_FL \ >> (FS_SYNC_FL | FS_IMMUTABLE_FL | FS_APPEND_FL | \ >> FS_NODUMP_FL | FS_NOATIME_FL | FS_DAX_FL | \ >> FS_PROJINHERIT_FL | FS_VERITY_FL) >> >> -#define FS_XFLAG_COMMON \ >> +#define FSX_COMMON \ >> (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ >> FS_XFLAG_NODUMP | FS_XFLAG_NOATIME | FS_XFLAG_DAX | \ >> FS_XFLAG_PROJINHERIT | FS_XFLAG_VERITY) >> >> -/* Read-only inode flags */ >> -#define FS_XFLAG_RDONLY_MASK \ >> +/* >> + * Read-only xflags via FS_IOC_FS[GS]ETXATTR and file_[gs]etattr(). >> + * The respective flags may still be read-write via FS_IOC_SETFLAGS. >> + */ >> +#define FSX_RDONLY_MASK \ >> (FS_XFLAG_PREALLOC | FS_XFLAG_HASATTR | FS_XFLAG_VERITY | \ >> FS_XFLAG_CASEFOLD | FS_XFLAG_CASENONPRESERVING) >> >> /* Flags to indicate valid value of fsx_ fields */ >> -#define FS_XFLAG_VALUES_MASK \ >> +#define FSX_VALUES_MASK \ >> (FS_XFLAG_EXTSIZE | FS_XFLAG_COWEXTSIZE) >> >> /* Flags for directories */ >> -#define FS_XFLAG_DIRONLY_MASK \ >> +#define FSX_DIRONLY_MASK \ >> (FS_XFLAG_RTINHERIT | FS_XFLAG_NOSYMLINKS | FS_XFLAG_EXTSZINHERIT) >> >> /* Misc settable flags */ >> -#define FS_XFLAG_MISC_MASK \ >> +#define FSX_MISC_MASK \ >> (FS_XFLAG_REALTIME | FS_XFLAG_NODEFRAG | FS_XFLAG_FILESTREAM) >> >> -#define FS_XFLAGS_MASK \ >> - (FS_XFLAG_COMMON | FS_XFLAG_RDONLY_MASK | FS_XFLAG_VALUES_MASK | \ >> - FS_XFLAG_DIRONLY_MASK | FS_XFLAG_MISC_MASK) >> +/* Flags for fa/fsx_extsize value fields */ >> +#define FSX_EXTSIZE_MASK \ >> + (FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT) >> + >> +/* Flags supported by FS_IOC_FS[GS]ETXATTR and file_[gs]etattr() */ >> +#define FSX_FSXATTR_MASK \ >> + (FSX_COMMON | FSX_RDONLY_MASK | FSX_VALUES_MASK | \ >> + FSX_DIRONLY_MASK | FSX_MISC_MASK) >> >> /* >> * Merged interface for miscellaneous file attributes. 'flags' originates from >> @@ -69,7 +81,7 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags); >> static inline bool fileattr_has_fsx(const struct file_kattr *fa) >> { >> return fa->fsx_valid && >> - ((fa->fsx_xflags & ~FS_XFLAG_COMMON) || fa->fsx_extsize != 0 || >> + ((fa->fsx_xflags & ~FSX_COMMON) || fa->fsx_extsize != 0 || >> fa->fsx_projid != 0 || fa->fsx_cowextsize != 0); >> } >> >> -- >> 2.56.1.dirty >>