[PATCH 18/21] NFSv4/pnfs: Grow the deviceid cache hash table

Benjamin Coddington <ben.coddington-F/[email protected]>
Newsgroups gmane.linux.nfs
Message-ID <75f92269fa1b13ee6512f66b69ec9148010c764e.1786653063.git.bcodding@hammerspace.com>
The global deviceid cache has 32 buckets shared by every server and
layout type.  pNFS striping deployments put hundreds to ~1000
distinct deviceIDs in play per mount (mirrors x stripes), a load
factor of ~31: resolution and re-resolution bursts walk long chains.

Grow to 256 buckets (2KB fixed): load factor ~4 at 1000 devices.
The existing byte-folding hash distributes fine at any power-of-two
size (the multiplier is odd), so bucket count is the only lever.
Alternatives considered and set aside: per-client tables do not help
the headline single-mount striping case, and a resizing rhashtable
is unwarranted for a burst-only (never per-I/O) lookup path.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Benjamin Coddington <bcodding-F/[email protected]>
---
 fs/nfs/pnfs_dev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
index 0c39ae8325b3..e09f25a26004 100644
--- a/fs/nfs/pnfs_dev.c
+++ b/fs/nfs/pnfs_dev.c
@@ -40,8 +40,16 @@
 
 /*
  * Device ID RCU cache. A device ID is unique per server and layout type.
+ *
+ * 256 buckets keep chains short for pNFS striping deployments with
+ * hundreds to ~1000 distinct deviceIDs (load factor ~4 at 1000) at a
+ * fixed cost of 2KB.  The hash folds every deviceID byte through
+ * x = x * 37 + byte; 37 is odd, so the low-bit mask distributes
+ * deviceIDs differing in any single byte perfectly at any
+ * power-of-two table size -- bucket count, not the hash, is the
+ * scaling lever.
  */
-#define NFS4_DEVICE_ID_HASH_BITS	5
+#define NFS4_DEVICE_ID_HASH_BITS	8
 #define NFS4_DEVICE_ID_HASH_SIZE	(1 << NFS4_DEVICE_ID_HASH_BITS)
 #define NFS4_DEVICE_ID_HASH_MASK	(NFS4_DEVICE_ID_HASH_SIZE - 1)
 
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.