Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>,
	trondmy@kernel.org,  chuck.lever@oracle.com, anna@kernel.org
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] [RFC] sunrpc: inject process namespace into machinename field
Date: Fri, 26 Jun 2026 10:04:36 -0400	[thread overview]
Message-ID: <7290d0262d782c0c3b26b8167975face1ae91053.camel@kernel.org> (raw)
In-Reply-To: <20260626125216.1467845-2-tigran.mkrtchyan@desy.de>

On Fri, 2026-06-26 at 14:52 +0200, Tigran Mkrtchyan wrote:
> On large shared machines often multiple jobs of a same user run in
> parallel. For debugging, it's usually impossible to identify requests
> coming from different processes.
> 
> The batch systems like HTCondor or SLURM start every job in it's own
> namespace, thus passing namespace info to the server will help by
> debugging.
> 
> Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
> ---
>  net/sunrpc/auth_unix.c | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
> index 6c742a3400c4..b218cfa9871a 100644
> --- a/net/sunrpc/auth_unix.c
> +++ b/net/sunrpc/auth_unix.c
> @@ -15,6 +15,7 @@
>  #include <linux/sunrpc/clnt.h>
>  #include <linux/sunrpc/auth.h>
>  #include <linux/user_namespace.h>
> +#include <linux/pid_namespace.h>
>  
>  
>  #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
> @@ -117,6 +118,28 @@ unx_marshal(struct rpc_task *task, struct xdr_stream *xdr)
>  	struct group_info *gi = cred->cr_cred->group_info;
>  	struct user_namespace *userns = clnt->cl_cred ?
>  		clnt->cl_cred->user_ns : &init_user_ns;
> +	char ns_aware_nodename[UNX_MAXNODENAME + 1];
> +	int ns_aware_nodename_len;
> +
> +	struct pid_namespace *pid_ns = task_active_pid_ns(current);
> +
> +	/* the process runs in a dedicated namespace */
> +	if (pid_ns != &init_pid_ns) {

FYI, Sashiko has some comments on this that seem valid:

https://sashiko.dev/#/patchset/20260626125216.1467845-2-tigran.mkrtchyan@desy.de?part=1

Fetching the user namespace ID might not be correct in some async ops.


> +		/* Format as: <pid_ns_inum>@<current-hostname> */
> +		int prefix_len = snprintf(ns_aware_nodename, sizeof(ns_aware_nodename),
> +			"%u@", pid_ns->ns.inum);
> +
> +		if (prefix_len < sizeof(ns_aware_nodename))
> +			strscpy(ns_aware_nodename + prefix_len, clnt->cl_nodename,
> +				sizeof(ns_aware_nodename) - prefix_len);
> +		else
> +			strscpy(ns_aware_nodename, clnt->cl_nodename, sizeof(ns_aware_nodename));
> +
> +		ns_aware_nodename_len = strlen(ns_aware_nodename);
> +	} else {
> +		ns_aware_nodename_len = clnt->cl_nodelen;
> +		strscpy(ns_aware_nodename, clnt->cl_nodename, sizeof(ns_aware_nodename));
> +	}
>  
>  	/* Credential */
>  
> @@ -126,8 +149,8 @@ unx_marshal(struct rpc_task *task, struct xdr_stream *xdr)
>  	*p++ = rpc_auth_unix;
>  	cred_len = p++;
>  	*p++ = xdr_zero;	/* stamp */
> -	if (xdr_stream_encode_opaque(xdr, clnt->cl_nodename,
> -				     clnt->cl_nodelen) < 0)
> +	if (xdr_stream_encode_opaque(xdr, ns_aware_nodename,
> +				     ns_aware_nodename_len) < 0)
>  		goto marshal_failed;
>  	p = xdr_reserve_space(xdr, 3 * sizeof(*p));
>  	if (!p)

-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2026-06-26 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 12:52 [PATCH 0/1] inject process namespace into machinename field Tigran Mkrtchyan
2026-06-26 12:52 ` [PATCH 1/1] [RFC] sunrpc: " Tigran Mkrtchyan
2026-06-26 14:04   ` Jeff Layton [this message]
2026-06-26 14:21     ` Mkrtchyan, Tigran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7290d0262d782c0c3b26b8167975face1ae91053.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tigran.mkrtchyan@desy.de \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox