Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH 1/7] cifs: Revert "smb: client: Avoid race in open_cached_dir with lease breaks"
@ 2025-06-04 10:18 nspmangalore
  2025-06-04 10:18 ` [PATCH 2/7] cifs: protect cfid accesses with fid_lock nspmangalore
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: nspmangalore @ 2025-06-04 10:18 UTC (permalink / raw)
  To: linux-cifs, smfrench, bharathsm.hsk, meetakshisetiyaoss, pc, paul,
	henrique.carvalho, ematsumiya
  Cc: Shyam Prasad N

From: Shyam Prasad N <sprasad@microsoft.com>

This reverts commit 3ca02e63edccb78ef3659bebc68579c7224a6ca2.
Upcoming patches in this code path introduces a new mutex, which
takes care of the same problem which this change fixes, but with
the use of mutex for the same section. So the net effect is that
there will be no blocking with spinlocks held.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
 fs/smb/client/cached_dir.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 89d2dbbb742c..e6fc92667d41 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -29,6 +29,7 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
 {
 	struct cached_fid *cfid;
 
+	spin_lock(&cfids->cfid_list_lock);
 	list_for_each_entry(cfid, &cfids->entries, entry) {
 		if (!strcmp(cfid->path, path)) {
 			/*
@@ -37,20 +38,25 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
 			 * being deleted due to a lease break.
 			 */
 			if (!cfid->time || !cfid->has_lease) {
+				spin_unlock(&cfids->cfid_list_lock);
 				return NULL;
 			}
 			kref_get(&cfid->refcount);
+			spin_unlock(&cfids->cfid_list_lock);
 			return cfid;
 		}
 	}
 	if (lookup_only) {
+		spin_unlock(&cfids->cfid_list_lock);
 		return NULL;
 	}
 	if (cfids->num_entries >= max_cached_dirs) {
+		spin_unlock(&cfids->cfid_list_lock);
 		return NULL;
 	}
 	cfid = init_cached_dir(path);
 	if (cfid == NULL) {
+		spin_unlock(&cfids->cfid_list_lock);
 		return NULL;
 	}
 	cfid->cfids = cfids;
@@ -68,6 +74,7 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
 	 */
 	cfid->has_lease = true;
 
+	spin_unlock(&cfids->cfid_list_lock);
 	return cfid;
 }
 
@@ -181,10 +188,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 	if (!utf16_path)
 		return -ENOMEM;
 
-	spin_lock(&cfids->cfid_list_lock);
 	cfid = find_or_create_cached_dir(cfids, path, lookup_only, tcon->max_cached_dirs);
 	if (cfid == NULL) {
-		spin_unlock(&cfids->cfid_list_lock);
 		kfree(utf16_path);
 		return -ENOENT;
 	}
@@ -193,6 +198,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 	 * Otherwise, it is either a new entry or laundromat worker removed it
 	 * from @cfids->entries.  Caller will put last reference if the latter.
 	 */
+	spin_lock(&cfids->cfid_list_lock);
 	if (cfid->has_lease && cfid->time) {
 		spin_unlock(&cfids->cfid_list_lock);
 		*ret_cfid = cfid;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-07-27 18:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-04 10:18 [PATCH 1/7] cifs: Revert "smb: client: Avoid race in open_cached_dir with lease breaks" nspmangalore
2025-06-04 10:18 ` [PATCH 2/7] cifs: protect cfid accesses with fid_lock nspmangalore
2025-06-12  3:24   ` Paul Aurich
2025-06-12 13:05     ` Shyam Prasad N
2025-06-12 16:33       ` Paul Aurich
2025-06-12 17:55         ` Shyam Prasad N
2025-06-04 10:18 ` [PATCH 3/7] cifs: do not return an invalidated cfid nspmangalore
2025-06-04 10:18 ` [PATCH 4/7] cifs: serialize initialization and cleanup of cfid nspmangalore
2025-06-12  3:25   ` Paul Aurich
2025-06-12  9:37     ` Shyam Prasad N
2025-06-12 15:28       ` Steve French
2025-06-04 10:18 ` [PATCH 5/7] cifs: update the lock ordering comments with new mutex nspmangalore
2025-06-04 10:18 ` [PATCH 6/7] cifs: tc_count updates should be done with tc_lock nspmangalore
2025-06-12  3:24   ` Paul Aurich
2025-06-04 10:18 ` [PATCH 7/7] cifs: add new field to track the last access time of cfid nspmangalore
2025-07-24 23:05   ` Steve French
2025-07-25  3:26     ` Steve French
2025-07-27 18:23       ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox