public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: linux-kernel@vger.kernel.org
Cc: nfs@lists.sourceforge.net, Neil Brown <neilb@suse.de>,
	"J. Bruce Fields" <bfields@citi.umich.edu>
Subject: [PATCH 13/15] knfsd: remove code duplication in nfsd4_setclientid()
Date: Mon, 27 Aug 2007 16:22:54 -0400	[thread overview]
Message-ID: <11882461782430-git-send-email-bfields@fieldses.org> (raw)
In-Reply-To: <11882461772689-git-send-email-bfields@fieldses.org>

From: J. Bruce Fields <bfields@citi.umich.edu>

Each branch of this if-then-else has a bunch of duplicated code that we
could just put at the end.

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
---
 fs/nfsd/nfs4state.c |   30 ++++++------------------------
 1 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 09573b9..6256492 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -774,13 +774,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		new = create_client(clname, dname);
 		if (new == NULL)
 			goto out;
-		copy_verf(new, &clverifier);
-		new->cl_addr = sin->sin_addr.s_addr;
-		copy_cred(&new->cl_cred,&rqstp->rq_cred);
 		gen_clid(new);
-		gen_confirm(new);
-		gen_callback(new, setclid);
-		add_to_unconfirmed(new, strhashval);
 	} else if (same_verf(&conf->cl_verifier, &clverifier)) {
 		/*
 		 * CASE 1:
@@ -806,13 +800,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		new = create_client(clname, dname);
 		if (new == NULL)
 			goto out;
-		copy_verf(new,&conf->cl_verifier);
-		new->cl_addr = sin->sin_addr.s_addr;
-		copy_cred(&new->cl_cred,&rqstp->rq_cred);
 		copy_clid(new, conf);
-		gen_confirm(new);
-		gen_callback(new, setclid);
-		add_to_unconfirmed(new,strhashval);
 	} else if (!unconf) {
 		/*
 		 * CASE 2:
@@ -825,13 +813,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		new = create_client(clname, dname);
 		if (new == NULL)
 			goto out;
-		copy_verf(new,&clverifier);
-		new->cl_addr = sin->sin_addr.s_addr;
-		copy_cred(&new->cl_cred,&rqstp->rq_cred);
 		gen_clid(new);
-		gen_confirm(new);
-		gen_callback(new, setclid);
-		add_to_unconfirmed(new, strhashval);
 	} else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) {
 		/*	
 		 * CASE3:
@@ -852,19 +834,19 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		new = create_client(clname, dname);
 		if (new == NULL)
 			goto out;
-		copy_verf(new,&clverifier);
-		new->cl_addr = sin->sin_addr.s_addr;
-		copy_cred(&new->cl_cred,&rqstp->rq_cred);
 		gen_clid(new);
-		gen_confirm(new);
-		gen_callback(new, setclid);
-		add_to_unconfirmed(new, strhashval);
 	} else {
 		/* No cases hit !!! */
 		status = nfserr_inval;
 		goto out;
 
 	}
+	copy_verf(new, &clverifier);
+	new->cl_addr = sin->sin_addr.s_addr;
+	copy_cred(&new->cl_cred, &rqstp->rq_cred);
+	gen_confirm(new);
+	gen_callback(new, setclid);
+	add_to_unconfirmed(new, strhashval);
 	setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot;
 	setclid->se_clientid.cl_id = new->cl_clientid.cl_id;
 	memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data));
-- 
1.5.3.rc5.19.g0734d


  reply	other threads:[~2007-08-27 20:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-27 20:22 nfs server patches for review J. Bruce Fields
2007-08-27 20:22 ` [PATCH 01/15] nfsd: tone down inaccurate dprintk J. Bruce Fields
2007-08-27 20:22   ` [PATCH 02/15] nfsd: remove unused cache_for_each macro J. Bruce Fields
2007-08-27 20:22     ` [PATCH 03/15] nfsd: fix horrible indentation in nfsd_setattr J. Bruce Fields
2007-08-27 20:22       ` [PATCH 04/15] knfsd: delete code made redundant by map_new_errors J. Bruce Fields
2007-08-27 20:22         ` [PATCH 05/15] knfsd: cleanup of nfsd4 cmp_* functions J. Bruce Fields
2007-08-27 20:22           ` [PATCH 06/15] knfsd: demote some printk()s to dprintk()s J. Bruce Fields
2007-08-27 20:22             ` [PATCH 07/15] knfsd: nfs4 name->id mapping not correctly parsing negative downcall J. Bruce Fields
2007-08-27 20:22               ` [PATCH 08/15] knfsd: spawn kernel thread to probe callback channel J. Bruce Fields
2007-08-27 20:22                 ` [PATCH 09/15] knfsd: move nfsv4 slab creation/destruction to module init/exit J. Bruce Fields
2007-08-27 20:22                   ` [PATCH 10/15] knfsd: Validate filehandle type in fsid_source J. Bruce Fields
2007-08-27 20:22                     ` [PATCH 11/15] knfsd: fix callback rpc cred J. Bruce Fields
2007-08-27 20:22                       ` [PATCH 12/15] nfsd warning fix J. Bruce Fields
2007-08-27 20:22                         ` J. Bruce Fields [this message]
2007-08-27 20:22                           ` [PATCH 14/15] svcgss: move init code into separate function J. Bruce Fields
2007-08-27 20:22                             ` [PATCH 15/15] knfsd: 64 bit ino support for NFS server J. Bruce Fields
2007-08-27 23:26                 ` [PATCH 08/15] knfsd: spawn kernel thread to probe callback channel Neil Brown
2007-08-27 23:36                   ` J. Bruce Fields

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=11882461782430-git-send-email-bfields@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=bfields@citi.umich.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /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