Skip to content

Commit 7d3e26a

Browse files
bcodding-rhTrond Myklebust
authored andcommitted
NFS: Cancel all existing RPC tasks when shutdown
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>
1 parent d9615d1 commit 7d3e26a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

fs/nfs/sysfs.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)
217217
}
218218
}
219219

220+
static bool shutdown_match_client(const struct rpc_task *task, const void *data)
221+
{
222+
return true;
223+
}
224+
225+
static void shutdown_client(struct rpc_clnt *clnt)
226+
{
227+
clnt->cl_shutdown = 1;
228+
rpc_cancel_tasks(clnt, -EIO, shutdown_match_client, NULL);
229+
}
230+
220231
static ssize_t
221232
shutdown_show(struct kobject *kobj, struct kobj_attribute *attr,
222233
char *buf)
@@ -247,14 +258,14 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
247258
goto out;
248259

249260
server->flags |= NFS_MOUNT_SHUTDOWN;
250-
server->client->cl_shutdown = 1;
251-
server->nfs_client->cl_rpcclient->cl_shutdown = 1;
261+
shutdown_client(server->client);
262+
shutdown_client(server->nfs_client->cl_rpcclient);
252263

253264
if (!IS_ERR(server->client_acl))
254-
server->client_acl->cl_shutdown = 1;
265+
shutdown_client(server->client_acl);
255266

256267
if (server->nlm_host)
257-
server->nlm_host->h_rpcclnt->cl_shutdown = 1;
268+
shutdown_client(server->nlm_host->h_rpcclnt);
258269
out:
259270
return count;
260271
}

0 commit comments

Comments
 (0)