Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Paul Aurich <paul@darkrain42.org>
To: nspmangalore@gmail.com
Cc: linux-cifs@vger.kernel.org, smfrench@gmail.com,
	bharathsm.hsk@gmail.com, meetakshisetiyaoss@gmail.com,
	pc@manguebit.com, henrique.carvalho@suse.com, ematsumiya@suse.de,
	Shyam Prasad N <sprasad@microsoft.com>
Subject: Re: [PATCH 6/7] cifs: tc_count updates should be done with tc_lock
Date: Wed, 11 Jun 2025 20:24:28 -0700	[thread overview]
Message-ID: <aEpIbMKyUh-6eqsR@vaarsuvius.home.arpa> (raw)
In-Reply-To: <20250604101829.832577-6-sprasad@microsoft.com>

On 2025-06-04 15:48:15 +0530, nspmangalore@gmail.com wrote:
>From: Shyam Prasad N <sprasad@microsoft.com>
>
>We had problems with deadlocks using the cifs_tcp_ses_lock for
>protecting a lot of structures. So we broke it down into smaller
>spinlocks. cifs_tcon struct fields are protected by tc_lock now.
>Hence we should stick to using that.

Is it really safe to adjust this to tc_lock?

There are a number of other points in the smb client that (AFAICT) only hold 
cifs_tcp_ses_lock while adjusting the tc_count (which is why I used that 
here).  See smb2_handle_cancelled_close, smb2_get_dfs_refer, 
smb2_reconnect_server, smb2_find_smb_tcon.

~Paul

>Fixes: 3fa640d035e5 ("smb: During unmount, ensure all cached dir instances drop their dentry")
>Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
>---
> fs/smb/client/cached_dir.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
>index 2746d693d80a..4abf5bbd8baf 100644
>--- a/fs/smb/client/cached_dir.c
>+++ b/fs/smb/client/cached_dir.c
>@@ -650,10 +650,12 @@ int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16])
> 			spin_unlock(&cfid->fid_lock);
> 			cfids->num_entries--;
>
>+			spin_lock(&cfid->tcon->tc_lock);
> 			++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(&cfid->tcon->tc_lock);
> 			spin_unlock(&cfids->cfid_list_lock);
> 			return true;
> 		}
>@@ -767,11 +769,11 @@ static void cfids_laundromat_worker(struct work_struct *work)
> 		dput(dentry);
>
> 		if (cfid->is_open) {
>-			spin_lock(&cifs_tcp_ses_lock);
>+			spin_lock(&cfid->tcon->tc_lock);
> 			++cfid->tcon->tc_count;
> 			trace_smb3_tcon_ref(cfid->tcon->debug_id, cfid->tcon->tc_count,
> 					    netfs_trace_tcon_ref_get_cached_laundromat);
>-			spin_unlock(&cifs_tcp_ses_lock);
>+			spin_unlock(&cfid->tcon->tc_lock);
> 			queue_work(serverclose_wq, &cfid->close_work);
> 		} else
> 			/*
>-- 
>2.43.0
>


  reply	other threads:[~2025-06-12  3:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=aEpIbMKyUh-6eqsR@vaarsuvius.home.arpa \
    --to=paul@darkrain42.org \
    --cc=bharathsm.hsk@gmail.com \
    --cc=ematsumiya@suse.de \
    --cc=henrique.carvalho@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=meetakshisetiyaoss@gmail.com \
    --cc=nspmangalore@gmail.com \
    --cc=pc@manguebit.com \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.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