summaryrefslogtreecommitdiff
path: root/fs/smb/client/cached_dir.h
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.h
parentdde6667fa3c8f52ec4b8afd487749e47d032d833 (diff)
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.h')
-rw-r--r--fs/smb/client/cached_dir.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/smb/client/cached_dir.h b/fs/smb/client/cached_dir.h
index 46b5a2fdf15b..c98f02943311 100644
--- a/fs/smb/client/cached_dir.h
+++ b/fs/smb/client/cached_dir.h
@@ -27,6 +27,9 @@ struct cached_dirents {
struct mutex de_mutex;
loff_t pos; /* Expected ctx->pos */
struct list_head entries;
+ /* accounting for cached entries in this directory */
+ unsigned long entries_count;
+ unsigned long bytes_used;
};
struct cached_fid {
@@ -62,8 +65,14 @@ struct cached_fids {
struct list_head dying;
struct work_struct invalidation_work;
struct delayed_work laundromat_work;
+ /* aggregate accounting for all cached dirents under this tcon */
+ atomic_long_t total_dirents_entries;
+ atomic64_t total_dirents_bytes;
};
+/* Module-wide directory cache accounting (defined in cifsfs.c) */
+extern atomic64_t cifs_dircache_bytes_used; /* bytes across all mounts */
+
extern struct cached_fids *init_cached_dirs(void);
extern void free_cached_dirs(struct cached_fids *cfids);
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,