#include "internal.h"
#include "fscache.h"
+static int nfs4_init_callback(struct nfs_client *);
+static void nfs4_destroy_callback(struct nfs_client *);
+
#define NFSDBG_FACILITY NFSDBG_CLIENT
static DEFINE_SPINLOCK(nfs_client_lock);
clp->rpc_ops = cl_init->rpc_ops;
- if (cl_init->rpc_ops->version == 4) {
- if (nfs_callback_up() < 0)
- goto error_2;
- __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
- }
+ if (nfs4_init_callback(clp) < 0)
+ goto error_2;
atomic_set(&clp->cl_count, 1);
clp->cl_cons_state = NFS_CS_INITING;
return clp;
error_3:
- if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
- nfs_callback_down();
+ nfs4_destroy_callback(clp);
error_2:
kfree(clp);
error_0:
#endif
}
+/*
+ * Destroy the NFS4 callback service
+ */
+static void nfs4_destroy_callback(struct nfs_client *clp)
+{
+#ifdef CONFIG_NFS_V4
+ if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
+ nfs_callback_down();
+#endif /* CONFIG_NFS_V4 */
+}
+
/*
* Clears/puts all minor version specific parts from an nfs_client struct
* reverting it to minorversion 0.
if (!IS_ERR(clp->cl_rpcclient))
rpc_shutdown_client(clp->cl_rpcclient);
- if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
- nfs_callback_down();
+ nfs4_destroy_callback(clp);
if (clp->cl_machine_cred != NULL)
put_rpccred(clp->cl_machine_cred);
}
#ifdef CONFIG_NFS_V4
+/*
+ * Initialize the NFS4 callback service
+ */
+static int nfs4_init_callback(struct nfs_client *clp)
+{
+ int error;
+
+ if (clp->rpc_ops->version == 4) {
+ error = nfs_callback_up();
+ if (error < 0) {
+ dprintk("%s: failed to start callback. Error = %d\n",
+ __func__, error);
+ return error;
+ }
+ __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
+ }
+ return 0;
+}
+
/*
* Initialize the minor version specific parts of an NFS4 client record
*/