]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:37 +0000 (11:07 +0100)
commitb7a2ca3f6945318b62fbe2cb69c75328612906b5
treeed586b2fee6316196e70dfd697c16ec6a9d706f3
parent38d767fb4a7766ec2058f97787e4c6e8d10343d6
smb: improve directory cache reuse for readdir operations

commit 72dd7961a4bb4fa1fc456169a61dd12e68e50645 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/cached_dir.h
fs/smb/client/readdir.c