All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Halevy, Benny" <bhalevy@panasas.com>
To: "Labiaga, Ricardo" <Ricardo.Labiaga@netapp.com>
Cc: "Myklebust, Trond" <Trond.Myklebust@netapp.com>,
	<pnfs@linux-nfs.org>, <linux-nfs@vger.kernel.org>
Subject: RE: [PATCH 08/14] SQUASHME: Removal of ugly #ifdefs
Date: Mon, 15 Jun 2009 12:59:49 -0400	[thread overview]
Message-ID: <7225594ED4A1304C9E43D030A886D221F4C554@daytona.int.panasas.com> (raw)
In-Reply-To: 273FE88A07F5D445824060902F70034406334CCD@SACMVEXC1-PRD.hq.netapp.com

> There are two lines in common between the #ifdef and #else case.
> 
> +	*rqstpp = nfs4_callback_up(serv);
> +	*callback_svc = nfs4_callback_svc;

In the function body...
There's also the function's header.

> 
> Calling it code duplication is a bit of a stretch :-)

I agree it isn't much but still any change you will make
in the future will have to bapplied on both copies and that's bad (IMO).

Benny

> 
> - ricardo

-----Original Message-----
From: Labiaga, Ricardo [mailto:Ricardo.Labiaga@netapp.com]
Sent: Mon 2009-06-15 18:31
To: Halevy, Benny
Cc: Myklebust, Trond; pnfs@linux-nfs.org; linux-nfs@vger.kernel.org
Subject: RE: [PATCH 08/14] SQUASHME: Removal of ugly #ifdefs
 
> -----Original Message-----
> From: Benny Halevy [mailto:bhalevy@panasas.com]
> Sent: Sunday, June 14, 2009 7:30 AM
> To: Labiaga, Ricardo
> Cc: Myklebust, Trond; pnfs@linux-nfs.org; linux-nfs@vger.kernel.org
> Subject: Re: [PATCH 08/14] SQUASHME: Removal of ugly #ifdefs
> 
> On Jun. 12, 2009, 1:54 -0400, Ricardo Labiaga
<Ricardo.Labiaga@netapp.com>
> wrote:
> > [squash with: nfs41: Implement NFSv4.1 callback service process]
> >
> > Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> > ---
> >  fs/nfs/callback.c |   50
+++++++++++++++++++++++++++++++++++-----------
> ----
> >  1 files changed, 35 insertions(+), 15 deletions(-)
> >
> > diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
> > index 4395c96..116424e 100644
> > --- a/fs/nfs/callback.c
> > +++ b/fs/nfs/callback.c
> > @@ -209,6 +209,39 @@ out:
> >  	dprintk("--> %s return %p\n", __func__, rqstp);
> >  	return rqstp;
> >  }
> > +
> > +static inline void nfs_callback_svc_setup(u32 minorversion,
> > +		struct svc_serv *serv, struct rpc_xprt *xprt,
> > +		struct svc_rqst **rqstpp, int (**callback_svc)(void
*vrqstp))
> > +{
> > +	if (minorversion) {
> > +		*rqstpp = nfs41_callback_up(serv, xprt);
> > +		*callback_svc = nfs41_callback_svc;
> > +	} else {
> > +		*rqstpp = nfs4_callback_up(serv);
> > +		*callback_svc = nfs4_callback_svc;
> > +	}
> > +}
> > +
> > +static inline void nfs_callback_bc_serv(u32 minorversion, struct
> rpc_xprt *xprt,
> > +		struct nfs_callback_data *cb_info)
> > +{
> > +	if (minorversion)
> > +		xprt->bc_serv = cb_info->serv;
> > +}
> > +#else
> > +static inline void nfs_callback_svc_setup(u32 minorversion,
> > +		struct svc_serv *serv, struct rpc_xprt *xprt,
> > +		struct svc_rqst **rqstpp, int (**callback_svc)(void
*vrqstp))
> > +{
> > +	*rqstpp = nfs4_callback_up(serv);
> > +	*callback_svc = nfs4_callback_svc;
> > +}
> > +
> > +static inline void nfs_callback_bc_serv(u32 minorversion, struct
> rpc_xprt *xprt,
> > +		struct nfs_callback_data *cb_info)
> > +{
> > +}
> >  #endif /* CONFIG_NFS_V4_1 */
> 
> Although this removes the ungly #ifdefs from inside nfs_callback_up
> it just introduces them elsewhere and what's worse, it adds code
> duplication which is even more unreadable and harder to maintain.
> 

