Commit 97dc135947181a6670949a480da56c3ebf8d3715

Authored by Trond Myklebust
1 parent a2118c33aa

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

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 4 changed files with 39 additions and 14 deletions Side-by-side Diff

... ... @@ -150,6 +150,7 @@
150 150 clp->cl_boot_time = CURRENT_TIME;
151 151 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
152 152 clp->cl_minorversion = cl_init->minorversion;
  153 + clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
153 154 #endif
154 155 cred = rpc_lookup_machine_cred();
155 156 if (!IS_ERR(cred))
... ... @@ -178,7 +179,7 @@
178 179 clp->cl_session = NULL;
179 180 }
180 181  
181   - clp->cl_call_sync = _nfs4_call_sync;
  182 + clp->cl_mvops = nfs_v4_minor_ops[0];
182 183 #endif /* CONFIG_NFS_V4_1 */
183 184 }
184 185  
... ... @@ -188,7 +189,7 @@
188 189 static void nfs4_destroy_callback(struct nfs_client *clp)
189 190 {
190 191 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
191   - nfs_callback_down(clp->cl_minorversion);
  192 + nfs_callback_down(clp->cl_mvops->minor_version);
192 193 }
193 194  
194 195 static void nfs4_shutdown_client(struct nfs_client *clp)
... ... @@ -1126,7 +1127,7 @@
1126 1127 return error;
1127 1128 }
1128 1129  
1129   - error = nfs_callback_up(clp->cl_minorversion,
  1130 + error = nfs_callback_up(clp->cl_mvops->minor_version,
1130 1131 clp->cl_rpcclient->cl_xprt);
1131 1132 if (error < 0) {
1132 1133 dprintk("%s: failed to start callback. Error = %d\n",
1133 1134  
... ... @@ -1143,10 +1144,8 @@
1143 1144 */
1144 1145 static int nfs4_init_client_minor_version(struct nfs_client *clp)
1145 1146 {
1146   - clp->cl_call_sync = _nfs4_call_sync;
1147   -
1148 1147 #if defined(CONFIG_NFS_V4_1)
1149   - if (clp->cl_minorversion) {
  1148 + if (clp->cl_mvops->minor_version) {
1150 1149 struct nfs4_session *session = NULL;
1151 1150 /*
1152 1151 * Create the session and mark it expired.
... ... @@ -1158,7 +1157,6 @@
1158 1157 return -ENOMEM;
1159 1158  
1160 1159 clp->cl_session = session;
1161   - clp->cl_call_sync = _nfs4_call_sync_session;
1162 1160 }
1163 1161 #endif /* CONFIG_NFS_V4_1 */
1164 1162  
... ... @@ -1454,7 +1452,7 @@
1454 1452 data->authflavor,
1455 1453 parent_server->client->cl_xprt->prot,
1456 1454 parent_server->client->cl_timeout,
1457   - parent_client->cl_minorversion);
  1455 + parent_client->cl_mvops->minor_version);
1458 1456 if (error < 0)
1459 1457 goto error;
1460 1458  
... ... @@ -52,6 +52,16 @@
52 52 NFS4_SESSION_DRAINING,
53 53 };
54 54  
  55 +struct nfs4_minor_version_ops {
  56 + u32 minor_version;
  57 +
  58 + int (*call_sync)(struct nfs_server *server,
  59 + struct rpc_message *msg,
  60 + struct nfs4_sequence_args *args,
  61 + struct nfs4_sequence_res *res,
  62 + int cache_reply);
  63 +};
  64 +
55 65 /*
56 66 * struct rpc_sequence ensures that RPC calls are sent in the exact
57 67 * order that they appear on the list.
... ... @@ -260,6 +270,7 @@
260 270 }
261 271 #endif /* CONFIG_NFS_V4_1 */
262 272  
  273 +extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
263 274 extern struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[];
264 275  
265 276 extern const u32 nfs4_fattr_bitmap[2];
... ... @@ -667,7 +667,7 @@
667 667 }
668 668  
669 669 #define nfs4_call_sync(server, msg, args, res, cache_reply) \
670   - (server)->nfs_client->cl_call_sync((server), (msg), &(args)->seq_args, \
  670 + (server)->nfs_client->cl_mvops->call_sync((server), (msg), &(args)->seq_args, \
671 671 &(res)->seq_res, (cache_reply))
672 672  
673 673 static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
... ... @@ -5353,6 +5353,18 @@
5353 5353 };
5354 5354 #endif
5355 5355  
  5356 +static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
  5357 + .minor_version = 0,
  5358 + .call_sync = _nfs4_call_sync,
  5359 +};
  5360 +
  5361 +#if defined(CONFIG_NFS_V4_1)
  5362 +static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
  5363 + .minor_version = 1,
  5364 + .call_sync = _nfs4_call_sync_session,
  5365 +};
  5366 +#endif
  5367 +
5356 5368 /*
5357 5369 * Per minor version reboot and network partition recovery ops
5358 5370 */
... ... @@ -5375,6 +5387,13 @@
5375 5387 &nfs40_state_renewal_ops,
5376 5388 #if defined(CONFIG_NFS_V4_1)
5377 5389 &nfs41_state_renewal_ops,
  5390 +#endif
  5391 +};
  5392 +
  5393 +const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = {
  5394 + [0] = &nfs_v4_0_minor_ops,
  5395 +#if defined(CONFIG_NFS_V4_1)
  5396 + [1] = &nfs_v4_1_minor_ops,
5378 5397 #endif
5379 5398 };
5380 5399  
include/linux/nfs_fs_sb.h
... ... @@ -15,6 +15,7 @@
15 15 struct nfs4_sequence_args;
16 16 struct nfs4_sequence_res;
17 17 struct nfs_server;
  18 +struct nfs4_minor_version_ops;
18 19  
19 20 /*
20 21 * The nfs_client identifies our client state to the server.
... ... @@ -70,11 +71,7 @@
70 71 */
71 72 char cl_ipaddr[48];
72 73 unsigned char cl_id_uniquifier;
73   - int (* cl_call_sync)(struct nfs_server *server,
74   - struct rpc_message *msg,
75   - struct nfs4_sequence_args *args,
76   - struct nfs4_sequence_res *res,
77   - int cache_reply);
  74 + const struct nfs4_minor_version_ops *cl_mvops;
78 75 #endif /* CONFIG_NFS_V4 */
79 76  
80 77 #ifdef CONFIG_NFS_V4_1