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>
if (ct->magic != CT_PRIV_MAGIC)
return -EINVAL;
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);
/* 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);
llapi_hsm_log_ct_registration(&ct, CT_UNREGISTER);
close(ct->open_by_fid_fd);