Re: [PATCH 3/3] ntfs: switch to the new xflags fileattr API

From: Amir Goldstein

Date: Mon Nov 23 2026 - 08:01:08 EST


On Sun, Nov 22, 2026 at 1:09 AM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> Switch ntfs_fileattr_[gs]et() from the legacy FS_*_FL flags to the
> modern xflags (FS_XFLAG_*) fileattr API with masks.
>
> Introduce FS_XFLAG_COMPR and FS_XFLAG_ENCRYPT and add them to
> FS_XFLAG_COMMON (and add FS_COMPR_FL and FS_ENCRYPT_FL to FS_COMMON_FL)
> to be used in this API switch.
>
> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.11
> Signed-off-by: koraynilay <koray.fra@xxxxxxxxx>
> ---
> fs/file_attr.c | 8 +++++
> fs/ntfs/file.c | 63 +++++++++++++++++++---------------------
> include/linux/fileattr.h | 6 ++--
> include/uapi/linux/fs.h | 2 ++
> 4 files changed, 44 insertions(+), 35 deletions(-)
>
...

> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 50be49f4c913..fde6fb2fe39c 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -155,31 +155,37 @@ int ntfs_file_release(struct inode *vi, struct file *filp)
> * @dentry: dentry to report the flags of
> * @fa: filled in with the flags of @dentry
> */
> +#define NTFS_RO_XFLAGS (FS_XFLAG_COMPR | FS_XFLAG_ENCRYPT | FS_XFLAG_CASEFOLD)
> +#define NTFS_RW_XFLAGS (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \
> + FS_XFLAG_NOATIME | FS_XFLAG_NODUMP)

Nit: checkpatch may allow 100 chars, but this due formatting is not
easy on the eyes
pls break to RO line and indent the broken lines below (


> diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h
> index 4faa40febf11..219e7c8eb601 100644
> --- a/include/linux/fileattr.h
> +++ b/include/linux/fileattr.h
> @@ -7,12 +7,14 @@
> #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)
> + FS_PROJINHERIT_FL | FS_VERITY_FL | FS_COMPR_FL | \
> + FS_ENCRYPT_FL)
>
> #define FS_XFLAG_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)
> + FS_XFLAG_PROJINHERIT | FS_XFLAG_VERITY | FS_XFLAG_COMPR | \
> + FS_XFLAG_ENCRYPT)


Rule:

You cannot add a flag to common without carefully auditing all
filesystems that support the legacy flag.

FS_XFLAG_ENCRYPT can go into common but must also
go to FS_XFLAG_RDONLY_MASK because it's read-only for
all existing fs.

COMPR is rw for some fs and ro for others.
As with CASEFOLD, you cannot make it COMMON before
converting all casefold fs to new API so that each can say
whether it wants RO or RW.

I think there may be a way to deal with this easily since
ntfs doesn't need to set either but not sure.

>
> /* Read-only inode flags */
> #define FS_XFLAG_RDONLY_MASK \
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index e40806b3a69c..09fc7e066485 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -275,6 +275,8 @@ struct file_attr {
> #define FS_XFLAG_CASENONPRESERVING 0x00080000 /* case not preserved */
>
> #define FS_XFLAG_PROJID 0x00100000 /* project ID */
> +#define FS_XFLAG_COMPR 0x00200000 /* Compress file */
> +#define FS_XFLAG_ENCRYPT 0x00400000 /* Encrypted file */

This is a mistake of patch 1. the newline should remain above HASATTR
which is allocated from the end.


> #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
>
> /* the read-only stuff doesn't really belong here, but any other place is

Thanks,
Amir.
>