Skip to content

Commit 5cef338

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
NFSv2/v3: Fix a memory leak when using -onolock
Neil Brown said: > Hi Trond, > > We found that a machine which made moderately heavy use of > 'automount' was leaking some nfs data structures - particularly the > 4K allocated by rpc_alloc_iostats. > It turns out that this only happens with filesystems with -onolock > set. > The problem is that if NFS_MOUNT_NONLM is set, nfs_start_lockd doesn't > set server->destroy, so when the filesystem is unmounted, the > ->client_acl is not shutdown, and so several resources are still > held. Multiple mount/umount cycles will slowly eat away memory > several pages at a time. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Acked-by: NeilBrown <neilb@suse.de>
1 parent 4584f52 commit 5cef338

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎fs/nfs/client.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ static int nfs_create_rpc_client(struct nfs_client *clp, int proto,
410410
*/
411411
static void nfs_destroy_server(struct nfs_server *server)
412412
{
413-
if (!IS_ERR(server->client_acl))
414-
rpc_shutdown_client(server->client_acl);
415-
416413
if (!(server->flags & NFS_MOUNT_NONLM))
417414
lockd_down(); /* release rpc.lockd */
418415
}
@@ -755,6 +752,9 @@ void nfs_free_server(struct nfs_server *server)
755752

756753
if (server->destroy != NULL)
757754
server->destroy(server);
755+
756+
if (!IS_ERR(server->client_acl))
757+
rpc_shutdown_client(server->client_acl);
758758
if (!IS_ERR(server->client))
759759
rpc_shutdown_client(server->client);
760760

0 commit comments

Comments
 (0)