From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796513699; b=tJT9tsX9j1cmcX2STUWyY+cXDOX/+SN4cTKB83to3g1JrSzZf//ha5CgYWDglCJIe2at BeMXtEm8ImnlGsCFHggQm4qBpvBQnax5zrofdpZRatfFQSBboa71/Fjt8X6VgR7HsdIVy qDrHtR7kjG+awsjRLfFnP/HEA49MJTPDcudvNO9Aa0vVD0h6hWAmvztttaDLLUYv1nnO3 Mc3Sw3AC2NpjfAs0HlxOCl6ec4X1XvbIxXq7uLy952tGK92OyPynzOpP933MTzELbZxXe hnp56IFewR4aJMczvPetevotF9YrJeQ5xXYgCgnBJNBLoiUMCfT0w0VEepfRp1BtR1Q== 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=v+3mpI+5chkppIe+wVSURvBIprEH0xO/Lhhhg47Q4P38QPMTL46PJjLWYQHpFPQM7AfV 0+l/8PPwB15Ni+jRkPcQy83/O3VqnoXnM/tSCFAoCR1zfioUKVkTW1khlhi8PfoJlnza/ aNIOtpbP6AwZ1FMHGj7kCBrJKp3mwuQ8Q1SzsX2GxGYTqEQVak8RTf9zQNbddLST7M0vS RObf71vMthF/w5dP8uAaB0waCJfzmEIw1dR5iRflX29QvygzscxwkPm55DqJ0qYg7GEPr 4ZHvda0l/3ZGbHqI85/fm2pjyZ8a/4HQN+RHEADGgblsSqX6TIpJ/U6kFGLtM2hUWyw== 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.45 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 997EB606A31F for ; Sat, 5 Dec 2026 23:34:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 997EB606A31F 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-f45.google.com with SMTP id ffacd0b85a97d-4a32576da88so1224288f8f.3 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=EhQH3oGA7xiXrUu1bbJYDjPdAQ42+431hjm0+gkLyb/b+aMyMpA5fwgcMkv4ud0gIk +AFDIwM73ExwwSDdM9zTo32kZ9+S8FrVJlO0kq9BrgE7XpgNwjqIejoGbJnnU5AmAm36 gBRKd/x5k4TPbGJjSq9aAGHzbTtBpBCx0sLfMz7R9zIglWYYixtlfL27DACH2ji4jO3Y 5W1eOuJoL565qEKnwNUt6v1Nvhm6FHMl60fEPuPFuCw61ibiAG4fnXJStaNPQOsWeisR mvrKovzOCULZ4PzKUyWOnzG5kUFYVZ1rZ/xIN50E3Y0w1pKFacbMbascSviMlKj8286I DJCQ== X-Forwarded-Encrypted: i=1; AL+hErHBVcdUGFH6ubv9OUKi9IaLIctBVbm5LQattLUISGx2YFnIGr80al2oggMZ7AHl362v1SweYX8YAfsgPBvs@vger.kernel.org X-Gm-Message-State: AB4q+uEJjA5YKg8g/la6xKDkgWLycHwzY+fvfwJAyeSIQR2XUH37S7YV zbjUBQ4M/yUfjq5qnyAOAtLMpxFZHV98OyPxJ+cOGeO82lEcxftzPeuc X-Gm-Gg: AZFdTZcHPw7pPDS/tfSzggy1WW/X+/pn/tgLQuF8O2mieVgFoooQyoAArBa8SSrqhPL M/KLH+xmZnNpRnEH5ayjHsEn2BLzAXq8mw6Us0Y6OUrV+LpkdYdrK40TH3Ksj4izpnAuY1l36Oi JP9m0ZqkdvOG7H7QmjjbGXnAcGD9gY8EstpEuImAUdkxM9LFHlApnzDaYahfI5MPlLoP4Tj1RL9 65G9laTzViPZy+3wLH0/rCMh6D4TAF2QNeg/+GQt0AlFstsAmmftWiYn8OjsPggI2TOqvcXOBAC v+EK84AAYXLIdm4F3pSjMX/o1lM2pdJXRcqpcZq1ondvnOPlVgRUsS995U7wgpVaC/FWkL17zGd q9yI2jLKgJSXvLsCWi9i7Ve4bopLsE4suxOtjUfSeMNu49e+9xcvAD4kWJ5G1cGXJzUmthd+fPS pkP2CYHKnsUFQJRLcXFBbtU4IbHt3qA0IEoivd4GTNbDFDlTaB0fD/wI/hvSBKhGRisyv3WT0kI /vvL+ys93vy9RmfUXLI5WWKKnFe8KoPJQu0c5jEFyi5pbEfylSZm2d2QmJMrUqMolNWEgjsgk0R fReXBU3fIhR+LJs98EX5piIJvg== 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-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=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--