From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795733915; b=Pby4JrCt4+CvNwwOP4aw784cbDuWApEihp/8CIcHD/A17sAQfejqkDwMLLVJEdipp4x1 Y/wx6y0xtT0z8KXTi//gnn1MoNRntVf5bQdlpTZt7vLwpU1mGuEXq1JXGfOsj68qXDnoe dA8BF2REC4APhmLZy7eYUuMgrmrQw4S7qn0/oS/SPH54prP6hSB5kZy311+BqEEjAFKhc E7K6m4a4CtpPtoPdHROUhsBgtQ4eKaW0ttiJOiz+z0QnhdQpnQ04dvCH1Pxtu4AYdfkbz +HxfyrgO9GIHslsgQZV9N1Wcg3Dsfslnx/9JAemE3MMBrCaJySDy0bNdJCOcjpIDjPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795733915; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc:X-Mailer: References:In-Reply-To; bh=m8YUNG0289MJznW1Ljl78OszeJ++5ltmCqqiqlxz4Gk=; b=G2DA2KYZO0RFNo16U7UTUvL+gjzIY52ccsfgrew/XNUIHPHtnuj6mRfpuDU5Gdt0nEFf 7eNYy74i9878Ekbnj+4PCMCdjTUcHi4eonLeyl/rhxikrhFAWFk9xpUgC0mkgeBEKKe/O kCNhqXPk3wjollnERwDKa0HvTY0aOQiRLT1NzP4PcFYp/osnEz6eiVXA0LbUb9UBM1sGp 53tBTdwrDmntLEQGJx/JygMmiNFzB0GFb0oqV4PFyQz+QeW3ny9ZlqY48bsLKCADF9B1l nlHSBvUySsW4cezbyGoPh2T0N3wnMboC0Md0EJgMCprB8S3GzCiDsaoTCRNKbGOw8QA== 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=Slgjv2rC; arc=none smtp.remote-ip=209.85.128.48 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 DDE21606A31E for ; Thu, 26 Nov 2026 22:58:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DDE21606A31E 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=Slgjv2rC Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4bb64ef5a14so74324335e9.1 for ; Thu, 26 Nov 2026 14:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795733913; x=1796338713; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:mime-version:from:to:cc:subject:date:message-id :reply-to:content-type; bh=m8YUNG0289MJznW1Ljl78OszeJ++5ltmCqqiqlxz4Gk=; b=Slgjv2rCfiamg+O9GJlFWAOQ9tg1YUbYxrZ9VVQK1e3h5ZRy4TxckJc3EvLoHkPBcp 6JFfOqwouWJHw9vFwDGw5BKLK/q4FoMI7a/1JQPvJVVt92csAcY0NU1qXo/KRh5S9t3I 8s5YGzWbAkRGZqQ5yBUMWlQmj1gSwN/6uNKcvQbVoSKqbpgTXmaqjewhAp0RZtZkwIVp N07Kpy7P09kbXO7OWl47yKEzBcSb0PEkzk3p0gJ90757PLddYD3e7pKI2zllVzgTjXak Rs+BXgOS+tT2mG06wnEKBDGNAQQXcRnPnBLeg0r8YS8lC083UKyytdUQ5+LaBSlDVwfq fo7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795733913; x=1796338713; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-type:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=m8YUNG0289MJznW1Ljl78OszeJ++5ltmCqqiqlxz4Gk=; b=KRQtrlzm17cyBYyByx1rrvvyL6F8TxTMVSUURGT8ZVu6Fd7R55F9p6nzF/ay5QI4MO kq3zbCfel2h2vL2YVcIzsOjEIqWEjfhTzx6xFOXq2GBtLWenwNKfIDlL+RxaWFI3jX4c XHKz7Two2UE9sgedSD+/YQ15mzQd+oa0UZYGRRu2nnwi7KSrlmruDCl77o7kUa0NZ38W 85kvKuvyc2R4oXdRVk6nAJdCdwmFFDcPTP1LuE9b6+oSB7g2ldVYLBX1zRhI2O65bxHH XV7/iYjIC+Vlx4ciEwJr7ZykrO+ZjwWRXzOG5bXvrjqVTnVvLpzXBstNsUWBmTf47utb oPKQ== X-Forwarded-Encrypted: i=1; AL+hErFbKOWquFO5bOVo1YdQEYW/TOIwtFdOB7f8mddpnDQlIgMUXP/1oSR+NFPPFWREt3ik3mGn+NLwDTEST9WG@vger.kernel.org X-Gm-Message-State: APuU4Z9w9JSllAZYdOeLtJfOCjp0hnRD/eYrCtgNDQZOLe4jaqpcFOkL mtwkvM8k6itnvYVJRUEmofrCyv3lSYog6i1OVfdMM/wSwh66dLF07CUE X-Gm-Gg: AZFdTZfdU8j6g3MFX5Kbds1AZgR/W4ms041n759zg/FACDxlnaLGva6oUG0T1Rh8FRD lOQCuHkIe+cKCx20lMqy9kEQXpbdjmcBc5sYJ6DoApGuE7a/riuSc+79mwcUDcHeE1fVNsnc5Xl LZSYhJaIRsz3F5LH+xoJ/OgTbBIA7xTnx6KJEzNf4bn9ufpalou2oZtBWzW6FdzqBJ1nuGjqem9 /5adRFzfDn+PPFisBFP94XC+i5TG3Qa1RP4if6nOTDDY517cIAQwo5x4yBTL1/idOtENYIXHmEb yqrwuuMensfCu5kHn48OwjdrXw5gbqoJC8IjcLkWTgDwlSx6H9ykqexgrg/Z/y/KG9yqPSd/WL5 fXWFAh+dLJjrgG7jwXuNRffU4p98WGZCOK7+csOeJp2y6NUQGtZc1x6TZ9nWGzfOiOflgQTkyII 3M6/qe/76wjl/ZdbJ3xezz1ZRf9Jo2X3Wyu82pXjA8YhqGshEYbIm+Ab78x8XRu6Rb31kCNyZ7o OyUhfWnMqYozFSxZMAPKx7gaTYjRINcLjOyMTMr8b/g1j21Tzl6Hi+nsKHnzAmte/I4LLuNJv5J 3uDQG2O4CRYegZRlmEKAgHx3OA== X-Received: by 2002:a05:600c:4e87:b0:4a7:6bc7:f778 with SMTP id 5b1f17b1804b1-4bb88938d38mr467930345e9.30.1795733913027; Thu, 26 Nov 2026 14:58:33 -0800 (PST) Received: from localhost ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b110c3csm41489064f8f.36.2026.11.26.14.58.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Nov 2026 14:58:31 -0800 (PST) X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: multipart/signed; boundary=05d75f0ce163acd47afe49ecf5a8d87df78d75f96b711c550e361cecbf9b; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Thu, 26 Nov 2026 23:58:25 +0100 Message-Id: Subject: Re: [PATCH v2 0/4] Add f*_xflags_{rw,ro}_mask flags to the fileattr API From: "koraynilay" To: "koraynilay" , "Namjae Jeon" , "Hyunchul Lee" , "Eric Biggers" , "Theodore Y . Ts'o" , "Jaegeuk Kim" , "Alexander Viro" , "Christian Brauner" Cc: "Chuck Lever" , "Jeff Layton" , "Jan Kara" , "Alexander Aring" , "Darrick J . Wong" , "Andrey Albershteyn" , "Amir Goldstein" , =?utf-8?q?Pali_Roh=C3=A1r?= , "Lauri Gates" , "Christoph Hellwig" , "Dave Chinner" , , , , , , , X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261126163114.403846-1-koray.fra@gmail.com> In-Reply-To: <20261126163114.403846-1-koray.fra@gmail.com> --05d75f0ce163acd47afe49ecf5a8d87df78d75f96b711c550e361cecbf9b Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On Thu Nov 26, 2026 at 5:31 PM CET, koraynilay wrote: > 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. > > The first patch is a preparatory cleanup so that the code in the later > patches can be formatted better. > > The second patch updates fscrypt_prepare_setflags() to take FS_XFLAG_* > xflags instead of legacy FS_*_FL flags. > > The third patch is the actual implementation, which introduces: > - fa_xflags_{rw,ro}_mask fields to struct file_attr > - fsx_xflags_{rw,ro}_mask fields and has_masks selector to struct file_ka= ttr > - AT_FILE_ATTR_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 ...and I forgot to include the improved explanation. I'll write it and send it tomorrow (hopefully). > 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. > > Patch 3/4 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 FS_XFLAGS_MASK and so it's > defined as part of a new FS_FILE_ATTR_XFLAGS_MASK group of xflags that > will be used moving forward for any new xflag (like the one proposed in [= 2]). > > Patch 4/4 converts fs/ntfs to this new API, to show how it can benefit > filesystem drivers too, and for this purpose adds FS_XFLAG_COMPR and > FS_XFLAG_ENCRYPT from their FS_COMPR_FL and FS_ENCRYPT_FL counterparts. > > 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. > > Note 2: there are apparently quite a few bugs with overlayfs and a few > other issues, but I wanted to get the final API design out first. > > 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 =3D=3D 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; > > Thanks, > koraynilay > > [1]: https://lore.kernel.org/CAOQ4uxg8aVcWyNiFDk8djdn-M3xJcu_7-kRxVq9jjFs= bcGp1ew@mail.gmail.com/ > [2]: https://lore.kernel.org/CAOQ4uxjVQ9cjV=3D_jBjQtNg9zCuWUEJT9KNYMKV+1j= wBkHen5OA@mail.gmail.com/ > [3]: https://github.com/koraynilay/xfstests/tree/patches-in-queue > > koraynilay (4): > vfs: use goto out on error in vfs_fileattr_set() > fscrypt: update fscrypt_prepare_setflags() to use xflags > vfs: add xflags mask to fileattr API > ntfs: switch to the new xflags fileattr API > > fs/crypto/hooks.c | 10 +- > fs/file_attr.c | 357 +++++++++++++++++++++++++++++++++---- > fs/ntfs/file.c | 109 +++++------ > include/linux/fileattr.h | 14 +- > include/linux/fscrypt.h | 6 +- > include/uapi/linux/fcntl.h | 6 + > include/uapi/linux/fs.h | 9 +- > 7 files changed, 409 insertions(+), 102 deletions(-) > > > base-commit: 3857587d9d6fa44d40d1c73bde6a39f6f7a5216c --05d75f0ce163acd47afe49ecf5a8d87df78d75f96b711c550e361cecbf9b Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSgVimKafU5DQMcjcDmj22qf5IGXAUCawi5kQAKCRDmj22qf5IG XG6WAPwJQXkvnYM2T6CI+OL3CbCXJcdyvNtTqqpqmtzkWtEBdQD8CWhtnTm8Mn20 vvyMXHnKEDWD/QMw27jw1T31axApsQ0= =Trt/ -----END PGP SIGNATURE----- --05d75f0ce163acd47afe49ecf5a8d87df78d75f96b711c550e361cecbf9b--