public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neilb@suse.de>, Lorenzo Bianconi <lorenzo@kernel.org>
Cc: linux-nfs@vger.kernel.org, lorenzo.bianconi@redhat.com,
	chuck.lever@oracle.com
Subject: Re: [PATCH v4 1/2] SUNRPC: add verbose parameter to __svc_print_addr()
Date: Mon, 31 Jul 2023 12:11:20 -0400	[thread overview]
Message-ID: <b519542134a605daa2d41742b1bfd0e8a1a2f436.camel@kernel.org> (raw)
In-Reply-To: <169058239308.32308.14184895022271604035@noble.neil.brown.name>

On Sat, 2023-07-29 at 08:13 +1000, NeilBrown wrote:
> On Sat, 29 Jul 2023, Lorenzo Bianconi wrote:
> > Introduce verbose parameter to utility routine in order to reduce output
> > verbosity. This is a preliminary patch to add rpc_status entry in nfsd
> > debug filesystem in order to dump pending RPC requests debugging
> > information.
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> >  include/linux/sunrpc/svc_xprt.h | 12 ++++++------
> >  net/sunrpc/svc_xprt.c           |  2 +-
> >  2 files changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
> > index a6b12631db21..1715d4c6bd6b 100644
> > --- a/include/linux/sunrpc/svc_xprt.h
> > +++ b/include/linux/sunrpc/svc_xprt.h
> > @@ -209,21 +209,21 @@ static inline unsigned short svc_xprt_remote_port(const struct svc_xprt *xprt)
> >  }
> >  
> >  static inline char *__svc_print_addr(const struct sockaddr *addr,
> > -				     char *buf, const size_t len)
> > +				     char *buf, const size_t len,
> > +				     bool verbose)
> >  {
> >  	const struct sockaddr_in *sin = (const struct sockaddr_in *)addr;
> >  	const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)addr;
> >  
> >  	switch (addr->sa_family) {
> >  	case AF_INET:
> > -		snprintf(buf, len, "%pI4, port=%u", &sin->sin_addr,
> > -			ntohs(sin->sin_port));
> > +		snprintf(buf, len, "%pI4, %s%u", &sin->sin_addr,
> > +			 verbose ? "port=" : "", ntohs(sin->sin_port));
> 
> I would move the "," into the verbose part too.
> so
>    verbose ? ", port=" : " "
> 
> Other than that, I like this approach.
> 

If we're separating fields in the main seqfile by ' ', then we probably
want to use a different delimiter here in the !verbose case. Maybe ':'
or ',' instead?

Also, ntohs is going to return a short, so the format should probably be
using "%hu" for the port.

> 
> >  		break;
> >  
> >  	case AF_INET6:
> > -		snprintf(buf, len, "%pI6, port=%u",
> > -			 &sin6->sin6_addr,
> > -			ntohs(sin6->sin6_port));
> > +		snprintf(buf, len, "%pI6, %s%u", &sin6->sin6_addr,
> > +			 verbose ? "port=" : "", ntohs(sin6->sin6_port));
> >  		break;
> >  
> >  	default:
> > diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> > index 62c7919ea610..16b794d291a4 100644
> > --- a/net/sunrpc/svc_xprt.c
> > +++ b/net/sunrpc/svc_xprt.c
> > @@ -386,7 +386,7 @@ EXPORT_SYMBOL_GPL(svc_xprt_copy_addrs);
> >   */
> >  char *svc_print_addr(struct svc_rqst *rqstp, char *buf, size_t len)
> >  {
> > -	return __svc_print_addr(svc_addr(rqstp), buf, len);
> > +	return __svc_print_addr(svc_addr(rqstp), buf, len, true);
> >  }
> >  EXPORT_SYMBOL_GPL(svc_print_addr);
> >  
> > -- 
> > 2.41.0
> > 
> > 
> 

-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2023-07-31 16:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28 18:44 [PATCH v4 0/2] add rpc_status handler in nfsd debug filesystem Lorenzo Bianconi
2023-07-28 18:44 ` [PATCH v4 1/2] SUNRPC: add verbose parameter to __svc_print_addr() Lorenzo Bianconi
2023-07-28 22:13   ` NeilBrown
2023-07-31 16:11     ` Jeff Layton [this message]
2023-07-31 22:15       ` NeilBrown
2023-07-28 18:44 ` [PATCH v4 2/2] NFSD: add rpc_status entry in nfsd debug filesystem Lorenzo Bianconi
2023-07-28 19:22   ` Chuck Lever
2023-07-28 22:11     ` NeilBrown
2023-08-04  8:02       ` Lorenzo Bianconi
2023-08-04  7:56     ` Lorenzo Bianconi
2023-08-04 14:02       ` Chuck Lever
2023-07-28 22:23   ` NeilBrown
2023-08-02  8:58     ` Lorenzo Bianconi
2023-07-29  5:18   ` kernel test robot

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=b519542134a605daa2d41742b1bfd0e8a1a2f436.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=neilb@suse.de \
    /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