Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2337343rwi; Fri, 28 Oct 2022 06:03:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fpyhA16MhLNATcIQFCXMT8tc8KdSPvYjmqvOONX+EoFEujcKozz9JxWxw5e/nan/c6kul X-Received: by 2002:a63:5f03:0:b0:460:b08a:8c00 with SMTP id t3-20020a635f03000000b00460b08a8c00mr45780260pgb.142.1666962225499; Fri, 28 Oct 2022 06:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666962225; cv=none; d=google.com; s=arc-20160816; b=yje2TdJPDNKJYx7YN+Jic/dnoCEP8jvtdw3FA0cFjfrcPKAgNitEiuCMk3i+p+8L6o 6tBGOoEy/Z1zvQKakL8ArMe7aC8Gx/AxEq/A17IBWjfvKUGTNma84DuJ1IlXvwEIcYez PQN9oxly0X8nGLCy6SOIk52xzZBbYvnujimdQXBjUmlV1KDmPFFjVvnmGnspb5U1E3wF OhdTlxbPZLtPTy/l+ta4BGy06HhZcOA5p6caAFw6hSWyDltnbfyXplbNn/IS4Ccr9KK/ zjaTGtXK17FNqIhw137WIjNUhNaYBmiY8efy0NblB5DJp5wBGh2+YicEGoN10EeBt5sl 0Ykg== 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=uzysCxKmfaFLtA/cxTT7vTp36K/YC6b8Z/qJ/+VYDFI=; b=JJ9Ew3YsHeNHahHjQ8AEcIhSpH2/RRRsrwO+ioTk1PBcoU+aYQPI/kSoyZ1pSSC3P4 3Ot+IyLA9Tmed1qgxxxG1Phwt9UUTQbeWPACY9zCOX6P8/abkK6BCpdNS3CHKCyRHdHv umXQET8V5XMWkDK1ulJCDNVxbb6bwwodhNHKbqt4NFIA08nyl1ZN3xO+DjB9y2pK3yEL KPpOZhRovOBnu/eDjawPOoh024c397SeUFGP5Oh7bkqu/0sbz7ltj9Fsun/n0xd2URvl nelPstDXx3ALwiAl1AKSXUSTk6jiJ5//ZWTZH7fONhTYYyjUmA9s/VxQdzE8A7rCLi9z EWkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="U40QhOY/"; 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 ip4-20020a17090b314400b00212e738ac60si4069039pjb.84.2022.10.28.06.03.20; Fri, 28 Oct 2022 06:03:45 -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="U40QhOY/"; 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 S230119AbiJ1NBx (ORCPT + 99 others); Fri, 28 Oct 2022 09:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiJ1NBv (ORCPT ); Fri, 28 Oct 2022 09:01:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B5F75FDD2 for ; Fri, 28 Oct 2022 06:01:49 -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 6992062844 for ; Fri, 28 Oct 2022 13:01:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D10AC433C1; Fri, 28 Oct 2022 13:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666962108; bh=gtLdtfk8X8Ts8aTOnA2TfG+8MKCo4F9YDnwuyjMTXMM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=U40QhOY/sBzAPL1L3gM+gn5SRlPzktq8CGg5lPT3yA1iQHT101Tr9OiucwO9yUCNK ofP9Uk2cmvp+LXflaqMsTnZORjwgZomh2ftGnx2q+zP1vJeyRBNXR9nYceQvYmslil mVCw9p5eIJaAkWuNHH2FQPIFXuc98AIvCvwtAj965u7vFofn6I4+PJedAb5DLGx0/X OiEempRBOcYt2TcO+/sti9pE5c7OuwjaME1HkD/ByyoeJZxb83xGx2gvmPsNIzHkyh H0BkrcOQoPmo4BuNh7GAZ/y0t9dqT1mfcvAW8g/uaAPpTKixCoDVmQYeEYQ1VNOZRz f/VWj4L5wozwQ== Message-ID: Subject: Re: [PATCH v2 3/3] nfsd: start non-blocking writeback after adding nfsd_file to the LRU From: Jeff Layton To: NeilBrown Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org Date: Fri, 28 Oct 2022 09:01:47 -0400 In-Reply-To: <166690952613.13915.11556395606559286695@noble.neil.brown.name> References: <20221027215213.138304-1-jlayton@kernel.org> , <20221027215213.138304-4-jlayton@kernel.org> <166690952613.13915.11556395606559286695@noble.neil.brown.name> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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, 2022-10-28 at 09:25 +1100, NeilBrown wrote: > On Fri, 28 Oct 2022, Jeff Layton wrote: > > When a GC entry gets added to the LRU, kick off SYNC_NONE writeback > > so that we can be ready to close it out when the time comes. > >=20 > > Signed-off-by: Jeff Layton >=20 > This looks sensible. > Reviewed-by: NeilBrown >=20 > Thanks, > NeilBrown >=20 >=20 > > --- > > fs/nfsd/filecache.c | 37 +++++++++++++++++++++++++++++++------ > > 1 file changed, 31 insertions(+), 6 deletions(-) > >=20 > > diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c > > index d2bbded805d4..491d3d9a1870 100644 > > --- a/fs/nfsd/filecache.c > > +++ b/fs/nfsd/filecache.c > > @@ -316,7 +316,7 @@ nfsd_file_alloc(struct nfsd_file_lookup_key *key, u= nsigned int may) > > } > > =20 > > static void > > -nfsd_file_flush(struct nfsd_file *nf) > > +nfsd_file_fsync(struct nfsd_file *nf) > > { > > struct file *file =3D nf->nf_file; > > =20 > > @@ -327,6 +327,22 @@ nfsd_file_flush(struct nfsd_file *nf) > > nfsd_reset_write_verifier(net_generic(nf->nf_net, nfsd_net_id)); > > } > > =20 > > +static void > > +nfsd_file_flush(struct nfsd_file *nf) > > +{ > > + struct file *file =3D nf->nf_file; > > + unsigned long nrpages; > > + > > + if (!file || !(file->f_mode & FMODE_WRITE)) > > + return; > > + > > + nrpages =3D file->f_mapping->nrpages; > > + if (nrpages) { > >=20 I may change this to: if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { I'm not sure here...Does nrpages count all of the pages in the mapping, or just the dirty ones? I'm wondering if we're overcounting in nfsd_file_pages_flushed? > > + this_cpu_add(nfsd_file_pages_flushed, nrpages); > > + filemap_flush(file->f_mapping); > > + } > > +} > > + > > static void > > nfsd_file_free(struct nfsd_file *nf) > > { > > @@ -337,7 +353,7 @@ nfsd_file_free(struct nfsd_file *nf) > > this_cpu_inc(nfsd_file_releases); > > this_cpu_add(nfsd_file_total_age, age); > > =20 > > - nfsd_file_flush(nf); > > + nfsd_file_fsync(nf); > > =20 > > if (nf->nf_mark) > > nfsd_file_mark_put(nf->nf_mark); > > @@ -500,12 +516,21 @@ nfsd_file_put(struct nfsd_file *nf) > > =20 > > if (test_bit(NFSD_FILE_GC, &nf->nf_flags)) { > > /* > > - * If this is the last reference (nf_ref =3D=3D 1), then transfer > > - * it to the LRU. If the add to the LRU fails, just put it as > > - * usual. > > + * If this is the last reference (nf_ref =3D=3D 1), then try > > + * to transfer it to the LRU. > > + */ > > + if (refcount_dec_not_one(&nf->nf_ref)) > > + return; > > + > > + /* > > + * If the add to the list succeeds, try to kick off SYNC_NONE > > + * writeback. If the add fails, then just fall through to > > + * decrement as usual. > > */ > > - if (refcount_dec_not_one(&nf->nf_ref) || nfsd_file_lru_add(nf)) > > + if (nfsd_file_lru_add(nf)) { > > + nfsd_file_flush(nf); > > return; > > + } > > } > > __nfsd_file_put(nf); > > } > > --=20 > > 2.37.3 > >=20 > >=20 --=20 Jeff Layton