Whamcloud - gitweb
LU-12233 lnet: deadlock on LNet shutdown 33/39933/3
authorSerguei Smirnov <ssmirnov@whamcloud.com>
Wed, 16 Sep 2020 16:46:48 +0000 (09:46 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 25 Sep 2020 03:13:04 +0000 (03:13 +0000)
Release ln_api_mutex during LNet shutdown while waiting
for zombie LNI to allow other threads to read the LNet
state updated by the shutdown and fall through, avoiding
the deadlock

Signed-off-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Change-Id: Iaba11624d5b79bd0acb4add39f6153c55770440a
Reviewed-on: https://review.whamcloud.com/39933
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c

index a7b3f8c..dff911d 100644 (file)
@@ -2114,7 +2114,13 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net)
                }
 
                if (!list_empty(&ni->ni_netlist)) {
+                       /* Unlock mutex while waiting to allow other
+                        * threads to read the LNet state and fall through
+                        * to avoid deadlock
+                        */
                        lnet_net_unlock(LNET_LOCK_EX);
+                       mutex_unlock(&the_lnet.ln_api_mutex);
+
                        ++i;
                        if ((i & (-i)) == i) {
                                CDEBUG(D_WARNING,
@@ -2122,6 +2128,8 @@ lnet_clear_zombies_nis_locked(struct lnet_net *net)
                                       libcfs_nid2str(ni->ni_nid));
                        }
                        schedule_timeout_uninterruptible(cfs_time_seconds(1));
+
+                       mutex_lock(&the_lnet.ln_api_mutex);
                        lnet_net_lock(LNET_LOCK_EX);
                        continue;
                }