Skip to content

Commit 2d3e998

Browse files
author
Trond Myklebust
committed
NFS: Shut down the nfs_client only after all the superblocks
The nfs_client manages state for all the superblocks in the "cl_superblocks" list, so it must not be shut down until all of them are gone. Fixes: 7d3e26a ("NFS: Cancel all existing RPC tasks when shutdown") Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent bf9be37 commit 2d3e998

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

fs/nfs/sysfs.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/rcupdate.h>
1515
#include <linux/lockd/lockd.h>
1616

17+
#include "internal.h"
1718
#include "nfs4_fs.h"
1819
#include "netns.h"
1920
#include "sysfs.h"
@@ -228,6 +229,25 @@ static void shutdown_client(struct rpc_clnt *clnt)
228229
rpc_cancel_tasks(clnt, -EIO, shutdown_match_client, NULL);
229230
}
230231

232+
/*
233+
* Shut down the nfs_client only once all the superblocks
234+
* have been shut down.
235+
*/
236+
static void shutdown_nfs_client(struct nfs_client *clp)
237+
{
238+
struct nfs_server *server;
239+
rcu_read_lock();
240+
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
241+
if (!(server->flags & NFS_MOUNT_SHUTDOWN)) {
242+
rcu_read_unlock();
243+
return;
244+
}
245+
}
246+
rcu_read_unlock();
247+
nfs_mark_client_ready(clp, -EIO);
248+
shutdown_client(clp->cl_rpcclient);
249+
}
250+
231251
static ssize_t
232252
shutdown_show(struct kobject *kobj, struct kobj_attribute *attr,
233253
char *buf)
@@ -259,14 +279,14 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
259279

260280
server->flags |= NFS_MOUNT_SHUTDOWN;
261281
shutdown_client(server->client);
262-
shutdown_client(server->nfs_client->cl_rpcclient);
263282

264283
if (!IS_ERR(server->client_acl))
265284
shutdown_client(server->client_acl);
266285

267286
if (server->nlm_host)
268287
shutdown_client(server->nlm_host->h_rpcclnt);
269288
out:
289+
shutdown_nfs_client(server->nfs_client);
270290
return count;
271291
}
272292

0 commit comments

Comments
 (0)