aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/smb/client/cached_dir.c
diff options
context:
space:
mode:
authorBharath SM <bharathsm@microsoft.com>2025-09-29 15:57:46 -0500
committerSteve French <stfrench@microsoft.com>2025-10-01 21:49:53 -0500
commit63eb8bd6c81d84a23fdc18fffd604e3ea38bb96c (patch)
treea9c7c02f27c2e621b34286cea8122284ad27ed08 /fs/smb/client/cached_dir.c
parentsmb: client: add drop_dir_cache module parameter to invalidate cached dirents (diff)
downloadwireguard-linux-63eb8bd6c81d84a23fdc18fffd604e3ea38bb96c.tar.xz
wireguard-linux-63eb8bd6c81d84a23fdc18fffd604e3ea38bb96c.zip
smb: client: account smb directory cache usage and per-tcon totals
Add lightweight accounting for directory lease cache usage to aid debugging and limiting cache size in future. Track per-directory entry/byte counts and maintain per-tcon aggregates. Also expose the totals in /proc/fs/cifs/open_dirs. Signed-off-by: Bharath SM <bharathsm@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/client/cached_dir.c')
-rw-r--r--fs/smb/client/cached_dir.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index b69daeb1301b..b6f538a1d5af 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -697,6 +697,21 @@ static void free_cached_dir(struct cached_fid *cfid)
kfree(dirent);
}
+ /* adjust tcon-level counters and reset per-dir accounting */
+ if (cfid->cfids) {
+ if (cfid->dirents.entries_count)
+ atomic_long_sub((long)cfid->dirents.entries_count,
+ &cfid->cfids->total_dirents_entries);
+ if (cfid->dirents.bytes_used) {
+ atomic64_sub((long long)cfid->dirents.bytes_used,
+ &cfid->cfids->total_dirents_bytes);
+ atomic64_sub((long long)cfid->dirents.bytes_used,
+ &cifs_dircache_bytes_used);
+ }
+ }
+ cfid->dirents.entries_count = 0;
+ cfid->dirents.bytes_used = 0;
+
kfree(cfid->path);
cfid->path = NULL;
kfree(cfid);
@@ -792,6 +807,9 @@ struct cached_fids *init_cached_dirs(void)
queue_delayed_work(cfid_put_wq, &cfids->laundromat_work,
dir_cache_timeout * HZ);
+ atomic_long_set(&cfids->total_dirents_entries, 0);
+ atomic64_set(&cfids->total_dirents_bytes, 0);
+
return cfids;
}