From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796566062; b=r2C6he96mj9ItrX0xx6J9xJ+t8rhFEQw35ihbAUFro/kkIR4QCs+Ik7mn7ebI7bpH8Xf jf9ip5QZlIUttLIt7SAuucjiCVXAQ/fbT9ELfz+3KTE8gpX+iPNFJhn/ErPgRF0YAU0U6 +YWMvE6C4gIiKAe1hlT2/sXx4zzNq4+BmbFdnlnUH4qvqBUga+CSOQgFnqRi5Gmn7W9bw 8naOkOQjH7xbe8Xw0O5BFF+zRgxiryY6qsWc+1N1eTZU1zWLIGQtRsGLhMEZpILz9Y6KX fUSVpXv75m2cl0T+D566zAd1Sps9fJanshAgfstZ6TNGzfx42hQwcCsKRP/oMcEf/yw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796566062; 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=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=mwR//kj7PzFpuMSQhA+aDW2QfPEzYKuoFftMnNt/aH1MZRJqe/Fya6IygSx02dWjFmC1 ilGNIZXw7YmujtMNJKhOCfvdjZLZvtd8XXK8KA3edNDbk1aW4uvvsfDRaej55XDfS7IQv Gs2VXv0ado9VUSgBfLDMrQRY6yF/mmMI/J/07gpMxleuQ66uWHKAr1pWhGtMyPoyoxgie FizbqEaVymQ4o/8LWMPvBfxvwQt4G4REYiFv3nW00Hi2Q1su/IVKdYLaSE3QtkoW8WZGD /sjVgaEccihZq1cdYcZll8ULoXb9cuQA9n77of2XngRj+5Eqp8xE5TD7UUc0HxVX71w== 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=jH9OSXEA; arc=none smtp.remote-ip=209.85.221.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 D83A8606A680 for ; Sun, 6 Dec 2026 14:07:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D83A8606A680 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=jH9OSXEA Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-490c3ae81d3so1407712f8f.2 for ; Sun, 06 Dec 2026 06:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796566058; x=1797170858; 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=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=jH9OSXEAm6FT2Rhwr08aMXNx/7IXwzQQoY6NzKxHiOqxf2OYGtNZhWWf4LSjdwg+Df Caa4YCinUhUHtdOugaFICFIMNTq3hXO4VgwlF3Jr2KUekOf3tFIUjMi8JC1iioWnDema TDkM6+RZ0obWXJYMwgs4UvI0Z86buHDxXv5hAoQ86ShBTyrEgmDt0XRJDZXS7rpOPTiT LI/qdTF/YJjDaNmM/Y4RJjgqlw0/gcP5jsyFwVS2dashX2SJIL8wODpGrvkN9KXCosMb mYkdgZXPlEnfDNT+I72l/RO/0FFGiJUjP6t4+458vS/48InokUrrVQu8UrF+Ylwvt6JV 54WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796566058; x=1797170858; 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=NIfq5wxvt7dtjYXQEsH+V1X5F3RBHOBqcfg7nQ3MWCk=; b=2fFNNUA7CaRzfFz1i8UJp8piRyc25zDI2y3t19HMRnH0ihVCR1/p3oEn5iuOBnRHNG Hoh6p6/zxjDXsUIC1TWhZJdbARfDa9/Gsz6QoYeiXyt4TWhCgaaHYE3YUPrqMI29Dwfo B2awORq5gCWY0juGPKfqysoGm+/ZO+DAt2LgWQhWP6k1lG+K0vCBvonwCLJav1whBkOn LZYlC9yJAE2fGGo9YIYMtsfYiuG3jvswpBWCotN8i2dMfXVhxMGKL8hBBGESYXBZSyQJ S0pxx9ncTEIgsLawzRwCCnbl1r4k9X/p6sHjI8DHBt5qyk43STnAX25yGoZNUZ2sKjNh wiuQ== X-Forwarded-Encrypted: i=1; AL+hErHEy/2KV6zxHbYTiB/tj1f3MwDNhxWKf4/C1s3EslEJMzROBpCIESz5pYxi+vBH9HO0HjS4gE+Z+LM=@vger.kernel.org X-Gm-Message-State: AB4q+uFxyGjlAKUhkyW6WNGNamq3Ys6cw1wWZ21CzqGh5lpd8BiCDrHE EtJNKxUPr8OyzzwXQjuzovkrDnHZIXCvo/SLRzcGQmukDWWPf7TE5QX/ X-Gm-Gg: AZFdTZcIQgaoeLaYQMPiz2BWL+M7zdaEB3uOQjpcu/IriBpfP/6z5KnCOqYQuFsP8RE GqCYkf86LXIec0H9SuqAgXlAHODwFB9mhUZd6Xz/Ls4HB3g/kwL0zcaKO7jdTY8mhonTDt+slk5 eWslm9sIDYSuQlPMdNE4itni1LPTIZM8LWTOUyUBBudermiUljgyVCpCfBGw2QALSF6JxQFgx1L 8jtdCuqhdmzH0ot8Qpb9fj2oZ7boSyu/UT2lGcTl2r5cp05Nkp8GRZKesyeFhBe+LF1Lt6XeevN ZIrOFEcKWygFenM6fCSIqrgY5n8cpZ2uPCvjvAxO4zRj6j7dj+DzJb+0/VwaLeUCLvk2W8qukei gFNCGgBR/Plmra5SEMMV8FkiB0MD3w2oxx8S1jRxcT3/erwbW+ok7go16N7kFt08huPADyLdVNy FAUy5zAZ1zVYrBQqY7ruO1tFJE+3Iz1W+HEipd6cn/fgCRl8aV+ei824/OrgZEB8+gP2WbmsmY/ SV7Sj0NOQ00/hfrzpl1LYnHjBaM67wWPBfMCVgjPCyL3ksed1pN74ZsdXvcz7XJJgOiWBM1kJXm g+EYEV38AFr8MQpl/s0ucdKWuw== X-Received: by 2002:a05:6000:2f87:b0:490:71a7:6f51 with SMTP id ffacd0b85a97d-4d1ea5a8a51mr14871615f8f.45.1796566058225; Sun, 06 Dec 2026 06:07:38 -0800 (PST) Received: from localhost ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17435e021sm16956832f8f.50.2026.12.06.06.07.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Dec 2026 06:07:37 -0800 (PST) X-Mailing-List: linux-nfs@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=0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Sun, 06 Dec 2026 15:07:35 +0100 Message-Id: Subject: Re: [PATCH v5 04/12] fs: switch fileattr_set_prepare() to xflags and refactor projid check From: "koraynilay" To: "Amir Goldstein" , "koraynilay" Cc: "Namjae Jeon" , "Hyunchul Lee" , "Jonathan Corbet" , "Eric Biggers" , "Theodore Y . Ts'o" , "Jaegeuk Kim" , "Alexander Viro" , "Christian Brauner" , "Shuah Khan" , "Randy Dunlap" , "Chuck Lever" , "Jeff Layton" , "Jan Kara" , "Alexander Aring" , "Darrick J . Wong" , "Andrey Albershteyn" , "Miklos Szeredi" , =?utf-8?q?Pali_Roh=C3=A1r?= , "Lauri Gates" , "Christoph Hellwig" , "Dave Chinner" , , , , , , , , , X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261205142411.164484-1-koray.fra@gmail.com> <20261205142411.164484-5-koray.fra@gmail.com> In-Reply-To: --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On Sun Dec 6, 2026 at 3:04 PM CET, Amir Goldstein wrote: > On Sun, Dec 6, 2026 at 3:00=E2=80=AFPM koraynilay w= rote: >> >> On Sun Dec 6, 2026 at 1:19 PM CET, Amir Goldstein wrote: >> > On Sat, Dec 5, 2026 at 3:24=E2=80=AFPM koraynilay wrote: >> >> >> >> In preparation for the addition of masks to the fileattr API, switch >> >> fileattr_set_prepare() checks from using FS_*_FL flags to FS_XFLAG_* >> >> xflags and refactor project ID value check to be cleaner. >> >> >> >> Signed-off-by: koraynilay >> >> --- >> >> fs/file_attr.c | 30 ++++++++++++++++++++---------- >> >> 1 file changed, 20 insertions(+), 10 deletions(-) >> >> >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> >> index 77e2f1bc22ad..c1a0272f1a83 100644 >> >> --- a/fs/file_attr.c >> >> +++ b/fs/file_attr.c >> >> @@ -74,6 +74,14 @@ void fileattr_fill_flags(struct file_kattr *fa, u3= 2 flags) >> >> } >> >> EXPORT_SYMBOL(fileattr_fill_flags); >> >> >> >> +static u32 xflags_to_flags(u32 xflags) >> >> +{ >> >> + struct file_kattr tmp =3D {}; >> >> + >> >> + fileattr_fill_xflags(&tmp, xflags); >> >> + return tmp.flags; >> >> +} >> >> + >> >> /** >> >> * vfs_fileattr_get - retrieve miscellaneous file attributes >> >> * @dentry: the object to retrieve from >> >> @@ -201,17 +209,20 @@ static int fileattr_set_prepare(struct inode *i= node, >> >> const struct file_kattr *old_ma, >> >> struct file_kattr *fa) >> >> { >> >> + u32 changed =3D (fa->fsx_xflags ^ old_ma->fsx_xflags) & FSX_F= SXATTR_MASK; >> >> int err; >> >> >> >> /* >> >> * The IMMUTABLE and APPEND_ONLY flags can only be changed by >> >> * the relevant capability. >> >> */ >> >> - if ((fa->flags ^ old_ma->flags) & (FS_APPEND_FL | FS_IMMUTABL= E_FL) && >> >> + if (changed & (FS_XFLAG_APPEND | FS_XFLAG_IMMUTABLE) && >> >> !capable(CAP_LINUX_IMMUTABLE)) >> >> return -EPERM; >> >> >> >> - err =3D fscrypt_prepare_setflags(inode, old_ma->flags, fa->fl= ags); >> >> + err =3D fscrypt_prepare_setflags(inode, >> >> + xflags_to_flags(old_ma->fsx_xf= lags), >> >> + xflags_to_flags(fa->fsx_xflags= )); >> > >> > Why is this needed? >> > fa->flags and old_ma->flags are kept in sync with fsx_xflags by the >> > VFS in all paths, >> Right, >> > including the masks conversions, >> > and fscrypt only cares about a newly set CASEFOLD flag. >> > I think this hunk can be dropped and xflags_to_flags() can be introduc= ed >> > in the patch that first needs it. >> >> but wouldn't it be better to keep it for consistency, since from now on >> set_prepare should only handle xflags, and not rely on the assumption >> that flags is kept up to date? >> >> Though since right now it is kept up to date in all paths, we would just >> need to be careful in later patches and wait until fscrypt_prepare_setfl= ags >> is switched to xflags (?). >> > > I think it need to be switched to xlags with signature and name change > as we discussed in v2, but for now, I think it is a bit of an overkill, s= o > a simple TODO: comment will do and no need for the xflags_to_flags(). Ok that makes sense, will do that. Thanks, koraynilay > Thanks, > Amir. --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSgVimKafU5DQMcjcDmj22qf5IGXAUCaxVsJwAKCRDmj22qf5IG XPMbAP9L29QaPNfMoLPeUMR3NSY0m9o7tENmtYfvuy97RuVsZQD/V7S601zK3WQM y1pfOYONDSndF1xD/5sSi00KrE7XcA8= =+Cwu -----END PGP SIGNATURE----- --0c72347b9d303144d49995b0820c9afee41f71d286bf4f6763a3a1f80d2c--