[PATCH 1/1] smb: client: Fix hang in smb2_reconnect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Rickard x Andersson <rickaran@xxxxxxxx>

Test case:
mount -t cifs //192.168.0.1/test y -o port=19999,ro,vers=2.1,sec=none,
      echo_interval=1
kill smbd with SIGSTOP
umount /tmp/y

Gives the following error:
INFO: task umount:1470 blocked for more than 122 seconds.
Not tainted 6.1.36-axis9-devel #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:umount          state:D stack:0     pid:1470  ppid:1468
__schedule from schedule+0x60/0x100
schedule from schedule_preempt_disabled+0x24/0x34
schedule_preempt_disabled from __mutex_lock.constprop.0+0x2bc/0x8e0
__mutex_lock.constprop.0 from smb2_reconnect+0x120/0x4e0 [cifs]
smb2_reconnect [cifs] from SMB2_open_init+0x58/0xb1c [cifs]
SMB2_open_init [cifs] from smb2_compound_op+0x1b8/0x1b10 [cifs]
smb2_compound_op [cifs] from smb2_query_path_info+0xf4/0x25c [cifs]
smb2_query_path_info [cifs] from cifs_get_inode_info+0x3d8/0x948 [cifs]
cifs_get_inode_info [cifs] from cifs_revalidate_dentry_attr+0x214/0x3d4
cifs_revalidate_dentry_attr [cifs] from cifs_getattr+0xb4/0x250 [cifs]
cifs_getattr [cifs] from vfs_getattr_nosec+0xac/0xcc
vfs_getattr_nosec from vfs_statx+0x9c/0x140
vfs_statx from do_statx+0x5c/0x80
do_statx from sys_statx+0x64/0x7c
sys_statx from ret_fast_syscall+0x0/0x64

Stack trace for kworker holding mutex:
wait_for_response+0x74/0xb0 [cifs]
compound_send_recv+0x3cc/0xa80 [cifs]
cifs_send_recv+0x34/0x3c [cifs]
SMB2_negotiate+0x428/0x13d4 [cifs]
smb2_negotiate+0x4c/0x58 [cifs]
cifs_negotiate_protocol+0x9c/0x100 [cifs]
smb2_reconnect+0x370/0x598 [cifs]
smb2_reconnect_server+0x210/0x674 [cifs]
process_one_work+0x188/0x490
worker_thread+0x50/0x4f4
kthread+0xf0/0x124
ret_from_fork+0x14/0x2c

Signed-off-by: Rickard x Andersson <rickaran@xxxxxxxx>
---
 fs/smb/client/transport.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
index 87aea456ee90..2fbb9de2d099 100644
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -759,13 +759,14 @@ static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
 static int
 wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
 {
-	int error;
+	int ret;
 
-	error = wait_event_state(server->response_q,
-				 midQ->mid_state != MID_REQUEST_SUBMITTED &&
-				 midQ->mid_state != MID_RESPONSE_RECEIVED,
-				 (TASK_KILLABLE|TASK_FREEZABLE_UNSAFE));
-	if (error < 0)
+	ret = wait_event_killable_timeout(server->response_q,
+					  midQ->mid_state != MID_REQUEST_SUBMITTED &&
+					  midQ->mid_state != MID_RESPONSE_RECEIVED,
+					  10*HZ);
+
+	if ((ret < 0) || (ret == 0))
 		return -ERESTARTSYS;
 
 	return 0;
-- 
2.30.2




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux