Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4863836iog; Wed, 22 Jun 2022 07:16:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1tLSaC4JooYVFE8oFfvvKx04HyULygWEunZbCY3gnrJgXmxQ7V6WX3+iA4dvA58Uf5sUR X-Received: by 2002:a17:907:d90:b0:711:d151:51aa with SMTP id go16-20020a1709070d9000b00711d15151aamr3543730ejc.452.1655907407018; Wed, 22 Jun 2022 07:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655907407; cv=none; d=google.com; s=arc-20160816; b=oIe6+BvqPlp+W9UGBQc0ndK7B7zr5GgJKJ21wEh58MOFgdjDA9qsIzaxL1nOtFU2f0 /yq49IC5A3j8BufXg0xsjcsGD56i3YsM5P2/BHe+vqRgeVy9Daw5+y5qDpNbnoEQpk4Q VK3M1Oe8KDq9IelT1AQyKTpyw73824vjgVbza+TMw79T6hKUZewrOdR2qBbWXtj9jKqO k/k2o9chKT+PrOAGFevmgfpO1ax9ScyjL5gJgww+IGzVhCl6pgjYVSXkKISVpFYNmrPQ PjonTnUoCepln2JfhXJF+SG7+JbSqT3almMRSiquhbINGxoIFKqN3AwvZSCRPQtDBW2s bHlQ== 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=kX4fL8cyVgO87PntFxEBlOlLJkTYodaRFOB6zJ5LbCo=; b=gKAo2BegdTggukB8l5yPwydSfcEUTH4PUfgbRLT4YRg8C+9vKNSOdsZnGFsPH2i/mZ /GzPdloiaNuPY3YdCXdYZ6vx8Nb4htRzyLtqwuvCTRNT///C4BLH7Id8DPW9VaUYu7LE Fl9wGSAWW00U/5FXGzfBIjWlUGDytEtBz28MHF4dqE+G983onHUbawQBlgCvZe5Al6lM yrS5T1yJpim8OpFWts/NPj5IIy7fHv5YlDPoSoyhSQiTJTsX6neH8/erd5cuntbIui14 dhsXqsi5kNGPKSgt6ZrGtuieVJEYjOSVlonxAkdUrwzA7bnoiEN5CIK5LID/TO8M2G8/ 4O7Q== 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 l22-20020a170906795600b006ff2e46e8cdsi3953853ejo.980.2022.06.22.07.16.20; Wed, 22 Jun 2022 07:16:47 -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 S1358092AbiFVOQE (ORCPT + 99 others); Wed, 22 Jun 2022 10:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358102AbiFVOPq (ORCPT ); Wed, 22 Jun 2022 10:15:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0621B24; Wed, 22 Jun 2022 07:15:06 -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 8B0D961BDD; Wed, 22 Jun 2022 14:15:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EF6BC34114; Wed, 22 Jun 2022 14:15:05 +0000 (UTC) Subject: [PATCH RFC 21/30] NFSD: Refactor __nfsd_file_close_inode() From: Chuck Lever To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: david@fromorbit.com, tgraf@suug.ch, jlayton@redhat.com Date: Wed, 22 Jun 2022 10:15:04 -0400 Message-ID: <165590730448.75778.4596658492674636131.stgit@manet.1015granger.net> In-Reply-To: <165590626293.75778.9843437418112335153.stgit@manet.1015granger.net> References: <165590626293.75778.9843437418112335153.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 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 The code that computes the hashval is the same in both callers. To prevent them from going stale, reframe the documenting comments to remove descriptions of the underlying hash table structure, which is about to be replaced. Signed-off-by: Chuck Lever --- fs/nfsd/filecache.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 16679a80f20e..0387b2028a9b 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -568,10 +568,15 @@ static struct shrinker nfsd_file_shrinker = { .seeks = 1, }; +/* + * Find all cache items that match the inode and move them to @dispose. + * This process is atomic wrt nfsd_file_insert(). + */ static void -__nfsd_file_close_inode(struct inode *inode, unsigned int hashval, - struct list_head *dispose) +__nfsd_file_close_inode(struct inode *inode, struct list_head *dispose) { + unsigned int hashval = (unsigned int)hash_long(inode->i_ino, + NFSD_FILE_HASH_BITS); struct nfsd_file *nf; struct hlist_node *tmp; @@ -587,19 +592,14 @@ __nfsd_file_close_inode(struct inode *inode, unsigned int hashval, * nfsd_file_close_inode_sync - attempt to forcibly close a nfsd_file * @inode: inode of the file to attempt to remove * - * Walk the whole hash bucket, looking for any files that correspond to "inode". - * If any do, then unhash them and put the hashtable reference to them and - * destroy any that had their last reference put. Also ensure that any of the - * fputs also have their final __fput done as well. + * Unhash and put, then flush and fput all cache items associated with @inode. */ void nfsd_file_close_inode_sync(struct inode *inode) { - unsigned int hashval = (unsigned int)hash_long(inode->i_ino, - NFSD_FILE_HASH_BITS); LIST_HEAD(dispose); - __nfsd_file_close_inode(inode, hashval, &dispose); + __nfsd_file_close_inode(inode, &dispose); trace_nfsd_file_close_inode_sync(inode, !list_empty(&dispose)); nfsd_file_dispose_list_sync(&dispose); } @@ -608,18 +608,14 @@ nfsd_file_close_inode_sync(struct inode *inode) * nfsd_file_close_inode - attempt a delayed close of a nfsd_file * @inode: inode of the file to attempt to remove * - * Walk the whole hash bucket, looking for any files that correspond to "inode". - * If any do, then unhash them and put the hashtable reference to them and - * destroy any that had their last reference put. + * Unhash and put all cache item associated with @inode. */ static void nfsd_file_close_inode(struct inode *inode) { - unsigned int hashval = (unsigned int)hash_long(inode->i_ino, - NFSD_FILE_HASH_BITS); LIST_HEAD(dispose); - __nfsd_file_close_inode(inode, hashval, &dispose); + __nfsd_file_close_inode(inode, &dispose); trace_nfsd_file_close_inode(inode, !list_empty(&dispose)); nfsd_file_dispose_list_delayed(&dispose); }