Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1007141rwe; Fri, 14 Apr 2023 12:49:33 -0700 (PDT) X-Google-Smtp-Source: AKy350aXzdiF3NhvlMWM4G4Ifpb/b9zCyzAti7vHyX4mOGvg2vxhezEnTtC7Tcvm1UaCte05gRBs X-Received: by 2002:a17:90b:3810:b0:22b:b832:d32 with SMTP id mq16-20020a17090b381000b0022bb8320d32mr7073542pjb.9.1681501773083; Fri, 14 Apr 2023 12:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681501773; cv=none; d=google.com; s=arc-20160816; b=MDUznIawiioYtMlF06ouS6g9qNu4e5q8xlUzSPevvQuDyPyq8CJTI+pEM+C4vhO3mS GHevObgT6abuUkfLdUbdNLfUISTd/nhawfjOWHfdGYPlU1qr7uE0nvDkAo7V+cB25xe8 4WGdghYVLNSONAbPkwhebcVaXPJUux85Kd5SLqbg5Ftv+s/WUVX1m4XTh2Lrn2APBMen W7VKDdUhYOsNsBV69crtXjnds5mcOa1eaHkDGDkKAVSdL0nsmGX7WD3CfOPf1tWXxXXe o7p8W7MZOS+h1vtmhIEOpJfsMMGicujfAZ36krGdjOpYus2gQ0mXu6fCfcF9KTK2QRWs h+zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=EPFGqLtZAov+N9K18XdjqcyGIOYSg9U4hcsUD7m7+r8=; b=wGjpbn7Q2DeQo3Z4eaSihZDh9/vo2XlUhkLoVn5j+oOs9lc2harUUhlbq5gmeOoiJB Gv0/ai67hN73V9t19J3OJKFLShOfJUsAhL4KgKf+vvOOjkCDiIRwCOsQBZy91hPI7whg vcV2xG+sNzBV+sz3EkDjX2y6o0aYEeagl8bC2maeEIoQgokFbPd4YSnCTw923RpUNYZn v7R10a4tk3V31CUxQGu3dzoQBnOHNIPv3WNkMcQoQSvB7Cb6MoJmkptmERhdfFt4WgWJ 4RX6/Rcyhq6o0ZpxzEJbcpFHWcNhRQW0yii+gVHZkQo/1OBolpbkEJdMczw2E0lnPPz4 Moig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ltoWJYkc; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a170902b58800b001a68ea3dca9si3927261pls.80.2023.04.14.12.49.09; Fri, 14 Apr 2023 12:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ltoWJYkc; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbjDNTRT (ORCPT + 99 others); Fri, 14 Apr 2023 15:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjDNTRS (ORCPT ); Fri, 14 Apr 2023 15:17:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABE6A35A1 for ; Fri, 14 Apr 2023 12:17:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 48158649E4 for ; Fri, 14 Apr 2023 19:17:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60A7FC433EF; Fri, 14 Apr 2023 19:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681499836; bh=fVDkY0PIuvALMsbgLbLVD0M9q1gJ01NZorKdJ6KS5PM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ltoWJYkcyciTqJR+cyzB2OFBnaY3TZT6g6PPJI4XT9ghFGBmhamKWzlTPY9ltreXc wTdT6vXhjQMGyLrWgA64UZ9DyLRd9fRlZ/k6wgWKitWCK6Eo2ICPmo0/Oqnk7IxQEl xX7/5RM2Z8fTy16yt53SA9FgNEooa309M8FnuFbEjaashETK4vPzfR3K8YicJwsZtp 1+/+QYRSD1H/4J08KCHznK59dLIjZmCtCv1mPJY4xuPORk/bjkSmh521j4I/oge+bD O28SFY1fW1lNkwg5/uFG3bHbPPsTsVTpNMJIuISyc97PzTrL4E1TWC+FjIRiog+RWg bJGc6yqU/EPUQ== Message-ID: Subject: Re: [PATCH 3/6] nfsd: simplify the delayed disposal list code From: Jeff Layton To: Chuck Lever III Cc: Linux NFS Mailing List Date: Fri, 14 Apr 2023 15:17:15 -0400 In-Reply-To: <7810C14C-DC16-48DF-8A14-1A1E7B9A2CD8@oracle.com> References: <20230118173139.71846-1-jlayton@kernel.org> <20230118173139.71846-4-jlayton@kernel.org> <7810C14C-DC16-48DF-8A14-1A1E7B9A2CD8@oracle.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, 2023-04-14 at 18:20 +0000, Chuck Lever III wrote: > > On Jan 18, 2023, at 12:31 PM, Jeff Layton > > wrote: > >=20 > > When queueing a dispose list to the appropriate "freeme" lists, it > > pointlessly queues the objects one at a time to an intermediate > > list. > >=20 > > Remove a few helpers and just open code a list_move to make it more > > clear and efficient. Better document the resulting functions with > > kerneldoc comments. > >=20 > > Signed-off-by: Jeff Layton > > --- > > fs/nfsd/filecache.c | 63 +++++++++++++++---------------------------- > > -- > > 1 file changed, 21 insertions(+), 42 deletions(-) > >=20 > > diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c > > index 58ac93e7e680..a2bc4bd90b9a 100644 > > --- a/fs/nfsd/filecache.c > > +++ b/fs/nfsd/filecache.c > > @@ -513,49 +513,25 @@ nfsd_file_dispose_list(struct list_head > > *dispose) > > } > > } > >=20 > > -static void > > -nfsd_file_list_remove_disposal(struct list_head *dst, > > - struct nfsd_fcache_disposal *l) > > -{ > > - spin_lock(&l->lock); > > - list_splice_init(&l->freeme, dst); > > - spin_unlock(&l->lock); > > -} > > - > > -static void > > -nfsd_file_list_add_disposal(struct list_head *files, struct net > > *net) > > -{ > > - struct nfsd_net *nn =3D net_generic(net, nfsd_net_id); > > - struct nfsd_fcache_disposal *l =3D nn->fcache_disposal; > > - > > - spin_lock(&l->lock); > > - list_splice_tail_init(files, &l->freeme); > > - spin_unlock(&l->lock); > > - queue_work(nfsd_filecache_wq, &l->work); > > -} > > - > > -static void > > -nfsd_file_list_add_pernet(struct list_head *dst, struct list_head > > *src, > > - struct net *net) > > -{ > > - struct nfsd_file *nf, *tmp; > > - > > - list_for_each_entry_safe(nf, tmp, src, nf_lru) { > > - if (nf->nf_net =3D=3D net) > > - list_move_tail(&nf->nf_lru, dst); > > - } > > -} > > - > > +/** > > + * nfsd_file_dispose_list_delayed - move list of dead files to > > net's freeme list > > + * @dispose: list of nfsd_files to be disposed > > + * > > + * Transfers each file to the "freeme" list for its nfsd_net, to > > eventually > > + * be disposed of by the per-net garbage collector. > > + */ > > static void > > nfsd_file_dispose_list_delayed(struct list_head *dispose) > > { > > - LIST_HEAD(list); > > - struct nfsd_file *nf; > > - > > while(!list_empty(dispose)) { > > - nf =3D list_first_entry(dispose, struct nfsd_file, nf_lru); > > - nfsd_file_list_add_pernet(&list, dispose, nf->nf_net); > > - nfsd_file_list_add_disposal(&list, nf->nf_net); > > + struct nfsd_file *nf =3D list_first_entry(dispose, > > + struct nfsd_file, nf_lru); > > + struct nfsd_net *nn =3D net_generic(nf->nf_net, nfsd_net_id); > > + struct nfsd_fcache_disposal *l =3D nn->fcache_disposal; > > + > > + spin_lock(&l->lock); > > + list_move_tail(&nf->nf_lru, &l->freeme); > > + spin_unlock(&l->lock); > > } > > } > >=20 > > @@ -765,8 +741,8 @@ nfsd_file_close_inode_sync(struct inode *inode) > > =A0* nfsd_file_delayed_close - close unused nfsd_files > > =A0* @work: dummy > > =A0* > > - * Walk the LRU list and destroy any entries that have not been > > used since > > - * the last scan. > > + * Scrape the freeme list for this nfsd_net, and then dispose of > > them > > + * all. > > =A0*/ > > static void > > nfsd_file_delayed_close(struct work_struct *work) > > @@ -775,7 +751,10 @@ nfsd_file_delayed_close(struct work_struct > > *work) > > struct nfsd_fcache_disposal *l =3D container_of(work, > > struct nfsd_fcache_disposal, work); > >=20 > > - nfsd_file_list_remove_disposal(&head, l); > > + spin_lock(&l->lock); > > + list_splice_init(&l->freeme, &head); > > + spin_unlock(&l->lock); > > + > > nfsd_file_dispose_list(&head); > > } >=20 > Hey Jeff - >=20 > After applying this one, tmpfs exports appear to leak space, > even after all files and directories are deleted. Eventually > the filesystem is "full" -- modifying operations return ENOSPC > but removing files doesn't recover the used space. >=20 > Can you have a look at this? >=20 Actually, I may see the bug. Does this fix it? diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index c173d460b17d..f40d8f3b35a4 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -421,6 +421,7 @@ nfsd_file_dispose_list_delayed(struct list_head *dispose) spin_lock(&l->lock); list_move_tail(&nf->nf_lru, &l->freeme); spin_unlock(&l->lock); + queue_work(nfsd_filecache_wq, &l->work); } } =20