aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/client.c
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2009-04-01 09:22:55 -0400
committerBenny Halevy <bhalevy@panasas.com>2009-06-17 15:43:47 -0400
commit9bdaa86d2a4cbf9a71de3048c0c0a874e7ebc8ad (patch)
treed12e23a15e86b929e3840116741696765000a6b4 /fs/nfs/client.c
parentf4a2e418bfd03a1f25f515e8a92ecd584d96cfc1 (diff)
nfs41: Refactor nfs4_{init,destroy}_callback for nfs4.0
Refactor-out code to bring the callback service up and down. Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r--fs/nfs/client.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 3e232bf56dfb..d9657d455730 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -47,6 +47,9 @@
47#include "internal.h" 47#include "internal.h"
48#include "fscache.h" 48#include "fscache.h"
49 49
50static int nfs4_init_callback(struct nfs_client *);
51static void nfs4_destroy_callback(struct nfs_client *);
52
50#define NFSDBG_FACILITY NFSDBG_CLIENT 53#define NFSDBG_FACILITY NFSDBG_CLIENT
51 54
52static DEFINE_SPINLOCK(nfs_client_lock); 55static DEFINE_SPINLOCK(nfs_client_lock);
@@ -121,11 +124,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
121 124
122 clp->rpc_ops = cl_init->rpc_ops; 125 clp->rpc_ops = cl_init->rpc_ops;
123 126
124 if (cl_init->rpc_ops->version == 4) { 127 if (nfs4_init_callback(clp) < 0)
125 if (nfs_callback_up() < 0) 128 goto error_2;
126 goto error_2;
127 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
128 }
129 129
130 atomic_set(&clp->cl_count, 1); 130 atomic_set(&clp->cl_count, 1);
131 clp->cl_cons_state = NFS_CS_INITING; 131 clp->cl_cons_state = NFS_CS_INITING;
@@ -162,8 +162,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
162 return clp; 162 return clp;
163 163
164error_3: 164error_3:
165 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) 165 nfs4_destroy_callback(clp);
166 nfs_callback_down();
167error_2: 166error_2:
168 kfree(clp); 167 kfree(clp);
169error_0: 168error_0:
@@ -184,6 +183,17 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
184} 183}
185 184
186/* 185/*
186 * Destroy the NFS4 callback service
187 */
188static void nfs4_destroy_callback(struct nfs_client *clp)
189{
190#ifdef CONFIG_NFS_V4
191 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
192 nfs_callback_down();
193#endif /* CONFIG_NFS_V4 */
194}
195
196/*
187 * Clears/puts all minor version specific parts from an nfs_client struct 197 * Clears/puts all minor version specific parts from an nfs_client struct
188 * reverting it to minorversion 0. 198 * reverting it to minorversion 0.
189 */ 199 */
@@ -215,8 +225,7 @@ static void nfs_free_client(struct nfs_client *clp)
215 if (!IS_ERR(clp->cl_rpcclient)) 225 if (!IS_ERR(clp->cl_rpcclient))
216 rpc_shutdown_client(clp->cl_rpcclient); 226 rpc_shutdown_client(clp->cl_rpcclient);
217 227
218 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) 228 nfs4_destroy_callback(clp);
219 nfs_callback_down();
220 229
221 if (clp->cl_machine_cred != NULL) 230 if (clp->cl_machine_cred != NULL)
222 put_rpccred(clp->cl_machine_cred); 231 put_rpccred(clp->cl_machine_cred);
@@ -1088,6 +1097,25 @@ error:
1088 1097
1089#ifdef CONFIG_NFS_V4 1098#ifdef CONFIG_NFS_V4
1090/* 1099/*
1100 * Initialize the NFS4 callback service
1101 */
1102static int nfs4_init_callback(struct nfs_client *clp)
1103{
1104 int error;
1105
1106 if (clp->rpc_ops->version == 4) {
1107 error = nfs_callback_up();
1108 if (error < 0) {
1109 dprintk("%s: failed to start callback. Error = %d\n",
1110 __func__, error);
1111 return error;
1112 }
1113 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
1114 }
1115 return 0;
1116}
1117
1118/*
1091 * Initialize the minor version specific parts of an NFS4 client record 1119 * Initialize the minor version specific parts of an NFS4 client record
1092 */ 1120 */
1093static int nfs4_init_client_minor_version(struct nfs_client *clp) 1121static int nfs4_init_client_minor_version(struct nfs_client *clp)