From: Henrique Carvalho henrique.carvalho@suse.com
[ Upstream commit 5676398315b73f21d6a4e2d36606ce94e8afc79e ]
open_cached_dir_by_dentry() was missing an update of cfid->last_access_time to jiffies, similar to what open_cached_dir() has.
Add it to the function.
Signed-off-by: Henrique Carvalho henrique.carvalho@suse.com Reviewed-by: Enzo Matsumiya ematsumiya@suse.de Signed-off-by: Steve French stfrench@microsoft.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES - The change makes `open_cached_dir_by_dentry()` refresh `cfid->last_access_time` just like `open_cached_dir()` already does, so cached handles looked up by dentry stay marked as recently used (`fs/smb/client/cached_dir.c:430`, compare with `fs/smb/client/cached_dir.c:197`). Without this, directories accessed through this path age out after the default 30 s timeout (`fs/smb/client/cifsfs.c:120`) regardless of activity. - Eviction is driven by `cfids_laundromat_worker()`, which examines `last_access_time` to drop “stale” entries (`fs/smb/client/cached_dir.c:747-759`). Because lookups and revalidation frequently reach the cache via `open_cached_dir_by_dentry()` (`fs/smb/client/inode.c:2706` and `fs/smb/client/dir.c:732`), the missing update causes active directories to be torn down prematurely, forcing unnecessary reopen traffic and defeating the regression fix that introduced the field. - The bug was introduced when `last_access_time` was added (`3edc68de5629`, included in v6.17), so affected stable trees already carry the infrastructure this patch relies on. The fix itself is a single assignment under the existing spinlock, so the regression risk is negligible and no additional prerequisites are required.
fs/smb/client/cached_dir.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index b69daeb1301b3..cc857a030a778 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -423,6 +423,7 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon, cifs_dbg(FYI, "found a cached file handle by dentry\n"); kref_get(&cfid->refcount); *ret_cfid = cfid; + cfid->last_access_time = jiffies; spin_unlock(&cfids->cfid_list_lock); return 0; }