* [PATCH 0/1] inject process namespace into machinename field @ 2026-06-26 12:52 Tigran Mkrtchyan 2026-06-26 12:52 ` [PATCH 1/1] [RFC] sunrpc: " Tigran Mkrtchyan 0 siblings, 1 reply; 4+ messages in thread From: Tigran Mkrtchyan @ 2026-06-26 12:52 UTC (permalink / raw) To: trondmy, chuck.lever, jlayton, anna; +Cc: linux-nfs, Tigran Mkrtchyan This path don't intended to land into the kernel, but more trigger a discussion and collect some ideas. 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. Tigran Mkrtchyan (1): [RFC] sunrpc: inject process namespace into machinename field net/sunrpc/auth_unix.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) -- 2.54.0 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] [RFC] sunrpc: inject process namespace into machinename field 2026-06-26 12:52 [PATCH 0/1] inject process namespace into machinename field Tigran Mkrtchyan @ 2026-06-26 12:52 ` Tigran Mkrtchyan 2026-06-26 14:04 ` Jeff Layton 0 siblings, 1 reply; 4+ messages in thread From: Tigran Mkrtchyan @ 2026-06-26 12:52 UTC (permalink / raw) To: trondmy, chuck.lever, jlayton, anna; +Cc: linux-nfs, Tigran Mkrtchyan 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) { + /* 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) -- 2.54.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] [RFC] sunrpc: inject process namespace into machinename field 2026-06-26 12:52 ` [PATCH 1/1] [RFC] sunrpc: " Tigran Mkrtchyan @ 2026-06-26 14:04 ` Jeff Layton 2026-06-26 14:21 ` Mkrtchyan, Tigran 0 siblings, 1 reply; 4+ messages in thread From: Jeff Layton @ 2026-06-26 14:04 UTC (permalink / raw) To: Tigran Mkrtchyan, trondmy, chuck.lever, anna; +Cc: linux-nfs 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> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] [RFC] sunrpc: inject process namespace into machinename field 2026-06-26 14:04 ` Jeff Layton @ 2026-06-26 14:21 ` Mkrtchyan, Tigran 0 siblings, 0 replies; 4+ messages in thread From: Mkrtchyan, Tigran @ 2026-06-26 14:21 UTC (permalink / raw) To: Jeff Layton; +Cc: trondmy, chuck lever, anna, linux-nfs [-- Attachment #1: Type: text/plain, Size: 3545 bytes --] Thanks, Jeff. Yes, Chuck has sent me the link too. Indeed, we have noticed that while tracing some applications with perf. Chuck as well suggested using the COMPOUND tag, which sounds more reasonable and will work with RPCSEC_GSS. I will post it after testing. Best regards, Tigran. ----- Original Message ----- > From: "Jeff Layton" <jlayton@kernel.org> > To: "Tigran Mkrtchyan" <tigran.mkrtchyan@desy.de>, "trondmy" <trondmy@kernel.org>, "chuck lever" > <chuck.lever@oracle.com>, "anna" <anna@kernel.org> > Cc: "linux-nfs" <linux-nfs@vger.kernel.org> > Sent: Friday, 26 June, 2026 16:04:36 > Subject: Re: [PATCH 1/1] [RFC] sunrpc: inject process namespace into machinename field > 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> [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 2309 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-26 14:21 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2026-06-26 14:21 ` Mkrtchyan, Tigran
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox