Whamcloud - gitweb
LU-7992 hsm: close KUC pipe before unregistering 42/19442/2
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 4 Jun 2015 14:48:44 +0000 (09:48 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 21 Apr 2016 02:28:23 +0000 (02:28 +0000)
In llapi_hsm_copytool_unregister() close the read side of the KUC pipe
before unregistering the copytool to avoid deadlocking with a ldlm_cb
thread.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I844086b32a3b2958ecaec391accded0ca06f60a2
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/19442
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
lustre/utils/liblustreapi_hsm.c

index 95ac6da..b7678d7 100644 (file)
@@ -803,13 +803,17 @@ int llapi_hsm_copytool_unregister(struct hsm_copytool_private **priv)
        if (ct->magic != CT_PRIV_MAGIC)
                return -EINVAL;
 
+       /* Close the read side of the KUC pipe. This should be done
+        * before unregistering to avoid deadlock: a ldlm_cb thread
+        * enters libcfs_kkuc_group_put() acquires kg_sem and blocks
+        * in pipe_write() due to full pipe; then we attempt to
+        * unregister and block on kg_sem. */
+       libcfs_ukuc_stop(&ct->kuc);
+
        /* Tell the kernel to stop sending us messages */
        ct->kuc.lk_flags = LK_FLG_STOP;
        ioctl(ct->mnt_fd, LL_IOC_HSM_CT_START, &ct->kuc);
 
-       /* Shut down the kernelcomms */
-       libcfs_ukuc_stop(&ct->kuc);
-
        llapi_hsm_log_ct_registration(&ct, CT_UNREGISTER);
 
        close(ct->open_by_fid_fd);