From nobody Thu Sep 11 01:49:18 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70CAA32CF6C; Wed, 10 Sep 2025 14:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757515061; cv=none; b=pfUs2egxBWD0XJzYWkIQyYTF0941vDcIUej3+iTq7yusreHecfGttchy6N1O6vwpIcQPG2fB130EwtzKbqAS1YX/8U33gRNZHWP78dhQBOR2XGh6vJ4lqpV5VmKnihPqbkRTwHcnCmdfOAsc9kOW+Myii5OUJUQRGyuvvWa4FfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757515061; c=relaxed/simple; bh=B7r5xME705JZrGrmvpUjQFvU/5IFdDDiURc8AUJwiiQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uR/uzzhyag90UAHhK1dCn7ITTDEh2E75qCQe6B14trHVrfOK77pT0KkSaFnSleNnHEbZRzbdfkc6TslEWur/Dy59nUw+EgzH8dnS9VqyVwSI8fBe6HD7t7BNiSXG8sC6tYsw0MVDY6sYqEbOgcIy50G3YjSacp5IFkiMPw/c7jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EYrDm3fo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EYrDm3fo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB1F1C4CEF0; Wed, 10 Sep 2025 14:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757515061; bh=B7r5xME705JZrGrmvpUjQFvU/5IFdDDiURc8AUJwiiQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EYrDm3foVgRyetarOPPjGBoKL2jTXbEF663pJ31nlzq+EkFi4aicPOLyWGk0pSsVg 7cEYzyu+yorQ401tF4RAPXrix8y4scRYTaAYzme7koY7wTXU9cNFmEernTGng4pyq8 pF08kk1+/JWQhNa8O1tlLB9KMhu28Umklv2TsL1Vd+9QL7bVaef5L3haS2UasPdwFy 82b56iaBwX0cxZq+q6Lb87l/ZJnW/JZizBfcY9ce04Z+bZfXMiK7lMTndKW6AjO6Fc uR9zu8Q7mR4ASbQFJUeIfWp4MAJmsfbS9pOp01yrjqiR8o3wPOjdVokw7Sv3i8hVF5 t0Sp1JCGUUp2g== From: Christian Brauner Date: Wed, 10 Sep 2025 16:36:51 +0200 Subject: [PATCH 06/32] ns: uniformly initialize ns_common Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250910-work-namespace-v1-6-4dd56e7359d8@kernel.org> References: <20250910-work-namespace-v1-0-4dd56e7359d8@kernel.org> In-Reply-To: <20250910-work-namespace-v1-0-4dd56e7359d8@kernel.org> To: Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org Cc: Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Alexander Viro , Jens Axboe , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Chuck Lever , linux-nfs@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.14.3-dev-385fa X-Developer-Signature: v=1; a=openpgp-sha256; l=1007; i=brauner@kernel.org; h=from:subject:message-id; bh=B7r5xME705JZrGrmvpUjQFvU/5IFdDDiURc8AUJwiiQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWQc7OWYG3gylSNZ7e36oD8rmc/dLJxQHzZ5Qgz/jTK/C bcihT5O7yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIueMMfziTxU4wauybahl0 I6f+QpvjMqPdW+zW1jnPE6tPb/LdsJmR4cksdlvXEGMRHvadktu3yLnx+tSr++TZn57q2GWn/Uu QHQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No point in cargo-culting the same code across all the different types. Use one common initializer. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- include/linux/proc_ns.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 5e1a4b378b79..dbb119bda097 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h @@ -72,6 +72,22 @@ static inline int ns_alloc_inum(struct ns_common *ns) return proc_alloc_inum(&ns->inum); } =20 +static inline int ns_common_init(struct ns_common *ns, + const struct proc_ns_operations *ops, + bool alloc_inum) +{ + if (alloc_inum) { + int ret; + ret =3D proc_alloc_inum(&ns->inum); + if (ret) + return ret; + } + refcount_set(&ns->count, 1); + ns->stashed =3D NULL; + ns->ops =3D ops; + return 0; +} + #define ns_free_inum(ns) proc_free_inum((ns)->inum) =20 #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private) --=20 2.47.3