summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnzo Matsumiya <ematsumiya@suse.de>2025-09-15 12:05:08 -0300
committerEnzo Matsumiya <ematsumiya@suse.de>2025-10-07 10:23:49 -0300
commit0dda48ca14b34acd6fd7a21a63875e0e1ab0155a (patch)
tree6424293517e28067fb7424692ff483c36a1136f3
parentae8fa033cc11e0dffb523bcd65cb8383dd97898b (diff)
downloadlinux-0dda48ca14b34acd6fd7a21a63875e0e1ab0155a.tar.gz
linux-0dda48ca14b34acd6fd7a21a63875e0e1ab0155a.tar.bz2
linux-0dda48ca14b34acd6fd7a21a63875e0e1ab0155a.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.c51
-rw-r--r--fs/smb/client/cached_dir.h1
2 files changed, 17 insertions, 35 deletions
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 8ea0ab033c51..0f259461a746 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -599,34 +599,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;
-
- dput(cfid->dentry);
- cfid->dentry = NULL;
-
- /* 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;
@@ -640,16 +617,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)
@@ -665,7 +651,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);
@@ -677,8 +662,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 03f356088144..51cfdb81ec53 100644
--- a/fs/smb/client/cached_dir.h
+++ b/fs/smb/client/cached_dir.h
@@ -46,7 +46,6 @@ struct cached_fid {
struct cifs_fid fid;
struct cifs_tcon *tcon;
struct dentry *dentry;
- struct work_struct put_work;
struct smb2_file_all_info file_all_info;
struct cached_dirents dirents;
};