Skip to contentSkip to conversation

CIFS: reconnect thread reschedule itself

PATCH Superseded Germano Percossi 1 participant 1 message Mar 28, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 CIFS: reconnect thread reschedule itself

In case of error, smb2_reconnect_server reschedule itself with a delay, to avoid being too aggressive.

---
 fs/cifs/smb2pdu.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +11 -1
index efe167c..523e3f1 100644
@@ -2177,6 +2177,9 @@ void smb2_reconnect_server(struct work_struct *work)
 	struct cifs_tcon *tcon, *tcon2;
 	struct list_head tmp_list;
 	int tcon_exist = false;
+	int rc;
+	int resched = false;
+
 
 	/* Prevent simultaneous reconnects that can corrupt tcon->rlist list */
 	mutex_lock(&server->reconnect_mutex);
@@ -2204,13 +2207,20 @@ void smb2_reconnect_server(struct work_struct *work)
 	spin_unlock(&cifs_tcp_ses_lock);
 
 	list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) {
-		if (!smb2_reconnect(SMB2_INTERNAL_CMD, tcon))
+		rc = smb2_reconnect(SMB2_INTERNAL_CMD, tcon);
+		if (!rc) {
 			cifs_reopen_persistent_handles(tcon);
+		} else {
+			resched = true;
+		}
 		list_del_init(&tcon->rlist);
 		cifs_put_tcon(tcon);
 	}
 
 	cifs_dbg(FYI, "Reconnecting tcons finished\n");
+	if (resched) {
+		queue_delayed_work(cifsiod_wq, &server->reconnect, 2 * HZ);
+	}
 	mutex_unlock(&server->reconnect_mutex);
 
 	/* now we can safely release srv struct */
Signature · 1 line
2.7.4