Skip to content

Commit 3edc68d

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: add new field to track the last access time of cfid
The handlecache code today tracks the time at which dir lease was acquired and the laundromat thread uses that to check for old entries to cleanup. However, if a directory is actively accessed, it should not be chosen to expire first. This change adds a new last_access_time field to cfid and uses that to decide expiry of the cfid. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2aaf178 commit 3edc68d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

fs/smb/client/cached_dir.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
195195
* from @cfids->entries. Caller will put last reference if the latter.
196196
*/
197197
if (cfid->has_lease && cfid->time) {
198+
cfid->last_access_time = jiffies;
198199
spin_unlock(&cfids->cfid_list_lock);
199200
*ret_cfid = cfid;
200201
kfree(utf16_path);
@@ -363,6 +364,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
363364
cfid->file_all_info_is_valid = true;
364365

365366
cfid->time = jiffies;
367+
cfid->last_access_time = jiffies;
366368
spin_unlock(&cfids->cfid_list_lock);
367369
/* At this point the directory handle is fully cached */
368370
rc = 0;
@@ -730,8 +732,8 @@ static void cfids_laundromat_worker(struct work_struct *work)
730732

731733
spin_lock(&cfids->cfid_list_lock);
732734
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
733-
if (cfid->time &&
734-
time_after(jiffies, cfid->time + HZ * dir_cache_timeout)) {
735+
if (cfid->last_access_time &&
736+
time_after(jiffies, cfid->last_access_time + HZ * dir_cache_timeout)) {
735737
cfid->on_list = false;
736738
list_move(&cfid->entry, &entry);
737739
cfids->num_entries--;

fs/smb/client/cached_dir.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct cached_fid {
3939
bool on_list:1;
4040
bool file_all_info_is_valid:1;
4141
unsigned long time; /* jiffies of when lease was taken */
42+
unsigned long last_access_time; /* jiffies of when last accessed */
4243
struct kref refcount;
4344
struct cifs_fid fid;
4445
spinlock_t fid_lock;

0 commit comments

Comments
 (0)