Skip to contentSkip to conversation

cifs: add missing spinlock around tcon refcount

PATCH In review Paulo Alcantara 2 participants 2 messages Sep 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: add missing spinlock around tcon refcount

Add missing spinlock to protect updates on tcon refcount in cifs_put_tcon().

Fixes d7d7a66aacd6 ("cifs: avoid use of global locks for high contention data")
---
 fs/cifs/connect.c | 3 +++
 1 file changed, 3 insertions(+)
fs/cifs/connect.c +3 -0
index 251753d0a54b..23fc48aa2ed6 100644
@@ -2350,7 +2350,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
 	ses = tcon->ses;
 	cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
 	spin_lock(&cifs_tcp_ses_lock);
+	spin_lock(&tcon->tc_lock);
 	if (--tcon->tc_count > 0) {
+		spin_unlock(&tcon->tc_lock);
 		spin_unlock(&cifs_tcp_ses_lock);
 		return;
 	}
@@ -2359,6 +2361,7 @@ cifs_put_tcon(struct cifs_tcon *tcon)
 	WARN_ON(tcon->tc_count < 0);
 
 	list_del_init(&tcon->tcon_list);
+	spin_unlock(&tcon->tc_lock);
 	spin_unlock(&cifs_tcp_ses_lock);
 
 	/* cancel polling of interfaces */
Signature · 1 line
2.37.3
#1 lore raw

LGTM

Quoted 35 lines · Paulo Alcantara

Add missing spinlock to protect updates on tcon refcount in cifs_put_tcon().

Fixes d7d7a66aacd6 ("cifs: avoid use of global locks for high contention data")
---
 fs/cifs/connect.c | 3 +++
 1 file changed, 3 insertions(+)
fs/cifs/connect.c +3 -1
index 251753d0a54b..23fc48aa2ed6 100644
@@ -2350,7 +2350,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
        ses = tcon->ses;
        cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
        spin_lock(&cifs_tcp_ses_lock);
+       spin_lock(&tcon->tc_lock);
        if (--tcon->tc_count > 0) {
+               spin_unlock(&tcon->tc_lock);
                spin_unlock(&cifs_tcp_ses_lock);
                return;
        }
@@ -2359,6 +2361,7 @@ cifs_put_tcon(struct cifs_tcon *tcon)
        WARN_ON(tcon->tc_count < 0);
 
        list_del_init(&tcon->tcon_list);
+       spin_unlock(&tcon->tc_lock);
        spin_unlock(&cifs_tcp_ses_lock);
 
        /* cancel polling of interfaces */
--

2.37.3