diff options
| author | Enzo Matsumiya <ematsumiya@suse.de> | 2025-09-15 12:05:08 -0300 |
|---|---|---|
| committer | Enzo Matsumiya <ematsumiya@suse.de> | 2025-09-25 12:03:02 -0300 |
| commit | 76765f7c08bf1b989ad8f40eddb3364529bc546e (patch) | |
| tree | e6eeeef120f8613592fddcc77ff793ac7d6ecdde | |
| parent | c8155cf3699c2decbc42118eb67ce93cf539a7c1 (diff) | |
| download | linux-76765f7c08bf1b989ad8f40eddb3364529bc546e.tar.gz linux-76765f7c08bf1b989ad8f40eddb3364529bc546e.tar.bz2 linux-76765f7c08bf1b989ad8f40eddb3364529bc546e.zip | |
smb: client: remove cached_dir_put_work/put_work
Move cfid to dying list directly on cached_dir_lease_break(), and
schedule laundromat for cleanup there too.
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
| -rw-r--r-- | fs/smb/client/cached_dir.c | 56 | ||||
| -rw-r--r-- | fs/smb/client/cached_dir.h | 1 |
2 files changed, 17 insertions, 40 deletions
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 8689ee4a883d..ab37a025ea1c 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -597,39 +597,11 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon) flush_delayed_work(&cfids->laundromat_work); } -/* - * Release the cached directory's dentry and schedule immediate cleanup on laundromat. - * Must be called with a reference to the cached_fid and a reference to the tcon. - */ -static void cached_dir_put_work(struct work_struct *work) -{ - struct cached_fid *cfid = container_of(work, struct cached_fid, put_work); - struct cached_fids *cfids = cfid->cfids; - struct cifs_tcon *tcon = cfid->tcon; - struct dentry *dentry; - - spin_lock(&cfid->fid_lock); - dentry = cfid->dentry; - cfid->dentry = NULL; - spin_unlock(&cfid->fid_lock); - - dput(dentry); - - /* move to dying list so laundromat can clean it up */ - spin_lock(&cfids->cfid_list_lock); - list_move(&cfid->entry, &cfids->dying); - cfid->on_list = false; - cfids->num_entries--; - spin_unlock(&cfids->cfid_list_lock); - - cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cached_close); - mod_delayed_work(cfid_put_wq, &cfids->laundromat_work, 0); -} - bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]) { struct cached_fids *cfids = tcon->cfids; struct cached_fid *cfid; + bool found = false; if (cfids == NULL) return false; @@ -643,16 +615,25 @@ bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]) cfid->has_lease = false; cfid->time = 0; - ++tcon->tc_count; - trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count, - netfs_trace_tcon_ref_get_cached_lease_break); - queue_work(cfid_put_wq, &cfid->put_work); - spin_unlock(&cfids->cfid_list_lock); - return true; + /* + * We found a lease, move it to the dying list and schedule immediate + * cleanup on laundromat. + * No need to take a ref here, as we still hold our initial one. + */ + list_move(&cfid->entry, &cfids->dying); + cfids->num_entries--; + cfid->on_list = false; + found = true; + break; } } spin_unlock(&cfids->cfid_list_lock); - return false; + + /* avoid unnecessary scheduling */ + if (found) + mod_delayed_work(cfid_put_wq, &cfids->laundromat_work, 0); + + return found; } static struct cached_fid *init_cached_dir(const char *path) @@ -668,7 +649,6 @@ static struct cached_fid *init_cached_dir(const char *path) return NULL; } - INIT_WORK(&cfid->put_work, cached_dir_put_work); INIT_LIST_HEAD(&cfid->entry); INIT_LIST_HEAD(&cfid->dirents.entries); mutex_init(&cfid->dirents.de_mutex); @@ -681,8 +661,6 @@ static void free_cached_dir(struct cached_fid *cfid) { struct cached_dirent *dirent, *q; - WARN_ON(work_pending(&cfid->put_work)); - /* * Delete all cached dirent names */ diff --git a/fs/smb/client/cached_dir.h b/fs/smb/client/cached_dir.h index e5445e3a7bd3..5e892d53a67a 100644 --- a/fs/smb/client/cached_dir.h +++ b/fs/smb/client/cached_dir.h @@ -44,7 +44,6 @@ struct cached_fid { spinlock_t fid_lock; struct cifs_tcon *tcon; struct dentry *dentry; - struct work_struct put_work; struct smb2_file_all_info file_all_info; struct cached_dirents dirents; }; |
