aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-04-01 15:56:46 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-04-05 17:03:55 -0400
commitdb4f2e637f6d5dff6d07112e62605275be6050b3 (patch)
tree99a15cdc15ea1bdb7f7dbf7858e33cbf0163b3fe /fs/nfs/nfs4proc.c
parentbe76b5b68d15861d50ccd1d3e66dac3cb19963dd (diff)
NFSv4: Clean up delegation recall error handling
Unify the error handling in nfs4_open_delegation_recall and nfs4_lock_delegation_recall. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c79
1 files changed, 25 insertions, 54 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 57b5fb778f16..bdf3d07ce974 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1379,19 +1379,8 @@ static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *sta
1379 return ret; 1379 return ret;
1380} 1380}
1381 1381
1382int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid) 1382static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, int err)
1383{ 1383{
1384 struct nfs_server *server = NFS_SERVER(state->inode);
1385 struct nfs4_opendata *opendata;
1386 int err;
1387
1388 opendata = nfs4_open_recoverdata_alloc(ctx, state,
1389 NFS4_OPEN_CLAIM_DELEG_CUR_FH);
1390 if (IS_ERR(opendata))
1391 return PTR_ERR(opendata);
1392 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid);
1393 err = nfs4_open_recover(opendata, state);
1394 nfs4_opendata_put(opendata);
1395 switch (err) { 1384 switch (err) {
1396 default: 1385 default:
1397 printk(KERN_ERR "NFS: %s: unhandled error " 1386 printk(KERN_ERR "NFS: %s: unhandled error "
@@ -1418,20 +1407,40 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
1418 case -NFS4ERR_DELEG_REVOKED: 1407 case -NFS4ERR_DELEG_REVOKED:
1419 case -NFS4ERR_ADMIN_REVOKED: 1408 case -NFS4ERR_ADMIN_REVOKED:
1420 case -NFS4ERR_BAD_STATEID: 1409 case -NFS4ERR_BAD_STATEID:
1410 case -NFS4ERR_OPENMODE:
1421 nfs_inode_find_state_and_recover(state->inode, 1411 nfs_inode_find_state_and_recover(state->inode,
1422 stateid); 1412 stateid);
1423 nfs4_schedule_stateid_recovery(server, state); 1413 nfs4_schedule_stateid_recovery(server, state);
1424 case -ENOMEM:
1425 return 0; 1414 return 0;
1426 case -NFS4ERR_DELAY: 1415 case -NFS4ERR_DELAY:
1427 case -NFS4ERR_GRACE: 1416 case -NFS4ERR_GRACE:
1428 set_bit(NFS_DELEGATED_STATE, &state->flags); 1417 set_bit(NFS_DELEGATED_STATE, &state->flags);
1429 ssleep(1); 1418 ssleep(1);
1430 return -EAGAIN; 1419 return -EAGAIN;
1420 case -ENOMEM:
1421 case -NFS4ERR_DENIED:
1422 /* kill_proc(fl->fl_pid, SIGLOST, 1); */
1423 return 0;
1431 } 1424 }
1432 return err; 1425 return err;
1433} 1426}
1434 1427
1428int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid)
1429{
1430 struct nfs_server *server = NFS_SERVER(state->inode);
1431 struct nfs4_opendata *opendata;
1432 int err;
1433
1434 opendata = nfs4_open_recoverdata_alloc(ctx, state,
1435 NFS4_OPEN_CLAIM_DELEG_CUR_FH);
1436 if (IS_ERR(opendata))
1437 return PTR_ERR(opendata);
1438 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid);
1439 err = nfs4_open_recover(opendata, state);
1440 nfs4_opendata_put(opendata);
1441 return nfs4_handle_delegation_recall_error(server, state, stateid, err);
1442}
1443
1435static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) 1444static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
1436{ 1445{
1437 struct nfs4_opendata *data = calldata; 1446 struct nfs4_opendata *data = calldata;
@@ -5127,54 +5136,16 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
5127 return status; 5136 return status;
5128} 5137}
5129 5138
5130int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) 5139int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid)
5131{ 5140{
5132 struct nfs_server *server = NFS_SERVER(state->inode); 5141 struct nfs_server *server = NFS_SERVER(state->inode);
5133 int err; 5142 int err;
5134 5143
5135 err = nfs4_set_lock_state(state, fl); 5144 err = nfs4_set_lock_state(state, fl);
5136 if (err != 0) 5145 if (err != 0)
5137 goto out; 5146 return err;
5138 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); 5147 err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW);
5139 switch (err) { 5148 return nfs4_handle_delegation_recall_error(server, state, stateid, err);
5140 default:
5141 printk(KERN_ERR "NFS: %s: unhandled error "
5142 "%d.\n", __func__, err);
5143 case 0:
5144 case -ESTALE:
5145 goto out;
5146 case -NFS4ERR_STALE_CLIENTID:
5147 case -NFS4ERR_STALE_STATEID:
5148 set_bit(NFS_DELEGATED_STATE, &state->flags);
5149 case -NFS4ERR_EXPIRED:
5150 nfs4_schedule_lease_recovery(server->nfs_client);
5151 return -EAGAIN;
5152 case -NFS4ERR_BADSESSION:
5153 case -NFS4ERR_BADSLOT:
5154 case -NFS4ERR_BAD_HIGH_SLOT:
5155 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
5156 case -NFS4ERR_DEADSESSION:
5157 set_bit(NFS_DELEGATED_STATE, &state->flags);
5158 nfs4_schedule_session_recovery(server->nfs_client->cl_session, err);
5159 return -EAGAIN;
5160 case -NFS4ERR_DELEG_REVOKED:
5161 case -NFS4ERR_ADMIN_REVOKED:
5162 case -NFS4ERR_BAD_STATEID:
5163 case -NFS4ERR_OPENMODE:
5164 nfs4_schedule_stateid_recovery(server, state);
5165 return 0;
5166 case -NFS4ERR_DELAY:
5167 case -NFS4ERR_GRACE:
5168 set_bit(NFS_DELEGATED_STATE, &state->flags);
5169 ssleep(1);
5170 return -EAGAIN;
5171 case -ENOMEM:
5172 case -NFS4ERR_DENIED:
5173 /* kill_proc(fl->fl_pid, SIGLOST, 1); */
5174 return 0;
5175 }
5176out:
5177 return err;
5178} 5149}
5179 5150
5180struct nfs_release_lockowner_data { 5151struct nfs_release_lockowner_data {