From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796513699; b=KWadk89LJG8isL6yMWpFqAAe12Gp6Xv6jsD0NfggVXerutX+3FrvG4YC0LXjGRajfnyv rfroHPADjJSjvL40ggwAB3IMNHevFF0CRDhhYHlnxivqhFkcSm6QSE6V0/YHkOE690DSe pXTpDzg8o0tXxo7+WQ2tSpGVHP+ugpgD4oVPguUG1qCjFz6E2P29tgrpV2M2b/p72AOfE s3UcbS+zR3b7xSEl4e9soHrdTtkmd1GVDTkOz74nFDgweYwwHusyk6ZAXyt6GfY6Q51Ec kzyhgQuBRXr69GqYY9dTlNdO+p5IxjU5tdTue6g0BToaIhA7DqsKdcFxKLiNA+8dEog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796513699; 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:To:Cc:Subject:From:X-Mailer: References:In-Reply-To; bh=6R5Qi7vCgJlk8rBjK6GO5kTHDD4pEW4bt4Jk8VjhVy8=; b=PrGZa3ukrHn5PERE7EDYeOhHu+rLkIElAfEyGp1EJbNn2Uz7U9vok5dPJ8sfaMEMd1Jh +QciY+dEQGQ0mMxZqHpVkh0CEK4JLIGF3+FSE1WYjntC0OJ8T4lDoy9gZ5LQ5/QYHGaxK N7srRCScMLADbsYz0FYcLkyOroju7tnpY5DZThsNCd4MWmSztiKVKLf5e47D+FU5DfTiq EEYyuHgIyWp5/jYt4L9UzuTvzuiv36tN7L+7/P8iosHDlt1l86QbEYcscTddbQUciTWJQ RkcXdbl4xiKEGQvdagnevdqKCodl+0JtrYZhTLfHgtGjVSgvh6ihvS8H7mCwRbCCVtg== 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=DWF7M4F+; arc=none smtp.remote-ip=209.85.221.48 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.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 A47F2606A32F for ; Sat, 5 Dec 2026 23:34:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A47F2606A32F 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=DWF7M4F+ Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-498f5fa5103so1354925f8f.2 for ; Sat, 05 Dec 2026 15:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796513697; x=1797118497; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-type:mime-version:from:to:cc:subject:date:message-id :reply-to:content-type; bh=6R5Qi7vCgJlk8rBjK6GO5kTHDD4pEW4bt4Jk8VjhVy8=; b=DWF7M4F+Tvp2OZ30LajG3QSkooOag5DKti4qR3TVGE5LCDwrNqqRZXN7yKaTOENjEd q7zERbYsKtcfHm2ireEa5JEjuH7jySuk0fEqWTg8mMwten2rtdzzDYVw6+AXzOha9zg8 ygjd+OqMvXNzyWi6fPsO0Y0r9y7q81DFpMN5YohNqGJvk5hxIAyvAZSJlgap3ZlC5o96 3nhJzGMLU9jjc2Iu0UG2JmflAyJHYVdHDMj6fE0PuYfUlTRwASfu+WwV+gcbdhJfw2jS ZdkS0P/aGw0AEAUXzDIc5fnFhTMK5FRTU+gmLFAnKBqNEyKjxBDzRswWSZhMhzwpxk56 2pcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796513697; x=1797118497; h=in-reply-to:references:from:subject:cc:to: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=6R5Qi7vCgJlk8rBjK6GO5kTHDD4pEW4bt4Jk8VjhVy8=; b=k/Nv1MhUfhz4EVjcXWqfsNgtPFS3FMz+j2iAi/q7fkuU9fxd1gWzhP/SPZQmF8jfZt 4WJ2/BuSx5i9METnL81tM0MXKJR489qzc+QdyPsHz2bj2LPNL4FcPXNbVpHJX5TlEyl8 kQI7NC5H/e5luxq8xi16BqCPbl1vEr5OhB/lkJHbVAFG1aNojoQSj2rwhKq/OhFowQdf VzXhX6P8j2PTJZRxuTLe7Stm3CUna5mdrHjJziwD24U+6bUMD+r32u5AVhjmRKievuJG oJOs96HFS4OSNAzwtZukWsRzFleNXlG8CviVfVGRmDXpfJckmqqQvwwMlwTWrY6kGPIP 5O/Q== X-Forwarded-Encrypted: i=1; AL+hErEs+uWwdWdCtF6bbpfYACzdWemp5G6nVmATymp92btIN/KnZGwXW4ov8P3gLQuDNoXvavbJkirOmmk=@vger.kernel.org X-Gm-Message-State: AB4q+uE50vOYVLrBdKP350lNdVBU5IROGYIkqiNQbvN7OwoP/4C/oldi 3k5CHt+BCEL8h4qWkxUWq1Ugcb/+KJ+KFrRwdt23bItgt2qGIbnY+cKn X-Gm-Gg: AZFdTZd78b0Wmpbr5bboLA0WYXcwuelIDnXvq9WKi4qfWT7N0pMqlK3iTxEINfVZEJp +bQdkkPlce/YNWujL2nGFV3lLdKkWoyRKgfDN5ncWJpVy5lZkwGiIU+ATij7QDa34/FA5xbh7Nz hS3MgFsjz5W9SzGBwGxg7aiVD3+eTLxy4inZFGPDZO2e/Hj8qyqgq15jIDB8xlJLs5oPm43Uktz DRMUtHV6JFqbo4iJWK2HqVvwJLYO/ji2a753GBVjYbGFxqXWUa7uco41WR1bJIsJP8UdJuXl5pc 0iQG8MC9qmRypZURJ1QbO6Q7bpF4ucYdh27bbHjy8RKmoNEU8eISLywy8rUeg0PpfAJwlakI8ky X1R3Wb2aW5HUDKUlGJkG6btrpv1zPyhSoFy1v+6DGrP5QvZBkVliCOZajCgdF8O0232OCqDB0Pa w2LzPBQn+WM9X84deeO8OXTF3RfyJGWoSuMndxItwpmwU0oXZ2B9qCRFYGYgvgxziCC19imGbyb +YooY7hz9q2ViL6SJ9Pe9DW0ZFPJguo96n5QFCLSSP49ioQDY3aie5oMm/tbnDnHWHk7GWspRMd YpD74sUqCAQNdHsK9bWHsyr8eA== X-Received: by 2002:a05:6000:178d:b0:4bf:2f91:dc71 with SMTP id ffacd0b85a97d-4d1e9b208e1mr13185715f8f.42.1796513696964; Sat, 05 Dec 2026 15:34:56 -0800 (PST) Received: from localhost ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d168a63852sm13389752f8f.0.2026.12.05.15.34.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Dec 2026 15:34:56 -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=fe9055f17f573ee46d13474a5d7074beb4586a3644924d54c0df95c89156; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Sun, 06 Dec 2026 00:34:54 +0100 Message-Id: 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" , , , , , , , , , Subject: Re: [PATCH v5 07/12] fs: add missing FS_XFLAG_PROJID xflag From: "koraynilay" X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261205142411.164484-1-koray.fra@gmail.com> <20261205142411.164484-8-koray.fra@gmail.com> In-Reply-To: --fe9055f17f573ee46d13474a5d7074beb4586a3644924d54c0df95c89156 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On Sat Dec 5, 2026 at 11:08 PM CET, Amir Goldstein wrote: > On Sat, Dec 5, 2026 at 3:25=E2=80=AFPM koraynilay w= rote: >> >> Add FS_XFLAG_PROJID to the UAPI header and include it in >> FSX_FILEATTR_MASK so file_[gs]etattr() with AT_FILEATTR_MASKS can >> advertise, set and clear the project ID using masks, while keeping it >> out of FS_IOC_FS[GS]ETXATTR and non-AT_FILEATTR_MASKS callers. >> >> Add FSX_FSXATTR_SET_MASK to specify xflags that are settable by >> file_setattr with masks on non-masks filesystems. This macro is then >> used to validate input xflags in fileattr_set_from_masks(). >> >> Signed-off-by: koraynilay >> --- >> fs/file_attr.c | 32 ++++++++++++++++++++++++++------ >> include/linux/fileattr.h | 12 +++++++++++- >> include/uapi/linux/fs.h | 6 ++++-- >> 3 files changed, 41 insertions(+), 9 deletions(-) >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> index 8b9785447e72..7bfd7651d1d8 100644 >> --- a/fs/file_attr.c >> +++ b/fs/file_attr.c >> @@ -138,6 +138,8 @@ static void fileattr_to_file_attr(const struct file_= kattr *fa, >> fattr->fa_extsize =3D fa->fsx_extsize; >> fattr->fa_nextents =3D fa->fsx_nextents; >> fattr->fa_projid =3D fa->fsx_projid; >> + if (fa->fsx_projid) >> + fattr->fa_xflags |=3D FS_XFLAG_PROJID; >> fattr->fa_cowextsize =3D fa->fsx_cowextsize; >> } >> >> @@ -208,6 +210,13 @@ static int file_attr_to_fileattr(const struct file_= attr *fattr, >> else >> fa->fsx_extsize =3D 0; >> >> + if (fa->fsx_xflags & FS_XFLAG_PROJID) >> + fa->fsx_projid =3D fattr->fa_projid; >> + else if ((rw_user_mask & FS_XFLAG_PROJID) && fattr->fa_projid) >> + return -EINVAL; >> + else >> + fa->fsx_projid =3D 0; >> + >> if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) >> fa->fsx_cowextsize =3D fattr->fa_cowextsize; >> else if ((rw_user_mask & FS_XFLAG_COWEXTSIZE) && fattr->fa_cowex= tsize) >> @@ -290,8 +299,11 @@ static int fileattr_set_to_masks(struct file_kattr = *fa, >> if (fa->fsx_extsize !=3D old_ma->fsx_extsize) >> new_rw_mask |=3D new_xflags & FSX_EXTSIZE_MASK; >> >> - if (fa->fsx_projid !=3D old_ma->fsx_projid) >> - return -EOPNOTSUPP; >> + if (fa->fsx_projid !=3D old_ma->fsx_projid) { >> + new_rw_mask |=3D FS_XFLAG_PROJID; >> + if (fa->fsx_projid > 0) >> + new_xflags |=3D FS_XFLAG_PROJID; > > Where did this > 0 come from It came from me checking > 0 for all 3 fields, which then I removed but didn't think of changing this one. > All other places including fileattr_fsx_ok() treat this as > if (fa->fsx_projid) or Yes I agree that's better, changed. > if (fa->fsx_projid !=3D 0) > if you want the uglier version of fileattr_has_fsx() > which I anyway suggested to convert to use fileattr_fsx_ok(). > > Other than this nit, nice readable patch, so: > > Reviewed-by: Amir Goldstein Thanks, koraynilay > Thanks, > Amir. > > >> + } >> >> if ((new_xflags & FS_XFLAG_COWEXTSIZE) && >> fa->fsx_cowextsize !=3D old_ma->fsx_cowextsize) >> @@ -326,14 +338,14 @@ static int fileattr_set_from_masks(struct file_kat= tr *fa, >> u32 new_xflags =3D fa->fsx_xflags; >> u32 new_flags =3D 0; >> >> - if (rw_user_mask & ~(FSX_FSXATTR_MASK & ~FSX_RDONLY_MASK)) >> + if (rw_user_mask & ~FSX_FSXATTR_SET_MASK) >> return -EOPNOTSUPP; >> >> /* Do RMW. */ >> new_xflags |=3D old_ma->fsx_xflags & ~rw_user_mask; >> >> /* RMW filesystems only expect writable fsxattr xflags. */ >> - new_xflags &=3D FSX_FSXATTR_MASK & ~FSX_RDONLY_MASK; >> + new_xflags &=3D FSX_FSXATTR_SET_MASK; >> >> new_flags =3D xflags_to_flags(new_xflags); >> new_flags |=3D old_ma->flags & ~FS_COMMON_FL; >> @@ -357,7 +369,12 @@ static int fileattr_set_from_masks(struct file_katt= r *fa, >> } >> } >> >> - fa->fsx_projid =3D old_ma->fsx_projid; >> + if (!(rw_user_mask & FS_XFLAG_PROJID)) >> + fa->fsx_projid =3D old_ma->fsx_projid; >> + else if (!(fa->fsx_xflags & FS_XFLAG_PROJID)) >> + fa->fsx_projid =3D 0; >> + /* Strip PROJID now that we've used it, old format doesn't have = it. */ >> + new_xflags &=3D ~FS_XFLAG_PROJID; >> >> if (!(rw_user_mask & FS_XFLAG_COWEXTSIZE)) >> fa->fsx_cowextsize =3D old_ma->fsx_cowextsize; >> @@ -443,7 +460,8 @@ static int fileattr_set_prepare(struct inode *inode, >> * namespace. Enforce that restriction only if we are trying to = change >> * the quota ID state. Everything else is allowed in user namesp= aces. >> */ >> - if (!fa->has_masks && old_ma->fsx_projid !=3D fa->fsx_projid) { >> + if ((rw_user_mask & FS_XFLAG_PROJID) && >> + old_ma->fsx_projid !=3D fa->fsx_projid) { >> /* Caller is not allowed to change the project ID. */ >> if (current_user_ns() !=3D &init_user_ns) >> return -EINVAL; >> @@ -488,6 +506,8 @@ static int fileattr_set_prepare(struct inode *inode, >> fa->fsx_xflags &=3D ~FSX_EXTSIZE_MASK; >> if (fa->fsx_cowextsize =3D=3D 0) >> fa->fsx_xflags &=3D ~FS_XFLAG_COWEXTSIZE; >> + if (fa->fsx_projid =3D=3D 0) >> + fa->fsx_xflags &=3D ~FS_XFLAG_PROJID; >> >> return 0; >> } >> diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h >> index adb586e21fd5..8dcabbb294fa 100644 >> --- a/include/linux/fileattr.h >> +++ b/include/linux/fileattr.h >> @@ -52,9 +52,19 @@ >> (FSX_COMMON | FSX_RDONLY_MASK | FSX_VALUES_MASK | \ >> FSX_DIRONLY_MASK | FSX_MISC_MASK) >> >> +/* >> + * Writable xflags for filesystems that don't support masks. >> + * The VFS converts masked requests to FS_IOC_FSSETXATTR format, which = lacks >> + * FS_XFLAG_PROJID and uses only file_kattr.fsx_projid instead. >> + * Include FS_XFLAG_PROJID here so masked callers can use it to select = project >> + * ID changes on unmasked filesystems. >> + */ >> +#define FSX_FSXATTR_SET_MASK \ >> + ((FSX_FSXATTR_MASK & ~FSX_RDONLY_MASK) | FS_XFLAG_PROJID) >> + >> /* All xflags supported by VER1+ file_[gs]etattr() with AT_FILEATTR_MAS= KS */ >> #define FSX_FILEATTR_MASK \ >> - (FSX_FSXATTR_MASK) >> + (FSX_FSXATTR_MASK | FS_XFLAG_PROJID) >> >> /* >> * Merged interface for miscellaneous file attributes. 'flags' origina= tes from >> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h >> index d402db1a2254..337bb00b0e64 100644 >> --- a/include/uapi/linux/fs.h >> +++ b/include/uapi/linux/fs.h >> @@ -236,8 +236,8 @@ struct fsxattr { >> * suggests a preferred extent size for new allocations. (= in/out) >> * @fa_nextents: Number of data extents in the file, read-only. Filled = in by >> * file_getattr(2) and ignored by file_setattr(2). (out) >> - * @fa_projid: Project identifier. Used by quota systems quotactl(2) to= group >> - * related files. (in/out) >> + * @fa_projid: Project identifier, value of FS_XFLAG_PROJID. Used by qu= ota >> + * systems quotactl(2) to group related files. (in/out) >> * @fa_cowextsize: Copy-on-Write (CoW) extent size hint in bytes, value= of >> * FS_XFLAG_COWEXTSIZE. This value suggests a preferred= extent >> * size for CoW operations. (in/out) >> @@ -294,6 +294,8 @@ struct file_attr { >> */ >> #define FS_XFLAG_CASEFOLD 0x00040000 /* case-insensitive look= ups */ >> #define FS_XFLAG_CASENONPRESERVING 0x00080000 /* case not preserved */ >> +#define FS_XFLAG_PROJID 0x00100000 /* project ID */ >> + >> #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this = */ >> >> /* the read-only stuff doesn't really belong here, but any other place = is >> -- >> 2.56.1.dirty >> --fe9055f17f573ee46d13474a5d7074beb4586a3644924d54c0df95c89156 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSgVimKafU5DQMcjcDmj22qf5IGXAUCaxSfngAKCRDmj22qf5IG XNJIAQCCmNUQV1j4Q/PvNw7/1lOX2/XhUUP0Nm5aJuJm0IhtZwEA8coNAxPmF/F2 CuH4vJTdjT++MgP+vPuW8QAdvqkJzQ8= =x01o -----END PGP SIGNATURE----- --fe9055f17f573ee46d13474a5d7074beb4586a3644924d54c0df95c89156--