Skip to contentSkip to conversation

scsi: iscsi: print error info after unlock 'frwd_lock' in iscsi_check_transport_timeouts()

PATCH New Ye Bin 1 participant 1 message Apr 9, 2025

Subsystems (2)
lore
Share & tools
lore

Ye Bin

author
#0 lore raw

PATCH 1/1 scsi: iscsi: print error info after unlock 'frwd_lock' in iscsi_check_transport_timeouts()

From: Ye Bin <[email protected]>

When a timeout occurs in iscsi_check_transport_timeouts(), it may be accompanied by many storage failures, and there may be many error logs printed to the serial port in a short period. In the case of a slow serial port, it may take a long time to output to the serial port in printk while holding the "&session->frwd_lock" lock. This can cause other processes to be unable to obtain the "&session->frwd_lock" lock, triggering a series of issues. To reduce the critical section of the "&session->frwd_lock" lock, error printing is moved outside the lock.

---
 drivers/scsi/libiscsi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/libiscsi.c +8 -5
index 1ddaf7228340..bbaed4eccfbf 100644
@@ -2252,20 +2252,23 @@ static void iscsi_check_transport_timeouts(struct timer_list *t)
 	if (!recv_timeout)
 		goto done;
 
-	recv_timeout *= HZ;
 	last_recv = conn->last_recv;
 
 	if (iscsi_has_ping_timed_out(conn)) {
+		int ping_timeout = conn->ping_timeout;
+		unsigned long last_ping = conn->last_ping;
+
+		spin_unlock(&session->frwd_lock);
 		iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
-				  "expired, recv timeout %d, last rx %lu, "
+				  "expired, recv timeout %lu, last rx %lu, "
 				  "last ping %lu, now %lu\n",
-				  conn->ping_timeout, conn->recv_timeout,
-				  last_recv, conn->last_ping, jiffies);
-		spin_unlock(&session->frwd_lock);
+				  ping_timeout, recv_timeout,
+				  last_recv, last_ping, jiffies);
 		iscsi_conn_failure(conn, ISCSI_ERR_NOP_TIMEDOUT);
 		return;
 	}
 
+	recv_timeout *= HZ;
 	if (time_before_eq(last_recv + recv_timeout, jiffies)) {
 		/* send a ping to try to provoke some traffic */
 		ISCSI_DBG_CONN(conn, "Sending nopout as ping\n");
Signature · 1 line
2.34.1