Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3114ea7a authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Return the delegation if the server returns NFS4ERR_OPENMODE



If a setattr() fails because of an NFS4ERR_OPENMODE error, it is
probably due to us holding a read delegation. Ensure that the
recovery routines return that delegation in this case.

Reported-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org
parent cf470c3e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -182,6 +182,7 @@ struct nfs4_exception {
	long timeout;
	long timeout;
	int retry;
	int retry;
	struct nfs4_state *state;
	struct nfs4_state *state;
	struct inode *inode;
};
};


struct nfs4_state_recovery_ops {
struct nfs4_state_recovery_ops {
+12 −1
Original line number Original line Diff line number Diff line
@@ -262,18 +262,28 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
{
{
	struct nfs_client *clp = server->nfs_client;
	struct nfs_client *clp = server->nfs_client;
	struct nfs4_state *state = exception->state;
	struct nfs4_state *state = exception->state;
	struct inode *inode = exception->inode;
	int ret = errorcode;
	int ret = errorcode;


	exception->retry = 0;
	exception->retry = 0;
	switch(errorcode) {
	switch(errorcode) {
		case 0:
		case 0:
			return 0;
			return 0;
		case -NFS4ERR_OPENMODE:
			if (nfs_have_delegation(inode, FMODE_READ)) {
				nfs_inode_return_delegation(inode);
				exception->retry = 1;
				return 0;
			}
			if (state == NULL)
				break;
			nfs4_schedule_stateid_recovery(server, state);
			goto wait_on_recovery;
		case -NFS4ERR_DELEG_REVOKED:
		case -NFS4ERR_DELEG_REVOKED:
		case -NFS4ERR_ADMIN_REVOKED:
		case -NFS4ERR_ADMIN_REVOKED:
		case -NFS4ERR_BAD_STATEID:
		case -NFS4ERR_BAD_STATEID:
			if (state != NULL)
			if (state != NULL)
				nfs_remove_bad_delegation(state->inode);
				nfs_remove_bad_delegation(state->inode);
		case -NFS4ERR_OPENMODE:
			if (state == NULL)
			if (state == NULL)
				break;
				break;
			nfs4_schedule_stateid_recovery(server, state);
			nfs4_schedule_stateid_recovery(server, state);
@@ -1939,6 +1949,7 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
	struct nfs_server *server = NFS_SERVER(inode);
	struct nfs_server *server = NFS_SERVER(inode);
	struct nfs4_exception exception = {
	struct nfs4_exception exception = {
		.state = state,
		.state = state,
		.inode = inode,
	};
	};
	int err;
	int err;
	do {
	do {