From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796480691; b=pe3ufCVUoy1KJ63NqQsVRVXt2kplqv7tDzOFc+8laAnSBCFsldZqoVCbJoluS14W+P7o FzuOhUMcuSroV0saHeEsjj41mgJXmZoTDZHvXEG+R5GfGuHx5+m+9K3m62+19l/DESbtm ZiUVqjYebHGGpIb7m85klDIKP9DUlwtrk+wBqbx4YBHoSXvb5JVE76GfeLpbV6yggFuCi BA4DJA+cQDSOPPFUFzdRQLBhcch0wLb7umiauo6xEbuzIqRS5NQy5qWzaK0AfdYObJ6mn YA140CdRSlAY0FiFU4BzBF+knpf3eb03sBeEXj7ESQPiLRVFLnzyOMDb9HHf1cUIXOw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796480691; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=rjo3nxJAHCVik2tbCDtWRWWgyefTWvJvK6clOX7n03c=; b=S/D95KNBf/d3p9yHSSGNfHVGmbd79b/7HJVGFXijwBWs1UKQzEHN/q+L+vA6w71hIQzp yXG0OYKzWV/chmqNAdCjl5Gi/hrw+W/qVda2J8UCSlGDN18BsPZ3sOV6zWEBjAZpDc9UT IaHWJGjIJ+4aNrey6PXKLhgELnHvFIxTmDRpG4mPTIkAWFulLP9CrBp64drxcwuq+SCxN 7oY1s31CF3zgrrCuZ2JsoPwBDy9ue0pkSXU7s0cdNtzooxUQXNcNnkJ8PDtST8M4OmiNJ wjViDrQskN4Fve9PrEAapSN5QHn+sLpZAkDQyTHh6DuIGg8vr0dhMAyQGlz5T0FgZTQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=AYOhCFNu; arc=none smtp.remote-ip=209.85.221.41 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34EC0606A330 for ; Sat, 5 Dec 2026 14:24:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 34EC0606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=AYOhCFNu Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-4a357b1c649so1063023f8f.3 for ; Sat, 05 Dec 2026 06:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796480690; x=1797085490; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rjo3nxJAHCVik2tbCDtWRWWgyefTWvJvK6clOX7n03c=; b=AYOhCFNuNiPu5WbaxK4lY4NOjZHvjdvFvuXqa0853leqel6knF5QwM89fpIHPfjZ7b TzCL8gK/IQsliJRD8RaGXxK/bl0+amURAMeeyMmfmp5SYXBtdH307RiD5S1Ff8t9ei2P I3b3d9lEVxabAZmiP7CObFg1sVUCUD19vjU/J0ODA9UVgwiwaqiapYWmTtW21uIhVMv0 dJvix9MBUnYRqfd1LpHU9pBH1aWcVVsfwh8ctZfW4tCspQBLp2nYWulruD+OZxfupJ/Q 0lh+FOn9WnwlbQpvHnOvzwxRHx7NxwQ2u5fq9raAd+h1eSKCN2VxgsvNTpMjBPmqi2sN PNjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796480690; x=1797085490; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rjo3nxJAHCVik2tbCDtWRWWgyefTWvJvK6clOX7n03c=; b=oZPLxfHpfa+wliwK1AxDgF0QQMj+l4eqCqb9TPRYM5lW/ej6mT/dXF3Z+xkE9M/9kz TIty4aKARWbr+IPostlaUk8ZaQhlwLZjQ2kRP1GF4ngbh4KqFE8GkLbD9ZYGuXz/oQ1q 5MLhY5v6bZe6K7slWKrzpHJA1DPgrQtOhI0bda3/8pgjm6r8fH69s9gRXJdUT2QlHu7b uhNhqJa18akpWufe0WZDPYljSp2yjT+GRYV4L0+R9rfPG/fkdPQfa0zwGaQoeJnqdbtv IsgRj00OI+rdNLOYdOILrKNYmPEeSnxweOGBfr9DhTLMDm3MVD8rROCHII2UPKOcoXyg 4GlA== X-Forwarded-Encrypted: i=1; AL+hErF4fInlrud/QsEH8hiv94xHxf6/V5T7SJkaPQ01Q1Kumku91ZN4EKrXumJGWppucgkfpzE8d/QNVdU=@vger.kernel.org X-Gm-Message-State: AB4q+uEsKZZwErZj0x3u9e4bCoRQ9bqX06rGysPGBzqd/C6Wfsq6aLAG L7AGLv9GCcDISMo52yl/FDQ+xPej99fkjwW2oPxa/cpESPKkyN8xYfWk X-Gm-Gg: AZFdTZePlftj2GCQAwtlmLwIAC3AAqZZxfiP2i8uhGzRo+KaBLHibp1FMtq+s5Gc70i J5e2wnrHZr87hJk3mViYcX5X348iFNMu2AdEIt134awP7lmiOD5eHdoa727aotkSDON/vHcAcR2 fDdssByn8c6JGVKCNZEhQtjkmdbNWjevgnde7qZL1qgrsUalP3ipRRBdPS4RVXmPyDQmPPNBQmm gAZiDrGtX8nDbcr4p+Da5N+XdATQs0/U/3aLGJPenhEVI9C9aMOpc2lNgkM/vTlttk6Nk1YwTVb pUK1VXrM52dZ4v0vVTddJWJwXlCPO6+shopYpstL5+gzqxJ2dLXmQ5N9Hlmr7pPWXImIptp7UB0 kJ8Z+UkQHexRXCQdOcRZ4UKIc0XxBWcoqedTO4mAHwrveKpnFORvn71GlsK3Ma7v/8K8nH2z8t2 RgyKyeD3Kw56Oalb0hMjVwKicsgPl/KLAG4ntWc+nnPzVlL1NrdtzsCl8XgqWTG2wCTlZ+L7uvy ggzQWFvsOthkATobYwPabGR7E9P4+oR+4twEfcHyIg1QHa4leDwai19j/yZd19F/x1PUQlvIdR4 vap+Cvrh29QFzoNjs5fg8N5I X-Received: by 2002:a05:6000:2b89:b0:4d1:5412:fc56 with SMTP id ffacd0b85a97d-4d1e8dbcef0mr6594052f8f.12.1796480689371; Sat, 05 Dec 2026 06:24:49 -0800 (PST) Received: from infinity ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d174d08d42sm10776969f8f.55.2026.12.05.06.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 06:24:48 -0800 (PST) From: koraynilay To: Namjae Jeon , Hyunchul Lee , Jonathan Corbet , Eric Biggers , "Theodore Y . Ts'o" , Jaegeuk Kim , Alexander Viro , Christian Brauner Cc: Shuah Khan , Randy Dunlap , Chuck Lever , Jeff Layton , Jan Kara , Alexander Aring , "Darrick J . Wong" , Andrey Albershteyn , Amir Goldstein , Miklos Szeredi , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lauri Gates , Christoph Hellwig , Dave Chinner , 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, linux-doc@vger.kernel.org, linux-unionfs@vger.kernel.org, koraynilay Subject: [PATCH v5 00/12] Add f*_xflags_{rw,ro}_mask flags to the fileattr API Date: Sat, 5 Dec 2026 15:23:59 +0100 Message-ID: <20261205142411.164484-1-koray.fra@gmail.com> X-Mailer: git-send-email 2.56.1.dirty X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is a follow up patch series stemmed from [1] and [2], splitting the _mask change for the fileattr API into its own separate patch series. The series extends the fileattr API with xflags masks by introducing: - fa_xflags_{rw,ro}_mask fields to struct file_attr - fsx_xflags_{rw,ro}_mask fields and has_masks / use_masks / get_only_masks selectors to struct file_kattr - AT_FILEATTR_MASKS at_flag for file_[gs]etattr() These masks have the following semantics: - rw_mask: * for filesystems: advertise which xflags they support changing * for userspace: specify which xflags it wants to modify - ro_mask: * for filesystems: advertise which xflags they support only reading * for userspace: ignored This allows userspace to not have to do a RMW cycle when using the file_[gs]etattr() syscalls, avoiding possible race conditions and simplifying their usage. The series also introduces the missing FS_XFLAG_PROJID flag so that programs like chattr can leverage the new mask API. FS_XFLAG_PROJID is kept out of the legacy FSX_FSXATTR_MASK and defined as part of the new FSX_FILEATTR_MASK group of xflags that will be used moving forward for any new xflag (like the one proposed in [2]). In addition, FS_XFLAG_COMPR and FS_XFLAG_ENCRYPT are added (as FS_COMPR_FL and FS_ENCRYPT_FL counterparts) for fs/ntfs, which is converted to the new mask API as an example. Old programs will also get these new flags, which should be fine since xflags were made to be expandable. Documentation/filesystems/fileattr.rst explains how this API can be used by both userspace and filesystems along with the various semantics (it doesn't go into *too much* detail though, since that would mean writing the code itself). The rendered page can be found at [4]. Please also check the specific patch comments. The series has been tested with custom xfstests [3] (generic/816-835, xfs/611, xfs/673) across NTFS, ext4 (project quotas), XFS (project quotas and extent size hints), Btrfs, and F2FS. Note: these tests were written by gemini and not manually checked, before sending them upstream (if needed) I'll have to review/rewrite them manually. IMPORTANT NOTE: there are quite a few bugs with overlayfs (generic/832-835 above) when using a masks filesystem, I haven't investigated them deeply yet since I would first need to understand a lot more how overlayfs works, but the robot's report is in [5]. To help me develop this patch series I used Gemini 4 Hydrogen/Neon in antigravity-cli to audit the code, find edge-cases, propose possible fixes, develop and run the tests above and help with comments/language/style. Thanks, koraynilay v5 changes: - split the v4 masks patch (3/7) into smaller patches, and separate get_only_masks into the overlayfs fix patch; - move FSX_COMMON / FSX_RDONLY_MASK comments into the rename patch; - add FSX_EXTSIZE_MASK to the rename patch to avoid having to always OR the two extsize macros in the later patches; - simplify file_attr_to_fileattr() with an early return when !use_masks; - fix mid-series ntfs regression by guarding the COMPR/ENCRYPT check with fa->flags_valid (kept in xflags conversion patch, removed in the masks conversion patch); - move NTFS_{RO,RW}_XFLAGS macros into the xflags conversion patch; - replace open-coded extsize/projid/cowextsize check with fileattr_fsx_ok(), rename fileattr_has_invalid_fsx_masks() to fileattr_fsx_masks_ok(), and build it on top of fileattr_fsx_ok() in the masks conversion patch; - docs: merge the two flag tables (ordered BOTH, XFLAGS-only, FLAGS-only, drop RESERVED/EOFBLOCKS, add single-fs notes and descriptions); - docs: clarify {flags,fsx}_valid for get vs set; - docs: document get_only_masks's writable-counterpart requirement; - docs: add the Filesystem Contract for Masks section; - add patch comments for 2/12, 8/12, 9/12 and 10/12. v4 changes: - add patch 2/7 to shorten internal xflag macro names (FSX_*) and document FSX_COMMON / FSX_RDONLY_MASK; - split ntfs conversion into flags->xflags (5/7) and masks support (6/7); - add use_masks and get_only_masks selectors to struct file_kattr, and clamp FS_IOC_SETFLAGS in fileattr_set_convert() (as discussed in [9]); - rename fileattr_set_{rmw_to_mask,mask_to_rmw}() to fileattr_set_{to,from}_masks(); - reject rw_mask == 0 and clearing value attributes with non-zero values with -EINVAL; - add FSX_FSXATTR_SET_MASK and clamp unmasked new_xflags in fileattr_set_from_masks(); - add fileattr_has_invalid_fsx_masks() and use it in ntfs_fileattr_set(); - update docs per v3 review (focus on internals, reference man-pages, VER0/VER1 phrasing); - dropped all Assisted-by tags and add LLM-usage explanation above. v3 changes: - refactor the big if/else in vfs_fileattr_set() to a fileattr_set_convert() helper and simplify (hopefully?) its code; - drop fscrypt flags -> xflags patch and just use xflags_to_flags() in vfs; - add FS_XFLAG_COMPR/ENCRYPT in a separate patch instead of in the ntfs one ([6]); - move FILE_ATTR_SIZE_VER* variables from the uapi header to the internal header ([7]); - rename AT_FILE_ATTR_MASKS to AT_FILEATTR_MASKS ([8]); - change "legacy" references to "rmw" references in both comments and helper names ([8]); - add docs. v2 changes: - make fa_xflags_{rw,ro}_mask in struct file_attr __u64; - add AT_FILE_ATTR_MASKS to opt in to mask semantics instead of needing unreliable heuristics on usize and mask values; - reject intermediate sizes between VER0 and VER1; - reject non-zero masks on SET without AT_FILE_ATTR_MASKS; - add patch 2/4 for fscrypt_prepare_setflags; - add xflags_to_flags() / flags_to_xflags() and fileattr_set_{legacy_to_mask,mask_to_legacy}() to translate between legacy RMW callers/filesystems and _mask callers/filesystems; - clamp fa->fsx_xflags to rw_user_mask in file_attr_to_fileattr(); - update fileattr_set_prepare() to validate capabilities and projid changes against rw_user_mask / xflags; - move the rw_mask == 0 early-return no-op from file_setattr() into vfs_fileattr_set(); - put FS_XFLAG_COMPR in FS_XFLAG_RDONLY_MASK only (keep FS_XFLAG_ENCRYPT in both FS_XFLAG_COMMON and FS_XFLAG_RDONLY_MASK); - update ntfs_fileattr_set() to apply only bits selected in fsx_xflags_rw_mask; [1]: https://lore.kernel.org/CAOQ4uxg8aVcWyNiFDk8djdn-M3xJcu_7-kRxVq9jjFsbcGp1ew@mail.gmail.com/ [2]: https://lore.kernel.org/CAOQ4uxjVQ9cjV=_jBjQtNg9zCuWUEJT9KNYMKV+1jwBkHen5OA@mail.gmail.com/ [3]: https://github.com/koraynilay/xfstests/tree/patches-in-queue [4]: https://koraynilay.neocities.org/vfs-masks/fileattr [5]: https://koraynilay.neocities.org/vfs-masks/overlayfs-fileattr-bugs [6]: https://lore.kernel.org/CAOQ4uxgJjy3TaORBkMOdef-JvzX2uA5K2sbMDEcLqmpkedsESw@mail.gmail.com/ [7]: https://lore.kernel.org/CAOQ4uxi6oyFj_A9nPbgGeSufGo11L2N=QxLi2DW=ZKy25YQ5Tw@mail.gmail.com/ [8]: https://lore.kernel.org/CAOQ4uxhA+93bo5WseLxe7cAvJHJ8eQodoQHLwh=iToyEVkeXEA@mail.gmail.com/ [9]: https://lore.kernel.org/DN8RMUP6F5CI.2KSDF5TMCRO1X@gmail.com/ koraynilay (12): fs: use goto out on error in vfs_fileattr_set() fs,overlayfs: rename FS_XFLAGS_MASK and shorten other internal macro names fs: move fileattr sizes out of uapi and factor out set_preserve() fs: switch fileattr_set_prepare() to xflags and refactor projid check fs: add initial implementation of xflags masks to fileattr API fs: add UAPI implementation of xflags masks to fileattr API fs: add missing FS_XFLAG_PROJID xflag fs,overlayfs: add fileattr masks support on get fs,ntfs: advertise COMPR/ENCRYPT xflags in file_getattr() ntfs: switch from flags to xflags in ntfs_fileattr_get/set() ntfs: support the fileattr API masks in ntfs_fileattr_get/set() docs: add fileattr API documentation Documentation/filesystems/fileattr.rst | 463 +++++++++++++++++++++++++ Documentation/filesystems/index.rst | 1 + Documentation/filesystems/vfs.rst | 19 +- fs/file_attr.c | 402 ++++++++++++++++++--- fs/ntfs/file.c | 98 +++--- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/inode.c | 5 +- include/linux/fileattr.h | 129 ++++++- include/uapi/linux/fcntl.h | 6 + include/uapi/linux/fs.h | 38 +- 10 files changed, 1038 insertions(+), 125 deletions(-) create mode 100644 Documentation/filesystems/fileattr.rst base-commit: d8d9179592a52044a52591b31b914cfc0edbf36d -- 2.56.1.dirty