NFSv4: Handle more errors when recovering open file and locking state
It is possible for servers to return NFS4ERR_BAD_STATEID when the state management code is recovering locks or is reclaiming state when returning a delegation. Ensure that we handle that case. While we're at it, add in handlers for NFS4ERR_STALE, NFS4ERR_ADMIN_REVOKED, NFS4ERR_OPENMODE, NFS4ERR_DENIED and NFS4ERR_STALE_STATEID, since the protocol appears to allow for them too. Also handle ENOMEM... Finally, rather than add new NFSv4.0-specific errors and error handling into the generic delegation code, move that open file and locking state error handling into the NFSv4 layer. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
d5122201a7
commit
965b5d6791
@ -804,16 +804,30 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
|
|||||||
err = _nfs4_open_delegation_recall(ctx, state, stateid);
|
err = _nfs4_open_delegation_recall(ctx, state, stateid);
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case 0:
|
case 0:
|
||||||
return err;
|
case -ENOENT:
|
||||||
|
case -ESTALE:
|
||||||
|
goto out;
|
||||||
case -NFS4ERR_STALE_CLIENTID:
|
case -NFS4ERR_STALE_CLIENTID:
|
||||||
case -NFS4ERR_STALE_STATEID:
|
case -NFS4ERR_STALE_STATEID:
|
||||||
case -NFS4ERR_EXPIRED:
|
case -NFS4ERR_EXPIRED:
|
||||||
/* Don't recall a delegation if it was lost */
|
/* Don't recall a delegation if it was lost */
|
||||||
nfs4_schedule_state_recovery(server->nfs_client);
|
nfs4_schedule_state_recovery(server->nfs_client);
|
||||||
return err;
|
goto out;
|
||||||
|
case -ERESTARTSYS:
|
||||||
|
/*
|
||||||
|
* The show must go on: exit, but mark the
|
||||||
|
* stateid as needing recovery.
|
||||||
|
*/
|
||||||
|
case -NFS4ERR_ADMIN_REVOKED:
|
||||||
|
case -NFS4ERR_BAD_STATEID:
|
||||||
|
nfs4_state_mark_reclaim_nograce(server->nfs_client, state);
|
||||||
|
case -ENOMEM:
|
||||||
|
err = 0;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
err = nfs4_handle_exception(server, err, &exception);
|
err = nfs4_handle_exception(server, err, &exception);
|
||||||
} while (exception.retry);
|
} while (exception.retry);
|
||||||
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3487,8 +3501,6 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
|
|||||||
ret = nfs4_wait_for_completion_rpc_task(task);
|
ret = nfs4_wait_for_completion_rpc_task(task);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = data->rpc_status;
|
ret = data->rpc_status;
|
||||||
if (ret == -NFS4ERR_DENIED)
|
|
||||||
ret = -EAGAIN;
|
|
||||||
} else
|
} else
|
||||||
data->cancelled = 1;
|
data->cancelled = 1;
|
||||||
rpc_put_task(task);
|
rpc_put_task(task);
|
||||||
@ -3576,9 +3588,11 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
err = _nfs4_proc_setlk(state, cmd, request);
|
||||||
|
if (err == -NFS4ERR_DENIED)
|
||||||
|
err = -EAGAIN;
|
||||||
err = nfs4_handle_exception(NFS_SERVER(state->inode),
|
err = nfs4_handle_exception(NFS_SERVER(state->inode),
|
||||||
_nfs4_proc_setlk(state, cmd, request),
|
err, &exception);
|
||||||
&exception);
|
|
||||||
} while (exception.retry);
|
} while (exception.retry);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -3635,11 +3649,29 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
|
|||||||
printk(KERN_ERR "%s: unhandled error %d.\n",
|
printk(KERN_ERR "%s: unhandled error %d.\n",
|
||||||
__func__, err);
|
__func__, err);
|
||||||
case 0:
|
case 0:
|
||||||
|
case -ESTALE:
|
||||||
goto out;
|
goto out;
|
||||||
case -NFS4ERR_EXPIRED:
|
case -NFS4ERR_EXPIRED:
|
||||||
case -NFS4ERR_STALE_CLIENTID:
|
case -NFS4ERR_STALE_CLIENTID:
|
||||||
|
case -NFS4ERR_STALE_STATEID:
|
||||||
nfs4_schedule_state_recovery(server->nfs_client);
|
nfs4_schedule_state_recovery(server->nfs_client);
|
||||||
goto out;
|
goto out;
|
||||||
|
case -ERESTARTSYS:
|
||||||
|
/*
|
||||||
|
* The show must go on: exit, but mark the
|
||||||
|
* stateid as needing recovery.
|
||||||
|
*/
|
||||||
|
case -NFS4ERR_ADMIN_REVOKED:
|
||||||
|
case -NFS4ERR_BAD_STATEID:
|
||||||
|
case -NFS4ERR_OPENMODE:
|
||||||
|
nfs4_state_mark_reclaim_nograce(server->nfs_client, state);
|
||||||
|
err = 0;
|
||||||
|
goto out;
|
||||||
|
case -ENOMEM:
|
||||||
|
case -NFS4ERR_DENIED:
|
||||||
|
/* kill_proc(fl->fl_pid, SIGLOST, 1); */
|
||||||
|
err = 0;
|
||||||
|
goto out;
|
||||||
case -NFS4ERR_DELAY:
|
case -NFS4ERR_DELAY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -854,25 +854,29 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
|
|||||||
if (nfs_file_open_context(fl->fl_file)->state != state)
|
if (nfs_file_open_context(fl->fl_file)->state != state)
|
||||||
continue;
|
continue;
|
||||||
status = ops->recover_lock(state, fl);
|
status = ops->recover_lock(state, fl);
|
||||||
if (status >= 0)
|
|
||||||
continue;
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case -ESTALE:
|
||||||
|
case -NFS4ERR_ADMIN_REVOKED:
|
||||||
|
case -NFS4ERR_STALE_STATEID:
|
||||||
|
case -NFS4ERR_BAD_STATEID:
|
||||||
|
case -NFS4ERR_EXPIRED:
|
||||||
|
case -NFS4ERR_NO_GRACE:
|
||||||
|
case -NFS4ERR_STALE_CLIENTID:
|
||||||
|
goto out;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
|
printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
|
||||||
__func__, status);
|
__func__, status);
|
||||||
case -NFS4ERR_EXPIRED:
|
case -ENOMEM:
|
||||||
case -NFS4ERR_NO_GRACE:
|
case -NFS4ERR_DENIED:
|
||||||
case -NFS4ERR_RECLAIM_BAD:
|
case -NFS4ERR_RECLAIM_BAD:
|
||||||
case -NFS4ERR_RECLAIM_CONFLICT:
|
case -NFS4ERR_RECLAIM_CONFLICT:
|
||||||
/* kill_proc(fl->fl_pid, SIGLOST, 1); */
|
/* kill_proc(fl->fl_pid, SIGLOST, 1); */
|
||||||
break;
|
status = 0;
|
||||||
case -NFS4ERR_STALE_CLIENTID:
|
|
||||||
goto out_err;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
up_write(&nfsi->rwsem);
|
out:
|
||||||
return 0;
|
|
||||||
out_err:
|
|
||||||
up_write(&nfsi->rwsem);
|
up_write(&nfsi->rwsem);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -918,6 +922,7 @@ restart:
|
|||||||
printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
|
printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
|
||||||
__func__, status);
|
__func__, status);
|
||||||
case -ENOENT:
|
case -ENOENT:
|
||||||
|
case -ENOMEM:
|
||||||
case -ESTALE:
|
case -ESTALE:
|
||||||
/*
|
/*
|
||||||
* Open state on this file cannot be recovered
|
* Open state on this file cannot be recovered
|
||||||
@ -928,6 +933,9 @@ restart:
|
|||||||
/* Mark the file as being 'closed' */
|
/* Mark the file as being 'closed' */
|
||||||
state->state = 0;
|
state->state = 0;
|
||||||
break;
|
break;
|
||||||
|
case -NFS4ERR_ADMIN_REVOKED:
|
||||||
|
case -NFS4ERR_STALE_STATEID:
|
||||||
|
case -NFS4ERR_BAD_STATEID:
|
||||||
case -NFS4ERR_RECLAIM_BAD:
|
case -NFS4ERR_RECLAIM_BAD:
|
||||||
case -NFS4ERR_RECLAIM_CONFLICT:
|
case -NFS4ERR_RECLAIM_CONFLICT:
|
||||||
nfs4_state_mark_reclaim_nograce(sp->so_client, state);
|
nfs4_state_mark_reclaim_nograce(sp->so_client, state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user