aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c118
1 files changed, 52 insertions, 66 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 7c0baf23abdc..826b445b8c70 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -718,19 +718,6 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
718 return err; 718 return err;
719} 719}
720 720
721static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata)
722{
723 struct nfs4_opendata *data = calldata;
724 struct rpc_message msg = {
725 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM],
726 .rpc_argp = &data->c_arg,
727 .rpc_resp = &data->c_res,
728 .rpc_cred = data->owner->so_cred,
729 };
730 data->timestamp = jiffies;
731 rpc_call_setup(task, &msg, 0);
732}
733
734static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) 721static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
735{ 722{
736 struct nfs4_opendata *data = calldata; 723 struct nfs4_opendata *data = calldata;
@@ -767,7 +754,6 @@ out_free:
767} 754}
768 755
769static const struct rpc_call_ops nfs4_open_confirm_ops = { 756static const struct rpc_call_ops nfs4_open_confirm_ops = {
770 .rpc_call_prepare = nfs4_open_confirm_prepare,
771 .rpc_call_done = nfs4_open_confirm_done, 757 .rpc_call_done = nfs4_open_confirm_done,
772 .rpc_release = nfs4_open_confirm_release, 758 .rpc_release = nfs4_open_confirm_release,
773}; 759};
@@ -779,8 +765,15 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
779{ 765{
780 struct nfs_server *server = NFS_SERVER(data->dir->d_inode); 766 struct nfs_server *server = NFS_SERVER(data->dir->d_inode);
781 struct rpc_task *task; 767 struct rpc_task *task;
768 struct rpc_message msg = {
769 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM],
770 .rpc_argp = &data->c_arg,
771 .rpc_resp = &data->c_res,
772 .rpc_cred = data->owner->so_cred,
773 };
782 struct rpc_task_setup task_setup_data = { 774 struct rpc_task_setup task_setup_data = {
783 .rpc_client = server->client, 775 .rpc_client = server->client,
776 .rpc_message = &msg,
784 .callback_ops = &nfs4_open_confirm_ops, 777 .callback_ops = &nfs4_open_confirm_ops,
785 .callback_data = data, 778 .callback_data = data,
786 .flags = RPC_TASK_ASYNC, 779 .flags = RPC_TASK_ASYNC,
@@ -790,6 +783,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
790 kref_get(&data->kref); 783 kref_get(&data->kref);
791 data->rpc_done = 0; 784 data->rpc_done = 0;
792 data->rpc_status = 0; 785 data->rpc_status = 0;
786 data->timestamp = jiffies;
793 task = rpc_run_task(&task_setup_data); 787 task = rpc_run_task(&task_setup_data);
794 if (IS_ERR(task)) 788 if (IS_ERR(task))
795 return PTR_ERR(task); 789 return PTR_ERR(task);
@@ -807,13 +801,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
807{ 801{
808 struct nfs4_opendata *data = calldata; 802 struct nfs4_opendata *data = calldata;
809 struct nfs4_state_owner *sp = data->owner; 803 struct nfs4_state_owner *sp = data->owner;
810 struct rpc_message msg = { 804
811 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN],
812 .rpc_argp = &data->o_arg,
813 .rpc_resp = &data->o_res,
814 .rpc_cred = sp->so_cred,
815 };
816
817 if (nfs_wait_on_sequence(data->o_arg.seqid, task) != 0) 805 if (nfs_wait_on_sequence(data->o_arg.seqid, task) != 0)
818 return; 806 return;
819 /* 807 /*
@@ -838,11 +826,11 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
838 data->o_arg.id = sp->so_owner_id.id; 826 data->o_arg.id = sp->so_owner_id.id;
839 data->o_arg.clientid = sp->so_client->cl_clientid; 827 data->o_arg.clientid = sp->so_client->cl_clientid;
840 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { 828 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) {
841 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; 829 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR];
842 nfs_copy_fh(&data->o_res.fh, data->o_arg.fh); 830 nfs_copy_fh(&data->o_res.fh, data->o_arg.fh);
843 } 831 }
844 data->timestamp = jiffies; 832 data->timestamp = jiffies;
845 rpc_call_setup(task, &msg, 0); 833 rpc_call_start(task);
846 return; 834 return;
847out_no_action: 835out_no_action:
848 task->tk_action = NULL; 836 task->tk_action = NULL;
@@ -914,8 +902,15 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
914 struct nfs_openargs *o_arg = &data->o_arg; 902 struct nfs_openargs *o_arg = &data->o_arg;
915 struct nfs_openres *o_res = &data->o_res; 903 struct nfs_openres *o_res = &data->o_res;
916 struct rpc_task *task; 904 struct rpc_task *task;
905 struct rpc_message msg = {
906 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN],
907 .rpc_argp = o_arg,
908 .rpc_resp = o_res,
909 .rpc_cred = data->owner->so_cred,
910 };
917 struct rpc_task_setup task_setup_data = { 911 struct rpc_task_setup task_setup_data = {
918 .rpc_client = server->client, 912 .rpc_client = server->client,
913 .rpc_message = &msg,
919 .callback_ops = &nfs4_open_ops, 914 .callback_ops = &nfs4_open_ops,
920 .callback_data = data, 915 .callback_data = data,
921 .flags = RPC_TASK_ASYNC, 916 .flags = RPC_TASK_ASYNC,
@@ -1256,12 +1251,6 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
1256{ 1251{
1257 struct nfs4_closedata *calldata = data; 1252 struct nfs4_closedata *calldata = data;
1258 struct nfs4_state *state = calldata->state; 1253 struct nfs4_state *state = calldata->state;
1259 struct rpc_message msg = {
1260 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE],
1261 .rpc_argp = &calldata->arg,
1262 .rpc_resp = &calldata->res,
1263 .rpc_cred = state->owner->so_cred,
1264 };
1265 int clear_rd, clear_wr, clear_rdwr; 1254 int clear_rd, clear_wr, clear_rdwr;
1266 1255
1267 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) 1256 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0)
@@ -1288,14 +1277,14 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
1288 } 1277 }
1289 nfs_fattr_init(calldata->res.fattr); 1278 nfs_fattr_init(calldata->res.fattr);
1290 if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) { 1279 if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) {
1291 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; 1280 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
1292 calldata->arg.open_flags = FMODE_READ; 1281 calldata->arg.open_flags = FMODE_READ;
1293 } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) { 1282 } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) {
1294 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; 1283 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
1295 calldata->arg.open_flags = FMODE_WRITE; 1284 calldata->arg.open_flags = FMODE_WRITE;
1296 } 1285 }
1297 calldata->timestamp = jiffies; 1286 calldata->timestamp = jiffies;
1298 rpc_call_setup(task, &msg, 0); 1287 rpc_call_start(task);
1299} 1288}
1300 1289
1301static const struct rpc_call_ops nfs4_close_ops = { 1290static const struct rpc_call_ops nfs4_close_ops = {
@@ -1321,8 +1310,13 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
1321 struct nfs4_closedata *calldata; 1310 struct nfs4_closedata *calldata;
1322 struct nfs4_state_owner *sp = state->owner; 1311 struct nfs4_state_owner *sp = state->owner;
1323 struct rpc_task *task; 1312 struct rpc_task *task;
1313 struct rpc_message msg = {
1314 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE],
1315 .rpc_cred = state->owner->so_cred,
1316 };
1324 struct rpc_task_setup task_setup_data = { 1317 struct rpc_task_setup task_setup_data = {
1325 .rpc_client = server->client, 1318 .rpc_client = server->client,
1319 .rpc_message = &msg,
1326 .callback_ops = &nfs4_close_ops, 1320 .callback_ops = &nfs4_close_ops,
1327 .flags = RPC_TASK_ASYNC, 1321 .flags = RPC_TASK_ASYNC,
1328 }; 1322 };
@@ -1345,6 +1339,8 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
1345 calldata->path.mnt = mntget(path->mnt); 1339 calldata->path.mnt = mntget(path->mnt);
1346 calldata->path.dentry = dget(path->dentry); 1340 calldata->path.dentry = dget(path->dentry);
1347 1341
1342 msg.rpc_argp = &calldata->arg,
1343 msg.rpc_resp = &calldata->res,
1348 task_setup_data.callback_data = calldata; 1344 task_setup_data.callback_data = calldata;
1349 task = rpc_run_task(&task_setup_data); 1345 task = rpc_run_task(&task_setup_data);
1350 if (IS_ERR(task)) 1346 if (IS_ERR(task))
@@ -2966,25 +2962,11 @@ struct nfs4_delegreturndata {
2966 struct nfs4_delegreturnres res; 2962 struct nfs4_delegreturnres res;
2967 struct nfs_fh fh; 2963 struct nfs_fh fh;
2968 nfs4_stateid stateid; 2964 nfs4_stateid stateid;
2969 struct rpc_cred *cred;
2970 unsigned long timestamp; 2965 unsigned long timestamp;
2971 struct nfs_fattr fattr; 2966 struct nfs_fattr fattr;
2972 int rpc_status; 2967 int rpc_status;
2973}; 2968};
2974 2969
2975static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata)
2976{
2977 struct nfs4_delegreturndata *data = calldata;
2978 struct rpc_message msg = {
2979 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN],
2980 .rpc_argp = &data->args,
2981 .rpc_resp = &data->res,
2982 .rpc_cred = data->cred,
2983 };
2984 nfs_fattr_init(data->res.fattr);
2985 rpc_call_setup(task, &msg, 0);
2986}
2987
2988static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) 2970static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
2989{ 2971{
2990 struct nfs4_delegreturndata *data = calldata; 2972 struct nfs4_delegreturndata *data = calldata;
@@ -2995,14 +2977,10 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
2995 2977
2996static void nfs4_delegreturn_release(void *calldata) 2978static void nfs4_delegreturn_release(void *calldata)
2997{ 2979{
2998 struct nfs4_delegreturndata *data = calldata;
2999
3000 put_rpccred(data->cred);
3001 kfree(calldata); 2980 kfree(calldata);
3002} 2981}
3003 2982
3004static const struct rpc_call_ops nfs4_delegreturn_ops = { 2983static const struct rpc_call_ops nfs4_delegreturn_ops = {
3005 .rpc_call_prepare = nfs4_delegreturn_prepare,
3006 .rpc_call_done = nfs4_delegreturn_done, 2984 .rpc_call_done = nfs4_delegreturn_done,
3007 .rpc_release = nfs4_delegreturn_release, 2985 .rpc_release = nfs4_delegreturn_release,
3008}; 2986};
@@ -3012,8 +2990,13 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
3012 struct nfs4_delegreturndata *data; 2990 struct nfs4_delegreturndata *data;
3013 struct nfs_server *server = NFS_SERVER(inode); 2991 struct nfs_server *server = NFS_SERVER(inode);
3014 struct rpc_task *task; 2992 struct rpc_task *task;
2993 struct rpc_message msg = {
2994 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN],
2995 .rpc_cred = cred,
2996 };
3015 struct rpc_task_setup task_setup_data = { 2997 struct rpc_task_setup task_setup_data = {
3016 .rpc_client = server->client, 2998 .rpc_client = server->client,
2999 .rpc_message = &msg,
3017 .callback_ops = &nfs4_delegreturn_ops, 3000 .callback_ops = &nfs4_delegreturn_ops,
3018 .flags = RPC_TASK_ASYNC, 3001 .flags = RPC_TASK_ASYNC,
3019 }; 3002 };
@@ -3029,11 +3012,13 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
3029 memcpy(&data->stateid, stateid, sizeof(data->stateid)); 3012 memcpy(&data->stateid, stateid, sizeof(data->stateid));
3030 data->res.fattr = &data->fattr; 3013 data->res.fattr = &data->fattr;
3031 data->res.server = server; 3014 data->res.server = server;
3032 data->cred = get_rpccred(cred); 3015 nfs_fattr_init(data->res.fattr);
3033 data->timestamp = jiffies; 3016 data->timestamp = jiffies;
3034 data->rpc_status = 0; 3017 data->rpc_status = 0;
3035 3018
3036 task_setup_data.callback_data = data; 3019 task_setup_data.callback_data = data;
3020 msg.rpc_argp = &data->args,
3021 msg.rpc_resp = &data->res,
3037 task = rpc_run_task(&task_setup_data); 3022 task = rpc_run_task(&task_setup_data);
3038 if (IS_ERR(task)) 3023 if (IS_ERR(task))
3039 return PTR_ERR(task); 3024 return PTR_ERR(task);
@@ -3221,12 +3206,6 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
3221static void nfs4_locku_prepare(struct rpc_task *task, void *data) 3206static void nfs4_locku_prepare(struct rpc_task *task, void *data)
3222{ 3207{
3223 struct nfs4_unlockdata *calldata = data; 3208 struct nfs4_unlockdata *calldata = data;
3224 struct rpc_message msg = {
3225 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU],
3226 .rpc_argp = &calldata->arg,
3227 .rpc_resp = &calldata->res,
3228 .rpc_cred = calldata->lsp->ls_state->owner->so_cred,
3229 };
3230 3209
3231 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) 3210 if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0)
3232 return; 3211 return;
@@ -3236,7 +3215,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)
3236 return; 3215 return;
3237 } 3216 }
3238 calldata->timestamp = jiffies; 3217 calldata->timestamp = jiffies;
3239 rpc_call_setup(task, &msg, 0); 3218 rpc_call_start(task);
3240} 3219}
3241 3220
3242static const struct rpc_call_ops nfs4_locku_ops = { 3221static const struct rpc_call_ops nfs4_locku_ops = {
@@ -3251,8 +3230,13 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3251 struct nfs_seqid *seqid) 3230 struct nfs_seqid *seqid)
3252{ 3231{
3253 struct nfs4_unlockdata *data; 3232 struct nfs4_unlockdata *data;
3233 struct rpc_message msg = {
3234 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU],
3235 .rpc_cred = ctx->cred,
3236 };
3254 struct rpc_task_setup task_setup_data = { 3237 struct rpc_task_setup task_setup_data = {
3255 .rpc_client = NFS_CLIENT(lsp->ls_state->inode), 3238 .rpc_client = NFS_CLIENT(lsp->ls_state->inode),
3239 .rpc_message = &msg,
3256 .callback_ops = &nfs4_locku_ops, 3240 .callback_ops = &nfs4_locku_ops,
3257 .flags = RPC_TASK_ASYNC, 3241 .flags = RPC_TASK_ASYNC,
3258 }; 3242 };
@@ -3268,6 +3252,8 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3268 return ERR_PTR(-ENOMEM); 3252 return ERR_PTR(-ENOMEM);
3269 } 3253 }
3270 3254
3255 msg.rpc_argp = &data->arg,
3256 msg.rpc_resp = &data->res,
3271 task_setup_data.callback_data = data; 3257 task_setup_data.callback_data = data;
3272 return rpc_run_task(&task_setup_data); 3258 return rpc_run_task(&task_setup_data);
3273} 3259}
@@ -3353,13 +3339,6 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
3353{ 3339{
3354 struct nfs4_lockdata *data = calldata; 3340 struct nfs4_lockdata *data = calldata;
3355 struct nfs4_state *state = data->lsp->ls_state; 3341 struct nfs4_state *state = data->lsp->ls_state;
3356 struct nfs4_state_owner *sp = state->owner;
3357 struct rpc_message msg = {
3358 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK],
3359 .rpc_argp = &data->arg,
3360 .rpc_resp = &data->res,
3361 .rpc_cred = sp->so_cred,
3362 };
3363 3342
3364 dprintk("%s: begin!\n", __FUNCTION__); 3343 dprintk("%s: begin!\n", __FUNCTION__);
3365 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) 3344 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0)
@@ -3373,7 +3352,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
3373 } else 3352 } else
3374 data->arg.new_lock_owner = 0; 3353 data->arg.new_lock_owner = 0;
3375 data->timestamp = jiffies; 3354 data->timestamp = jiffies;
3376 rpc_call_setup(task, &msg, 0); 3355 rpc_call_start(task);
3377 dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); 3356 dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status);
3378} 3357}
3379 3358
@@ -3435,8 +3414,13 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3435{ 3414{
3436 struct nfs4_lockdata *data; 3415 struct nfs4_lockdata *data;
3437 struct rpc_task *task; 3416 struct rpc_task *task;
3417 struct rpc_message msg = {
3418 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK],
3419 .rpc_cred = state->owner->so_cred,
3420 };
3438 struct rpc_task_setup task_setup_data = { 3421 struct rpc_task_setup task_setup_data = {
3439 .rpc_client = NFS_CLIENT(state->inode), 3422 .rpc_client = NFS_CLIENT(state->inode),
3423 .rpc_message = &msg,
3440 .callback_ops = &nfs4_lock_ops, 3424 .callback_ops = &nfs4_lock_ops,
3441 .flags = RPC_TASK_ASYNC, 3425 .flags = RPC_TASK_ASYNC,
3442 }; 3426 };
@@ -3451,6 +3435,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3451 data->arg.block = 1; 3435 data->arg.block = 1;
3452 if (reclaim != 0) 3436 if (reclaim != 0)
3453 data->arg.reclaim = 1; 3437 data->arg.reclaim = 1;
3438 msg.rpc_argp = &data->arg,
3439 msg.rpc_resp = &data->res,
3454 task_setup_data.callback_data = data; 3440 task_setup_data.callback_data = data;
3455 task = rpc_run_task(&task_setup_data); 3441 task = rpc_run_task(&task_setup_data);
3456 if (IS_ERR(task)) 3442 if (IS_ERR(task))