Skip to content

Commit

Permalink
NFS: Cancel all existing RPC tasks when shutdown
Browse files Browse the repository at this point in the history
Walk existing RPC tasks and cancel them with -EIO when the client is
shutdown.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Benjamin Coddington authored and Trond Myklebust committed Jun 19, 2023
1 parent d9615d1 commit 7d3e26a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions fs/nfs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)
}
}

static bool shutdown_match_client(const struct rpc_task *task, const void *data)
{
return true;
}

static void shutdown_client(struct rpc_clnt *clnt)
{
clnt->cl_shutdown = 1;
rpc_cancel_tasks(clnt, -EIO, shutdown_match_client, NULL);
}

static ssize_t
shutdown_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
Expand Down Expand Up @@ -247,14 +258,14 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
goto out;

server->flags |= NFS_MOUNT_SHUTDOWN;
server->client->cl_shutdown = 1;
server->nfs_client->cl_rpcclient->cl_shutdown = 1;
shutdown_client(server->client);
shutdown_client(server->nfs_client->cl_rpcclient);

if (!IS_ERR(server->client_acl))
server->client_acl->cl_shutdown = 1;
shutdown_client(server->client_acl);

if (server->nlm_host)
server->nlm_host->h_rpcclnt->cl_shutdown = 1;
shutdown_client(server->nlm_host->h_rpcclnt);
out:
return count;
}
Expand Down

0 comments on commit 7d3e26a

Please sign in to comment.