Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp773268imw; Fri, 8 Jul 2022 11:25:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vBpBaO2Tf44xYWvTycrAm60u+vRmZu9tqRqztiWJZUCY4snS8VMz6MfhDOljNjFkahpwCc X-Received: by 2002:a17:90b:4b11:b0:1ef:d1e4:b302 with SMTP id lx17-20020a17090b4b1100b001efd1e4b302mr1302130pjb.73.1657304704041; Fri, 08 Jul 2022 11:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657304704; cv=none; d=google.com; s=arc-20160816; b=UpCwSQel3uGF8Odu95Bi4CWxObjntNN1EfVdaKGWMrhhHFQkjGajJQBcHLUDTrQGE+ 1rD7jiT9LsYNuyL73CsITpBj/eUfjUnGtGEdOzH7FWybV8qQmBmoeqBQwMBiP/II1x68 G9qXtsR37aeWzGpie/72rr0rBMXWbKWbaUsujZgTb8TnPPBh4T3Q/mgHustG2L/PwPUF 7iZwWSsUwp84hETGx4Gelv25RYaJgvm4yn+W41SXGxbnFIL9gRtcZcK10VTjn0N8Fe33 ugnWzXWe8a3yXo8z4/zrCnodKx4y7+x/0IQ4pRBu4VPxDitvTWTz3nuUptB7qG21cE3Y BZUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=P+wUMtiUsoReJZZasLGIlktzRxBVmAAunGGbVlA6NB0=; b=TTPBVHO9Ehm/YyOLax2eQ3siMhpzBpSkncgt2f/ziYbNC/2AROsCVqGFqH2q6azPMO ORyUFm7wOEjYnPlU7OJyb1WBvbfQKDhrJFD9LOcviAjHCg0Acqside59Km5r8UoacK3z RW1nDlglr+TqP59u+V1i2Nqd/RgH+eqWFQCdtQwnUQ5wQHDaZl9s08z2KAWVEgPkBAZb 3TqbypbfTEBcIcAEmAFFFIss2iODhaqfndBhvb9tT5uSekV8CV4B8kavEygwX/DyNTr2 PoMYrF6Znsv4t4VtAbYffnWLzUKjxZ+Rbvh2hfJSf9EjxQi0oWiVhvlXKQrkw1IJBbr7 +Mpg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a170902bf4c00b0016beedb0424si16418575pls.131.2022.07.08.11.24.52; Fri, 08 Jul 2022 11:25:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239419AbiGHSY0 (ORCPT + 99 others); Fri, 8 Jul 2022 14:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239427AbiGHSYX (ORCPT ); Fri, 8 Jul 2022 14:24:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B557E018; Fri, 8 Jul 2022 11:24:22 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3B42BB82921; Fri, 8 Jul 2022 18:24:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1DB1C341C0; Fri, 8 Jul 2022 18:24:19 +0000 (UTC) Subject: [PATCH v3 06/32] NFSD: Add nfsd_file_lru_dispose_list() helper From: Chuck Lever To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: david@fromorbit.com, jlayton@redhat.com, tgraf@suug.ch Date: Fri, 08 Jul 2022 14:24:18 -0400 Message-ID: <165730465867.28142.16841721582689848253.stgit@klimt.1015granger.net> In-Reply-To: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> References: <165730437087.28142.6731645688073512500.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Refactor the invariant part of nfsd_file_lru_walk_list() into a separate helper function. Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index da48c51a2bf0..b278030e0a12 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -457,11 +457,31 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru, return LRU_SKIP; } +/* + * Unhash items on @dispose immediately, then queue them on the + * disposal workqueue to finish releasing them in the background. + * + * cel: Note that between the time list_lru_shrink_walk runs and + * now, these items are in the hash table but marked unhashed. + * Why release these outside of lru_cb ? There's no lock ordering + * problem since lru_cb currently takes no lock. + */ +static void nfsd_file_gc_dispose_list(struct list_head *dispose) +{ + struct nfsd_file *nf; + + list_for_each_entry(nf, dispose, nf_lru) { + spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); + nfsd_file_do_unhash(nf); + spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); + } + nfsd_file_dispose_list_delayed(dispose); +} + static unsigned long nfsd_file_lru_walk_list(struct shrink_control *sc) { LIST_HEAD(head); - struct nfsd_file *nf; unsigned long ret; if (sc) @@ -471,12 +491,7 @@ nfsd_file_lru_walk_list(struct shrink_control *sc) ret = list_lru_walk(&nfsd_file_lru, nfsd_file_lru_cb, &head, LONG_MAX); - list_for_each_entry(nf, &head, nf_lru) { - spin_lock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); - nfsd_file_do_unhash(nf); - spin_unlock(&nfsd_file_hashtbl[nf->nf_hashval].nfb_lock); - } - nfsd_file_dispose_list_delayed(&head); + nfsd_file_gc_dispose_list(&head); return ret; }