From: Paul Aurich <paul@darkrain42.org>
To: linux-cifs@vger.kernel.org, Steve French <sfrench@samba.org>
Cc: paul@darkrain42.org, Paulo Alcantara <pc@manguebit.com>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>
Subject: [PATCH 4/5] smb: No need to wait for work when cleaning up cached directories
Date: Fri, 8 Nov 2024 14:29:05 -0800 [thread overview]
Message-ID: <20241108222906.3257172-5-paul@darkrain42.org> (raw)
In-Reply-To: <20241108222906.3257172-1-paul@darkrain42.org>
It isn't possible for cfids_laundromat_worker(),
invalidate_all_cached_dirs(), and cached_dir_lease_break() to race with
each other. Each holds the spinlock while walking the list of cfids, and
removes entries from the list. cfids_laundromat_worker() and
invalidate_all_cached_dirs() will never see a cfid that has pending
work.
Signed-off-by: Paul Aurich <paul@darkrain42.org>
---
fs/smb/client/cached_dir.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 06eb19dabb0e..de1e41abdaf2 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -516,11 +516,10 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
}
spin_unlock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &entry, entry) {
list_del(&cfid->entry);
- cancel_work_sync(&cfid->lease_break);
/*
* Drop the ref-count from above, either the lease-ref (if there
* was one) or the extra one acquired.
*/
kref_put(&cfid->refcount, smb2_close_cached_fid);
@@ -594,10 +593,12 @@ static struct cached_fid *init_cached_dir(const char *path)
static void free_cached_dir(struct cached_fid *cfid)
{
struct cached_dirent *dirent, *q;
+ WARN_ON(work_pending(&cfid->lease_break));
+
dput(cfid->dentry);
cfid->dentry = NULL;
/*
* Delete all cached dirent names
@@ -640,15 +641,10 @@ static void cfids_laundromat_worker(struct work_struct *work)
}
spin_unlock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &entry, entry) {
list_del(&cfid->entry);
- /*
- * Cancel and wait for the work to finish in case we are racing
- * with it.
- */
- cancel_work_sync(&cfid->lease_break);
/*
* Drop the ref-count from above, either the lease-ref (if there
* was one) or the extra one acquired.
*/
kref_put(&cfid->refcount, smb2_close_cached_fid);
--
2.45.2
next prev parent reply other threads:[~2024-11-08 22:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 22:29 [PATCH 0/5] SMB cached directory fixes around reconnection/unmounting Paul Aurich
2024-11-08 22:29 ` [PATCH 1/5] smb: cached directories can be more than root file handle Paul Aurich
2024-11-08 22:29 ` [PATCH 2/5] smb: Don't leak cfid when reconnect races with open_cached_dir Paul Aurich
2024-11-08 22:29 ` [PATCH 3/5] smb: prevent use-after-free due to open_cached_dir error paths Paul Aurich
2024-11-08 22:29 ` Paul Aurich [this message]
2024-11-08 22:29 ` [PATCH 5/5] smb: During umount, flush any pending lease breaks for cached dirs Paul Aurich
2024-11-08 22:33 ` Steve French
2024-11-08 22:39 ` [PATCH 0/5] SMB cached directory fixes around reconnection/unmounting Steve French
2024-11-08 22:44 ` Paul Aurich
2024-11-08 23:09 ` Enzo Matsumiya
2024-11-10 0:49 ` Steve French
2024-11-13 19:08 ` Paul Aurich
2024-11-18 17:40 ` Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241108222906.3257172-5-paul@darkrain42.org \
--to=paul@darkrain42.org \
--cc=bharathsm@microsoft.com \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox