From 46e978ce97d8974e5e553cbb1036ae3b807e8b05 Mon Sep 17 00:00:00 2001 From: zhenwei pi Date: Wed, 18 Mar 2020 10:08:03 +0800 Subject: [PATCH] iser: fix hang in rdma_destroy_id Hit iser hang in rdma_destroy_id with trace: #0 pthread_cond_wait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 #1 0x00007f96ecbbcbb3 in rdma_destroy_id () from /usr/lib/librdmacm.so.1 #2 0x00005632027311d4 in iser_conn_release (iser_conn=iser_conn@entry=0x7f96d4027440) at iser.c:261 #3 0x0000563202731428 in iscsi_iser_connect (iscsi=0x563205206c70, sa=, ai_family=) at iser.c:1516 #4 0x000056320273dd3c in iscsi_connect_async (iscsi=iscsi@entry=0x563205206c70, portal=portal@entry=0x563205207084 "210.32.124.205:3260", cb=cb@entry=0x56320272b220 , private_data=private_data@entry=0x7f96d4008b00) at socket.c:389 #5 0x000056320272b325 in iscsi_full_connect_async (iscsi=0x563205206c70, portal=0x563205207084 "210.32.124.205:3260", lun=1, cb=cb@entry=0x56320272aef0 , private_data=private_data@entry=0x0) at connect.c:230 #6 0x000056320272b711 in iscsi_reconnect (iscsi=) at connect.c:473 #7 0x00005632026810a8 in iscsi_timed_check_events (opaque=0x563205206ae0) at block/iscsi.c:387 Currently use pthread_cancel to kill cmthread forcefully, cmthread may exits without rdma_ack_cm_event, then unacknowledged event will be remained in librdmacm. rdma_destroy_id hangs until uplayer ack all the cm event. Since destroying qp, cm thread will handle DISCONNECTED event, and exits by itself. Joining cm thread to wait cm thread to exit gracefully. Signed-off-by: zhenwei pi --- lib/iser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/iser.c b/lib/iser.c index 2361d9e..f3baf4c 100644 --- a/lib/iser.c +++ b/lib/iser.c @@ -201,7 +201,6 @@ iser_free_iser_conn_res(struct iser_conn *iser_conn, bool destroy) if (destroy) { if (iser_conn->cmthread) { - pthread_cancel(iser_conn->cmthread); pthread_join(iser_conn->cmthread, NULL); iser_conn->cmthread = 0; }