There are two lines in common between the #ifdef and #else case.

+	*rqstpp = nfs4_callback_up(serv);
+	*callback_svc = nfs4_callback_svc;

Calling it code duplication is a bit of a stretch :-)

- ricardo

> How about something along these line?
> 
> static inline void nfs_callback_svc_setup(u32 minorversion,
> 		struct svc_serv *serv, struct rpc_xprt *xprt,
> 		struct svc_rqst **rqstpp, int (**callback_svc)(void
*vrqstp))
> {
> #ifdef CONFIG_NFS_V4_1
> 	if (minorversion) {
> 		*rqstpp = nfs41_callback_up(serv, xprt);
> 		*callback_svc = nfs41_callback_svc;
> 		return;
> 	}
> #endif /* CONFIG_NFS_V4_1 */
> 	*rqstpp = nfs4_callback_up(serv);
> 	*callback_svc = nfs4_callback_svc;
> }
> 
> static inline void nfs_callback_bc_serv(u32 minorversion, struct
rpc_xprt
> *xprt,
> 		struct nfs_callback_data *cb_info)
> {
> #ifdef CONFIG_NFS_V4_1
> 	if (minorversion)
> 		xprt->bc_serv = cb_info->serv;
> #endif /* CONFIG_NFS_V4_1 */
> }
> 
> Benny
> 
> >
> >  /*
> > @@ -225,10 +258,7 @@ int nfs_callback_up(u32 minorversion, struct
> rpc_xprt *xprt)
> >
> >  	mutex_lock(&nfs_callback_mutex);
> >  	if (cb_info->users++ || cb_info->task != NULL) {
> > -#if defined(CONFIG_NFS_V4_1)
> > -		if (minorversion)
> > -			xprt->bc_serv = cb_info->serv;
> > -#endif /* CONFIG_NFS_V4_1 */
> > +		nfs_callback_bc_serv(minorversion, xprt, cb_info);
> >  		goto out;
> >  	}
> >  	serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,
> NULL);
> > @@ -239,17 +269,7 @@ int nfs_callback_up(u32 minorversion, struct
> rpc_xprt *xprt)
> >
> >  	/* FIXME: either 4.0 or 4.1 callback service can be up at a time
> >  	 * need to monitor and control them both */
> > -	if (!minorversion) {
> > -		rqstp = nfs4_callback_up(serv);
> > -		callback_svc = nfs4_callback_svc;
> > -	} else {
> > -#if defined(CONFIG_NFS_V4_1)
> > -		rqstp = nfs41_callback_up(serv, xprt);
> > -		callback_svc = nfs41_callback_svc;
> > -#else  /* CONFIG_NFS_V4_1 */
> > -		BUG();
> > -#endif /* CONFIG_NFS_V4_1 */
> > -	}
> > +	nfs_callback_svc_setup(minorversion, serv, xprt, &rqstp,
> &callback_svc);
> >
> >  	if (IS_ERR(rqstp)) {
> >  		ret = PTR_ERR(rqstp);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs"
in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


      reply	other threads:[~2009-06-15 17:04 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
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 [this message]

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=7225594ED4A1304C9E43D030A886D221F4C554@daytona.int.panasas.com \
    --to=bhalevy@panasas.com \
    --cc=Ricardo.Labiaga@netapp.com \
    --cc=Trond.Myklebust@netapp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.