diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2013-08-09 12:48:18 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-09-03 15:26:32 -0400 |
commit | a9c92d6b853547ceccb28594af3609ecaf35af6f (patch) | |
tree | 529f09519664edf45d1313104c17622a9aff903e | |
parent | 5a580e0ae2c0228aef4d10d649aaf387bebd70b6 (diff) |
NFS: Common versions of sequence helper functions
NFSv4.0 will have need for this functionality when I add the ability
to block NFSv4.0 traffic before migration recovery.
I'm not really clear on why nfs4_set_sequence_privileged() gets a
generic name, but nfs41_init_sequence() gets a minor
version-specific name.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/nfs4proc.c | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f6be2264e39c..7b702bc49419 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -469,6 +469,21 @@ struct nfs4_call_sync_data { | |||
469 | struct nfs4_sequence_res *seq_res; | 469 | struct nfs4_sequence_res *seq_res; |
470 | }; | 470 | }; |
471 | 471 | ||
472 | static void nfs4_init_sequence(struct nfs4_sequence_args *args, | ||
473 | struct nfs4_sequence_res *res, int cache_reply) | ||
474 | { | ||
475 | args->sa_slot = NULL; | ||
476 | args->sa_cache_this = cache_reply; | ||
477 | args->sa_privileged = 0; | ||
478 | |||
479 | res->sr_slot = NULL; | ||
480 | } | ||
481 | |||
482 | static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args) | ||
483 | { | ||
484 | args->sa_privileged = 1; | ||
485 | } | ||
486 | |||
472 | #if defined(CONFIG_NFS_V4_1) | 487 | #if defined(CONFIG_NFS_V4_1) |
473 | 488 | ||
474 | static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res) | 489 | static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res) |
@@ -617,22 +632,6 @@ static int nfs4_sequence_done(struct rpc_task *task, | |||
617 | return nfs41_sequence_done(task, res); | 632 | return nfs41_sequence_done(task, res); |
618 | } | 633 | } |
619 | 634 | ||
620 | static void nfs41_init_sequence(struct nfs4_sequence_args *args, | ||
621 | struct nfs4_sequence_res *res, int cache_reply) | ||
622 | { | ||
623 | args->sa_slot = NULL; | ||
624 | args->sa_cache_this = 0; | ||
625 | args->sa_privileged = 0; | ||
626 | if (cache_reply) | ||
627 | args->sa_cache_this = 1; | ||
628 | res->sr_slot = NULL; | ||
629 | } | ||
630 | |||
631 | static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args) | ||
632 | { | ||
633 | args->sa_privileged = 1; | ||
634 | } | ||
635 | |||
636 | int nfs41_setup_sequence(struct nfs4_session *session, | 635 | int nfs41_setup_sequence(struct nfs4_session *session, |
637 | struct nfs4_sequence_args *args, | 636 | struct nfs4_sequence_args *args, |
638 | struct nfs4_sequence_res *res, | 637 | struct nfs4_sequence_res *res, |
@@ -773,16 +772,6 @@ static int nfs4_call_sync_sequence(struct rpc_clnt *clnt, | |||
773 | } | 772 | } |
774 | 773 | ||
775 | #else | 774 | #else |
776 | static | ||
777 | void nfs41_init_sequence(struct nfs4_sequence_args *args, | ||
778 | struct nfs4_sequence_res *res, int cache_reply) | ||
779 | { | ||
780 | } | ||
781 | |||
782 | static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args) | ||
783 | { | ||
784 | } | ||
785 | |||
786 | static int nfs4_setup_sequence(const struct nfs_server *server, | 775 | static int nfs4_setup_sequence(const struct nfs_server *server, |
787 | struct nfs4_sequence_args *args, | 776 | struct nfs4_sequence_args *args, |
788 | struct nfs4_sequence_res *res, | 777 | struct nfs4_sequence_res *res, |
@@ -817,7 +806,7 @@ int nfs4_call_sync(struct rpc_clnt *clnt, | |||
817 | struct nfs4_sequence_res *res, | 806 | struct nfs4_sequence_res *res, |
818 | int cache_reply) | 807 | int cache_reply) |
819 | { | 808 | { |
820 | nfs41_init_sequence(args, res, cache_reply); | 809 | nfs4_init_sequence(args, res, cache_reply); |
821 | return server->nfs_client->cl_mvops->call_sync(clnt, server, msg, | 810 | return server->nfs_client->cl_mvops->call_sync(clnt, server, msg, |
822 | args, res); | 811 | args, res); |
823 | } | 812 | } |
@@ -1769,7 +1758,7 @@ static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover) | |||
1769 | }; | 1758 | }; |
1770 | int status; | 1759 | int status; |
1771 | 1760 | ||
1772 | nfs41_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1); | 1761 | nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1); |
1773 | kref_get(&data->kref); | 1762 | kref_get(&data->kref); |
1774 | data->rpc_done = 0; | 1763 | data->rpc_done = 0; |
1775 | data->rpc_status = 0; | 1764 | data->rpc_status = 0; |
@@ -2547,7 +2536,7 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) | |||
2547 | calldata = kzalloc(sizeof(*calldata), gfp_mask); | 2536 | calldata = kzalloc(sizeof(*calldata), gfp_mask); |
2548 | if (calldata == NULL) | 2537 | if (calldata == NULL) |
2549 | goto out; | 2538 | goto out; |
2550 | nfs41_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1); | 2539 | nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1); |
2551 | calldata->inode = state->inode; | 2540 | calldata->inode = state->inode; |
2552 | calldata->state = state; | 2541 | calldata->state = state; |
2553 | calldata->arg.fh = NFS_FH(state->inode); | 2542 | calldata->arg.fh = NFS_FH(state->inode); |
@@ -3312,7 +3301,7 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir) | |||
3312 | 3301 | ||
3313 | res->server = server; | 3302 | res->server = server; |
3314 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; | 3303 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; |
3315 | nfs41_init_sequence(&args->seq_args, &res->seq_res, 1); | 3304 | nfs4_init_sequence(&args->seq_args, &res->seq_res, 1); |
3316 | 3305 | ||
3317 | nfs_fattr_init(res->dir_attr); | 3306 | nfs_fattr_init(res->dir_attr); |
3318 | } | 3307 | } |
@@ -3346,7 +3335,7 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg, struct inode *dir) | |||
3346 | 3335 | ||
3347 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME]; | 3336 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME]; |
3348 | res->server = server; | 3337 | res->server = server; |
3349 | nfs41_init_sequence(&arg->seq_args, &res->seq_res, 1); | 3338 | nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1); |
3350 | } | 3339 | } |
3351 | 3340 | ||
3352 | static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) | 3341 | static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) |
@@ -3954,7 +3943,7 @@ static void nfs4_proc_read_setup(struct nfs_read_data *data, struct rpc_message | |||
3954 | data->timestamp = jiffies; | 3943 | data->timestamp = jiffies; |
3955 | data->read_done_cb = nfs4_read_done_cb; | 3944 | data->read_done_cb = nfs4_read_done_cb; |
3956 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; | 3945 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
3957 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); | 3946 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); |
3958 | } | 3947 | } |
3959 | 3948 | ||
3960 | static void nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data) | 3949 | static void nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data) |
@@ -4038,7 +4027,7 @@ static void nfs4_proc_write_setup(struct nfs_write_data *data, struct rpc_messag | |||
4038 | data->timestamp = jiffies; | 4027 | data->timestamp = jiffies; |
4039 | 4028 | ||
4040 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; | 4029 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; |
4041 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); | 4030 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); |
4042 | } | 4031 | } |
4043 | 4032 | ||
4044 | static void nfs4_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data) | 4033 | static void nfs4_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data) |
@@ -4087,7 +4076,7 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess | |||
4087 | data->commit_done_cb = nfs4_commit_done_cb; | 4076 | data->commit_done_cb = nfs4_commit_done_cb; |
4088 | data->res.server = server; | 4077 | data->res.server = server; |
4089 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; | 4078 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT]; |
4090 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); | 4079 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); |
4091 | } | 4080 | } |
4092 | 4081 | ||
4093 | struct nfs4_renewdata { | 4082 | struct nfs4_renewdata { |
@@ -4901,7 +4890,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co | |||
4901 | data = kzalloc(sizeof(*data), GFP_NOFS); | 4890 | data = kzalloc(sizeof(*data), GFP_NOFS); |
4902 | if (data == NULL) | 4891 | if (data == NULL) |
4903 | return -ENOMEM; | 4892 | return -ENOMEM; |
4904 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); | 4893 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); |
4905 | data->args.fhandle = &data->fh; | 4894 | data->args.fhandle = &data->fh; |
4906 | data->args.stateid = &data->stateid; | 4895 | data->args.stateid = &data->stateid; |
4907 | data->args.bitmask = server->cache_consistency_bitmask; | 4896 | data->args.bitmask = server->cache_consistency_bitmask; |
@@ -5166,7 +5155,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, | |||
5166 | return ERR_PTR(-ENOMEM); | 5155 | return ERR_PTR(-ENOMEM); |
5167 | } | 5156 | } |
5168 | 5157 | ||
5169 | nfs41_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1); | 5158 | nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1); |
5170 | msg.rpc_argp = &data->arg; | 5159 | msg.rpc_argp = &data->arg; |
5171 | msg.rpc_resp = &data->res; | 5160 | msg.rpc_resp = &data->res; |
5172 | task_setup_data.callback_data = data; | 5161 | task_setup_data.callback_data = data; |
@@ -5402,7 +5391,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
5402 | return -ENOMEM; | 5391 | return -ENOMEM; |
5403 | if (IS_SETLKW(cmd)) | 5392 | if (IS_SETLKW(cmd)) |
5404 | data->arg.block = 1; | 5393 | data->arg.block = 1; |
5405 | nfs41_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1); | 5394 | nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1); |
5406 | msg.rpc_argp = &data->arg; | 5395 | msg.rpc_argp = &data->arg; |
5407 | msg.rpc_resp = &data->res; | 5396 | msg.rpc_resp = &data->res; |
5408 | task_setup_data.callback_data = data; | 5397 | task_setup_data.callback_data = data; |
@@ -6266,7 +6255,7 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo) | |||
6266 | }; | 6255 | }; |
6267 | int status; | 6256 | int status; |
6268 | 6257 | ||
6269 | nfs41_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0); | 6258 | nfs4_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0); |
6270 | nfs4_set_sequence_privileged(&args.la_seq_args); | 6259 | nfs4_set_sequence_privileged(&args.la_seq_args); |
6271 | dprintk("--> %s\n", __func__); | 6260 | dprintk("--> %s\n", __func__); |
6272 | task = rpc_run_task(&task_setup); | 6261 | task = rpc_run_task(&task_setup); |
@@ -6572,7 +6561,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, | |||
6572 | nfs_put_client(clp); | 6561 | nfs_put_client(clp); |
6573 | return ERR_PTR(-ENOMEM); | 6562 | return ERR_PTR(-ENOMEM); |
6574 | } | 6563 | } |
6575 | nfs41_init_sequence(&calldata->args, &calldata->res, 0); | 6564 | nfs4_init_sequence(&calldata->args, &calldata->res, 0); |
6576 | if (is_privileged) | 6565 | if (is_privileged) |
6577 | nfs4_set_sequence_privileged(&calldata->args); | 6566 | nfs4_set_sequence_privileged(&calldata->args); |
6578 | msg.rpc_argp = &calldata->args; | 6567 | msg.rpc_argp = &calldata->args; |
@@ -6715,7 +6704,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp, | |||
6715 | calldata->clp = clp; | 6704 | calldata->clp = clp; |
6716 | calldata->arg.one_fs = 0; | 6705 | calldata->arg.one_fs = 0; |
6717 | 6706 | ||
6718 | nfs41_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0); | 6707 | nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0); |
6719 | nfs4_set_sequence_privileged(&calldata->arg.seq_args); | 6708 | nfs4_set_sequence_privileged(&calldata->arg.seq_args); |
6720 | msg.rpc_argp = &calldata->arg; | 6709 | msg.rpc_argp = &calldata->arg; |
6721 | msg.rpc_resp = &calldata->res; | 6710 | msg.rpc_resp = &calldata->res; |
@@ -6906,7 +6895,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags) | |||
6906 | 6895 | ||
6907 | lgp->res.layoutp = &lgp->args.layout; | 6896 | lgp->res.layoutp = &lgp->args.layout; |
6908 | lgp->res.seq_res.sr_slot = NULL; | 6897 | lgp->res.seq_res.sr_slot = NULL; |
6909 | nfs41_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0); | 6898 | nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0); |
6910 | 6899 | ||
6911 | /* nfs4_layoutget_release calls pnfs_put_layout_hdr */ | 6900 | /* nfs4_layoutget_release calls pnfs_put_layout_hdr */ |
6912 | pnfs_get_layout_hdr(NFS_I(inode)->layout); | 6901 | pnfs_get_layout_hdr(NFS_I(inode)->layout); |
@@ -7001,7 +6990,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp) | |||
7001 | int status; | 6990 | int status; |
7002 | 6991 | ||
7003 | dprintk("--> %s\n", __func__); | 6992 | dprintk("--> %s\n", __func__); |
7004 | nfs41_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1); | 6993 | nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1); |
7005 | task = rpc_run_task(&task_setup_data); | 6994 | task = rpc_run_task(&task_setup_data); |
7006 | if (IS_ERR(task)) | 6995 | if (IS_ERR(task)) |
7007 | return PTR_ERR(task); | 6996 | return PTR_ERR(task); |
@@ -7183,7 +7172,7 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync) | |||
7183 | data->args.lastbytewritten, | 7172 | data->args.lastbytewritten, |
7184 | data->args.inode->i_ino); | 7173 | data->args.inode->i_ino); |
7185 | 7174 | ||
7186 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); | 7175 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); |
7187 | task = rpc_run_task(&task_setup_data); | 7176 | task = rpc_run_task(&task_setup_data); |
7188 | if (IS_ERR(task)) | 7177 | if (IS_ERR(task)) |
7189 | return PTR_ERR(task); | 7178 | return PTR_ERR(task); |
@@ -7302,7 +7291,7 @@ static int _nfs41_test_stateid(struct nfs_server *server, | |||
7302 | }; | 7291 | }; |
7303 | 7292 | ||
7304 | dprintk("NFS call test_stateid %p\n", stateid); | 7293 | dprintk("NFS call test_stateid %p\n", stateid); |
7305 | nfs41_init_sequence(&args.seq_args, &res.seq_res, 0); | 7294 | nfs4_init_sequence(&args.seq_args, &res.seq_res, 0); |
7306 | nfs4_set_sequence_privileged(&args.seq_args); | 7295 | nfs4_set_sequence_privileged(&args.seq_args); |
7307 | status = nfs4_call_sync_sequence(server->client, server, &msg, | 7296 | status = nfs4_call_sync_sequence(server->client, server, &msg, |
7308 | &args.seq_args, &res.seq_res); | 7297 | &args.seq_args, &res.seq_res); |
@@ -7407,7 +7396,7 @@ static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server, | |||
7407 | 7396 | ||
7408 | msg.rpc_argp = &data->args; | 7397 | msg.rpc_argp = &data->args; |
7409 | msg.rpc_resp = &data->res; | 7398 | msg.rpc_resp = &data->res; |
7410 | nfs41_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); | 7399 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); |
7411 | if (privileged) | 7400 | if (privileged) |
7412 | nfs4_set_sequence_privileged(&data->args.seq_args); | 7401 | nfs4_set_sequence_privileged(&data->args.seq_args); |
7413 | 7402 | ||