summaryrefslogtreecommitdiff
path: root/fs/smb/client/cached_dir.c
diff options
context:
space:
mode:
authorEnzo Matsumiya <ematsumiya@suse.de>2025-07-08 15:54:31 -0300
committerEnzo Matsumiya <ematsumiya@suse.de>2025-07-09 03:00:14 -0300
commita70b71978ca38fcd839cf708cae288c442c14141 (patch)
tree0b0c893fe653e634e3d69291a7a4336c5c0fc1ba /fs/smb/client/cached_dir.c
parente835f5ff89e9106fe8c8d1fe8ea3917cea67c016 (diff)
downloadlinux-plk.tar.gz
linux-plk.tar.bz2
linux-plk.zip
smb: client: properly invalidate and reuse cached direntsplk
By properly invalidating cache dir entries allows to determine when we must or not do a remote open of the dir, reducing the number of network calls while the cached dir is still valid. Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
Diffstat (limited to 'fs/smb/client/cached_dir.c')
-rw-r--r--fs/smb/client/cached_dir.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index d28855a1edc1..0ee6eb959f1b 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -134,6 +134,28 @@ struct cached_fid *lookup_cached_dir(struct cached_fids *cfids, const void *key,
return cfid;
}
+void invalidate_dirents(struct cached_fid *cfid)
+{
+ struct cached_dirents *cde;
+ struct cached_dirent *de, *q;
+
+ if (!cfid)
+ return;
+
+ cde = &cfid->dirents;
+ mutex_lock(&cde->de_mutex);
+ list_for_each_entry_safe(de, q, &cde->entries, entry) {
+ list_del(&de->entry);
+ kfree(de->name);
+ kfree(de);
+ }
+
+ cde->is_valid = false;
+ cde->is_failed = false;
+ cde->pos = 2;
+ mutex_unlock(&cde->de_mutex);
+}
+
/*
* Open the and cache a directory handle.
* If error then *cfid is not initialized.