]> git.ipfire.org Git - thirdparty/linux.git/commit
smb: improve directory cache reuse for readdir operations
authorBharath SM <bharathsm.hsk@gmail.com>
Wed, 11 Jun 2025 11:29:02 +0000 (16:59 +0530)
committerSteve French <stfrench@microsoft.com>
Thu, 12 Jun 2025 18:38:21 +0000 (13:38 -0500)
commit72dd7961a4bb4fa1fc456169a61dd12e68e50645
tree798f77af2d54fafdc22fe8d15e7b071ed5be5314
parentb64af6bcd3b0f3fc633d6a70adb0991737abfef4
smb: improve directory cache reuse for readdir operations

Currently, cached directory contents were not reused across subsequent
'ls' operations because the cache validity check relied on comparing
the ctx pointer, which changes with each readdir invocation. As a
result, the cached dir entries was not marked as valid and the cache was
not utilized for subsequent 'ls' operations.

This change uses the file pointer, which remains consistent across all
readdir calls for a given directory instance, to associate and validate
the cache. As a result, cached directory contents can now be
correctly reused, improving performance for repeated directory listings.

Performance gains with local windows SMB server:

Without the patch and default actimeo=1:
 1000 directory enumeration operations on dir with 10k files took 135.0s

With this patch and actimeo=0:
 1000 directory enumeration operations on dir with 10k files took just 5.1s

Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cached_dir.h
fs/smb/client/readdir.c