public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Benny Halevy <bhalevy@panasas.com>
Cc: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>,
	pnfs@linux-nfs.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 11/14] SQUASHME: Moves embedded #ifdefs into #ifdef function blocks
Date: Sun, 14 Jun 2009 12:55:06 -0400	[thread overview]
Message-ID: <1244998506.5298.2.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <4A350B99.90104@panasas.com>

On Sun, 2009-06-14 at 10:39 -0400, Benny Halevy wrote:
> On Jun. 12, 2009, 1:54 -0400, Ricardo Labiaga <Ricardo.Labiaga@netapp.com> wrote:
> > [squash with: nfs41: New xs_tcp_read_data()]
> > 
> > Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> > ---
> >  net/sunrpc/xprtsock.c |   28 ++++++++++++++++++----------
> >  1 files changed, 18 insertions(+), 10 deletions(-)
> > 
> > diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> > index fe57ebd..c6f24c0 100644
> > --- a/net/sunrpc/xprtsock.c
> > +++ b/net/sunrpc/xprtsock.c
> > @@ -1207,6 +1207,23 @@ static inline int xs_tcp_read_callback(struct rpc_xprt *xprt,
> >  
> >  	return 0;
> >  }
> > +
> > +static inline int _xs_tcp_read_data(struct rpc_xprt *xprt,
> > +					struct xdr_skb_reader *desc)
> > +{
> > +	struct sock_xprt *transport =
> > +				container_of(xprt, struct sock_xprt, xprt);
> > +
> > +	return (transport->tcp_flags & TCP_RPC_REPLY) ?
> > +		xs_tcp_read_reply(xprt, desc) :
> > +		xs_tcp_read_callback(xprt, desc);
> > +}
> > +#else
> > +static inline int _xs_tcp_read_data(struct rpc_xprt *xprt,
> > +					struct xdr_skb_reader *desc)
> > +{
> > +	return xs_tcp_read_reply(xprt, desc);
> > +}
> >  #endif /* CONFIG_NFS_V4_1 */
> 
> Again, I'd be inclined to avoid duplicating code.
> If we want still to use an #ifdef (and in this case
> we might as well just always check the tcp_flags)
> the I'd suggest to code this as follows:
> 
> static inline int _xs_tcp_read_data(struct rpc_xprt *xprt,
> 				    struct xdr_skb_reader *desc)
> {
> #ifdef /* CONFIG_NFS_V4_1 */
> 	struct sock_xprt *transport =
> 				container_of(xprt, struct sock_xprt, xprt);
> 
> 	if (!(transport->tcp_flags & TCP_RPC_REPLY))
> 		return xs_tcp_read_callback(xprt, desc);
> #ifdef /* CONFIG_NFS_V4_1 */
> 
> 	return xs_tcp_read_reply(xprt, desc);
> }
> 
> Benny
> 
> >  
> >  /*
> > @@ -1218,17 +1235,8 @@ static void xs_tcp_read_data(struct rpc_xprt *xprt,
> >  {
> >  	struct sock_xprt *transport =
> >  				container_of(xprt, struct sock_xprt, xprt);
> > -	int status;
> > -
> > -#if defined(CONFIG_NFS_V4_1)
> > -	status = (transport->tcp_flags & TCP_RPC_REPLY) ?
> > -		xs_tcp_read_reply(xprt, desc) :
> > -		xs_tcp_read_callback(xprt, desc);
> > -#else
> > -	status = xs_tcp_read_reply(xprt, desc);
> > -#endif /* CONFIG_NFS_V4_1 */
> >  
> > -	if (status == 0)
> > +	if (_xs_tcp_read_data(xprt, desc) == 0)
> >  		xs_tcp_check_fraghdr(transport);
> >  	else {
> >  		/*
> 

NO! Just put the bits that are v4.1 specific in a function (make said
function empty in the !v4.1 case, and call it from the common code.

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com

  reply	other threads:[~2009-06-14 16:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12  5:54 [PATCH 0/14] Updates to nfs41 client backchannel for 2.6.31 Ricardo Labiaga
2009-06-12  5:54 ` [PATCH 01/14] SQUASHME: Type check arguments of nfs_callback_up Ricardo Labiaga
2009-06-12  5:54   ` [PATCH 02/14] SQUASHME: Update copyright notice and explain page allocation Ricardo Labiaga
2009-06-12  5:54     ` [PATCH 03/14] SQUASHME: Update Copyright notice and fix formatting Ricardo Labiaga
2009-06-12  5:54       ` [PATCH 04/14] SQUASHME: rpc_count_iostats incorrectly exits early Ricardo Labiaga
2009-06-12  5:54         ` [PATCH 05/14] SQUASHME: Convert rpc_reply_expected() to inline function Ricardo Labiaga
2009-06-12  5:54           ` [PATCH 06/14] SQUASHME: Remove unnecessary BUG_ON() Ricardo Labiaga
2009-06-12  5:54             ` [PATCH 07/14] SQUASHME: Rename variable Ricardo Labiaga
2009-06-12  5:54               ` [PATCH 08/14] SQUASHME: Removal of ugly #ifdefs Ricardo Labiaga
2009-06-12  5:54                 ` [PATCH 09/14] SQUASHME: nfs41: sunrpc: Add RPC direction back into the XDR buffer Ricardo Labiaga
2009-06-12  5:54                   ` [PATCH 10/14] SQUASHME: nfs41: sunrpc: Don't skip past the RPC call direction Ricardo Labiaga
2009-06-12  5:54                     ` [PATCH 11/14] SQUASHME: Moves embedded #ifdefs into #ifdef function blocks Ricardo Labiaga
2009-06-12  5:54                       ` [PATCH 12/14] SQUASHME: Removes bc_svc_process() declaration Ricardo Labiaga
2009-06-12  5:54                         ` [PATCH 13/14] SQUASHME: Move bc_svc_process() declaration to correct patch Ricardo Labiaga
2009-06-12  5:54                           ` [PATCH 14/14] SQUASHME: Update copyright Ricardo Labiaga
2009-06-14 14:39                       ` [PATCH 11/14] SQUASHME: Moves embedded #ifdefs into #ifdef function blocks Benny Halevy
2009-06-14 16:55                         ` Trond Myklebust [this message]
2009-06-14 14:34                     ` [PATCH 10/14] SQUASHME: nfs41: sunrpc: Don't skip past the RPC call direction Benny Halevy
2009-06-15 15:37                       ` Labiaga, Ricardo
2009-06-12 14:22                   ` [PATCH 09/14] SQUASHME: nfs41: sunrpc: Add RPC direction back into the XDR buffer Benny Halevy
2009-06-12 15:07                     ` Labiaga, Ricardo
2009-06-14 14:30                 ` [PATCH 08/14] SQUASHME: Removal of ugly #ifdefs Benny Halevy
2009-06-14 16:53                   ` Trond Myklebust
     [not found]                     ` <1244998412.5298.0.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-15  8:48                       ` [pnfs] " Boaz Harrosh
2009-06-15 15:31                   ` Labiaga, Ricardo
2009-06-15 16:59                     ` Halevy, Benny

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=1244998506.5298.2.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=Ricardo.Labiaga@netapp.com \
    --cc=bhalevy@panasas.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=pnfs@linux-nfs.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