NFSv4: keep state manager thread active if swap is enabled

[ Upstream commit 4dc73c679114a2f408567e2e44770ed934190db2 ]

If we are swapping over NFSv4, we may not be able to allocate memory to
start the state-manager thread at the time when we need it.
So keep it always running when swap is enabled, and just signal it to
start.

This requires updating and testing the cl_swapper count on the root
rpc_clnt after following all ->cl_parent links.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Stable-dep-of: b46d80bd2d6e ("nfs4trace: fix state manager flag printing")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
NeilBrown
2022-03-07 10:41:44 +11:00
committed by Greg Kroah-Hartman
parent d601f78282
commit 6d434b4c49
6 changed files with 70 additions and 10 deletions

View File

@@ -10385,6 +10385,24 @@ static ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size)
return error + error2 + error3;
}
static void nfs4_enable_swap(struct inode *inode)
{
/* The state manager thread must always be running.
* It will notice the client is a swapper, and stay put.
*/
struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
nfs4_schedule_state_manager(clp);
}
static void nfs4_disable_swap(struct inode *inode)
{
/* The state manager thread will now exit once it is
* woken.
*/
wake_up_var(&NFS_SERVER(inode)->nfs_client->cl_state);
}
static const struct inode_operations nfs4_dir_inode_operations = {
.create = nfs_create,
.lookup = nfs_lookup,
@@ -10461,6 +10479,8 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.free_client = nfs4_free_client,
.create_server = nfs4_create_server,
.clone_server = nfs_clone_server,
.enable_swap = nfs4_enable_swap,
.disable_swap = nfs4_disable_swap,
};
static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {