Commit 97dc1359 authored by Trond Myklebust's avatar Trond Myklebust

NFSv41: Clean up the NFSv4.1 minor version specific operations

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent a2118c33
...@@ -150,6 +150,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ ...@@ -150,6 +150,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
clp->cl_boot_time = CURRENT_TIME; clp->cl_boot_time = CURRENT_TIME;
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
clp->cl_minorversion = cl_init->minorversion; clp->cl_minorversion = cl_init->minorversion;
clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
#endif #endif
cred = rpc_lookup_machine_cred(); cred = rpc_lookup_machine_cred();
if (!IS_ERR(cred)) if (!IS_ERR(cred))
...@@ -178,7 +179,7 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp) ...@@ -178,7 +179,7 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp)
clp->cl_session = NULL; clp->cl_session = NULL;
} }
clp->cl_call_sync = _nfs4_call_sync; clp->cl_mvops = nfs_v4_minor_ops[0];
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
} }
...@@ -188,7 +189,7 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp) ...@@ -188,7 +189,7 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp)
static void nfs4_destroy_callback(struct nfs_client *clp) static void nfs4_destroy_callback(struct nfs_client *clp)
{ {
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
nfs_callback_down(clp->cl_minorversion); nfs_callback_down(clp->cl_mvops->minor_version);
} }
static void nfs4_shutdown_client(struct nfs_client *clp) static void nfs4_shutdown_client(struct nfs_client *clp)
...@@ -1126,7 +1127,7 @@ static int nfs4_init_callback(struct nfs_client *clp) ...@@ -1126,7 +1127,7 @@ static int nfs4_init_callback(struct nfs_client *clp)
return error; return error;
} }
error = nfs_callback_up(clp->cl_minorversion, error = nfs_callback_up(clp->cl_mvops->minor_version,
clp->cl_rpcclient->cl_xprt); clp->cl_rpcclient->cl_xprt);
if (error < 0) { if (error < 0) {
dprintk("%s: failed to start callback. Error = %d\n", dprintk("%s: failed to start callback. Error = %d\n",
...@@ -1143,10 +1144,8 @@ static int nfs4_init_callback(struct nfs_client *clp) ...@@ -1143,10 +1144,8 @@ static int nfs4_init_callback(struct nfs_client *clp)
*/ */
static int nfs4_init_client_minor_version(struct nfs_client *clp) static int nfs4_init_client_minor_version(struct nfs_client *clp)
{ {
clp->cl_call_sync = _nfs4_call_sync;
#if defined(CONFIG_NFS_V4_1) #if defined(CONFIG_NFS_V4_1)
if (clp->cl_minorversion) { if (clp->cl_mvops->minor_version) {
struct nfs4_session *session = NULL; struct nfs4_session *session = NULL;
/* /*
* Create the session and mark it expired. * Create the session and mark it expired.
...@@ -1158,7 +1157,6 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) ...@@ -1158,7 +1157,6 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
return -ENOMEM; return -ENOMEM;
clp->cl_session = session; clp->cl_session = session;
clp->cl_call_sync = _nfs4_call_sync_session;
} }
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
...@@ -1454,7 +1452,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, ...@@ -1454,7 +1452,7 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
data->authflavor, data->authflavor,
parent_server->client->cl_xprt->prot, parent_server->client->cl_xprt->prot,
parent_server->client->cl_timeout, parent_server->client->cl_timeout,
parent_client->cl_minorversion); parent_client->cl_mvops->minor_version);
if (error < 0) if (error < 0)
goto error; goto error;
......
...@@ -52,6 +52,16 @@ enum nfs4_session_state { ...@@ -52,6 +52,16 @@ enum nfs4_session_state {
NFS4_SESSION_DRAINING, NFS4_SESSION_DRAINING,
}; };
struct nfs4_minor_version_ops {
u32 minor_version;
int (*call_sync)(struct nfs_server *server,
struct rpc_message *msg,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res,
int cache_reply);
};
/* /*
* struct rpc_sequence ensures that RPC calls are sent in the exact * struct rpc_sequence ensures that RPC calls are sent in the exact
* order that they appear on the list. * order that they appear on the list.
...@@ -260,6 +270,7 @@ static inline int nfs4_init_session(struct nfs_server *server) ...@@ -260,6 +270,7 @@ static inline int nfs4_init_session(struct nfs_server *server)
} }
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
extern struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[]; extern struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[];
extern const u32 nfs4_fattr_bitmap[2]; extern const u32 nfs4_fattr_bitmap[2];
......
...@@ -667,7 +667,7 @@ int _nfs4_call_sync(struct nfs_server *server, ...@@ -667,7 +667,7 @@ int _nfs4_call_sync(struct nfs_server *server,
} }
#define nfs4_call_sync(server, msg, args, res, cache_reply) \ #define nfs4_call_sync(server, msg, args, res, cache_reply) \
(server)->nfs_client->cl_call_sync((server), (msg), &(args)->seq_args, \ (server)->nfs_client->cl_mvops->call_sync((server), (msg), &(args)->seq_args, \
&(res)->seq_res, (cache_reply)) &(res)->seq_res, (cache_reply))
static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
...@@ -5353,6 +5353,18 @@ struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = { ...@@ -5353,6 +5353,18 @@ struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
}; };
#endif #endif
static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
.minor_version = 0,
.call_sync = _nfs4_call_sync,
};
#if defined(CONFIG_NFS_V4_1)
static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
.minor_version = 1,
.call_sync = _nfs4_call_sync_session,
};
#endif
/* /*
* Per minor version reboot and network partition recovery ops * Per minor version reboot and network partition recovery ops
*/ */
...@@ -5378,6 +5390,13 @@ struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[] = { ...@@ -5378,6 +5390,13 @@ struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[] = {
#endif #endif
}; };
const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = {
[0] = &nfs_v4_0_minor_ops,
#if defined(CONFIG_NFS_V4_1)
[1] = &nfs_v4_1_minor_ops,
#endif
};
static const struct inode_operations nfs4_file_inode_operations = { static const struct inode_operations nfs4_file_inode_operations = {
.permission = nfs_permission, .permission = nfs_permission,
.getattr = nfs_getattr, .getattr = nfs_getattr,
......
...@@ -15,6 +15,7 @@ struct nlm_host; ...@@ -15,6 +15,7 @@ struct nlm_host;
struct nfs4_sequence_args; struct nfs4_sequence_args;
struct nfs4_sequence_res; struct nfs4_sequence_res;
struct nfs_server; struct nfs_server;
struct nfs4_minor_version_ops;
/* /*
* The nfs_client identifies our client state to the server. * The nfs_client identifies our client state to the server.
...@@ -70,11 +71,7 @@ struct nfs_client { ...@@ -70,11 +71,7 @@ struct nfs_client {
*/ */
char cl_ipaddr[48]; char cl_ipaddr[48];
unsigned char cl_id_uniquifier; unsigned char cl_id_uniquifier;
int (* cl_call_sync)(struct nfs_server *server, const struct nfs4_minor_version_ops *cl_mvops;
struct rpc_message *msg,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res,
int cache_reply);
#endif /* CONFIG_NFS_V4 */ #endif /* CONFIG_NFS_V4 */
#ifdef CONFIG_NFS_V4_1 #ifdef CONFIG_NFS_V4_1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment