Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp33666pxb; Wed, 30 Mar 2022 22:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1IyBVCVX+14YB5H9OLGoJHOrM+5OcbUepRoSKXbBxm9jz36hxXtfN337iaMzeWvpO5aHb X-Received: by 2002:a17:90a:c246:b0:1c9:7d32:640f with SMTP id d6-20020a17090ac24600b001c97d32640fmr4115351pjx.182.1648703366797; Wed, 30 Mar 2022 22:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648703366; cv=none; d=google.com; s=arc-20160816; b=DsKnFEIA3p4owFbx0tbUrbPdBPZi9bboElDLK+11BHqE8ON4zeM/JIsnkNEEEd+GHX NODIaV9+oOh2gUZY213E3ipZ/ELFVxbZXwiUjjF6NzvR/pnlf8OAd7C6KewRei/h4YZ9 ZVvwZQxBE8OSyzGVob/A3FNFpSr53rCJzYgzUppXdKbo6HsSaVWw8KJ0KjDMO8m+XA26 qUY9H7bbONpIS/KzMlkXVh0E9y7e9qp1/qnofbqP3iRwnlc1R73fBtU82TFMVlQRD5J7 0f5JZTP5HL+1YdzLYAXctuWe39iNm2WeOsPUZea6bTEUNkD+TOJzsX3ti4k4xR1PSPUI XxpQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=1K9IY4WjXgYDY5PK29UefVCGw7WrPo9yMaXviXw6fsM=; b=LhgHJe8C+UpBgIA2Qb7KBSAuIcu/ZDznKTR1m6ywtaL/9yDNRnwC1LyYY0998g3GGZ eiFRh/iO6A3SW/3poQG0GgVuSOdmBqL0T41U9F9veERnYWbaJcTz/nt5OzzUoxzEj9pR gx17JyvoPJwu/tkZrlvi43jVjP2EAszLCiabWLODiFCHh2YIei3YUG4KWrCPhZ/vMZBB s3dAwBO4W2ndoLXLmqlSJ2oce2fFnipo0HWz4an/c5YyVJUuMe97kZiyNBDshbCmdwmr 2kGimxOFDpcPQpNGoNACqVisdks3zFCnVJbPZFgcJgrDVdolt68fMK1gwVgzx2PheILA RlSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cp1AElic; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v5-20020a655685000000b003816043eec9si21424754pgs.190.2022.03.30.22.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 22:09:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cp1AElic; spf=softfail (google.com: domain of transitioning linux-nfs-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50AA629527E; Wed, 30 Mar 2022 20:47:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbiCaDs7 (ORCPT + 99 others); Wed, 30 Mar 2022 23:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiCaDs6 (ORCPT ); Wed, 30 Mar 2022 23:48:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6D1C60 for ; Wed, 30 Mar 2022 20:42:44 -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 AA5C2B81EBF for ; Thu, 31 Mar 2022 03:36:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D25C1C340EE for ; Thu, 31 Mar 2022 03:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648697810; bh=2E1w0gMxAp1swUpkCMOhkLBA/iQpJu3ZHzi3KIm9H9Q=; h=From:To:Subject:Date:From; b=Cp1AElicMT9JJN+HhxPQy/2BbmU58DUgwzb/piW/HK20lDQCeCqijpfySqdCWyI+D Ku7P0tzKUAvdEru+sdoeujgr2HIInBKIYkZE5AlpsJpO4A9EJFGPZHFgT/nSqi9wAO hiDEIjti0bUFnrLZJ/zTmiY0GFH2LME9l6voQddicSc2GzRcUYseRAu+lbyRDUCnPb yR0X79ESIf8Trb+7/4NS7qPMwIFbsrM0AGZxSJTtoi2yVFvP+P1UTtYek7fglVRknJ Qv/wz5eHkGSHbxP3I01NEgpFNeIAFnNaMdQvIsuUiNYGk/wtuKo93xaq1mjRxDtUki 1LPjY5l4vxaag== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Replace readdir's use of xxhash() with hash_64() Date: Wed, 30 Mar 2022 23:30:23 -0400 Message-Id: <20220331033023.718688-1-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Trond Myklebust Both xxhash() and hash_64() appear to give similarly low collision rates with a standard linearly increasing readdir offset. They both give similarly higher collision rates when applied to ext4's offsets. So switch to using the standard hash_64(). Signed-off-by: Trond Myklebust --- fs/nfs/Kconfig | 4 ---- fs/nfs/dir.c | 9 +++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index 47a53b3362b6..14a72224b657 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig @@ -4,10 +4,6 @@ config NFS_FS depends on INET && FILE_LOCKING && MULTIUSER select LOCKD select SUNRPC - select CRYPTO - select CRYPTO_HASH - select XXHASH - select CRYPTO_XXHASH select NFS_ACL_SUPPORT if NFS_V3_ACL help Choose Y here if you want to access files residing on other diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 0365063b85a2..c6b263b5faf1 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include "delegation.h" #include "iostat.h" @@ -350,10 +350,7 @@ static int nfs_readdir_page_array_append(struct page *page, * of directory cookies. Content is addressed by the value of the * cookie index of the first readdir entry in a page. * - * The xxhash algorithm is chosen because it is fast, and is supposed - * to result in a decent flat distribution of hashes. - * - * We then select only the first 18 bits to avoid issues with excessive + * We select only the first 18 bits to avoid issues with excessive * memory use for the page cache XArray. 18 bits should allow the caching * of 262144 pages of sequences of readdir entries. Since each page holds * 127 readdir entries for a typical 64-bit system, that works out to a @@ -363,7 +360,7 @@ static pgoff_t nfs_readdir_page_cookie_hash(u64 cookie) { if (cookie == 0) return 0; - return xxhash(&cookie, sizeof(cookie), 0) & NFS_READDIR_COOKIE_MASK; + return hash_64(cookie, 18); } static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie, -- 2.35.1