From 62752bf3b143630560adfdb568606a661fdafafb Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 4 Jun 2015 09:48:44 -0500 Subject: [PATCH] LU-7992 hsm: close KUC pipe before unregistering 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 Change-Id: I844086b32a3b2958ecaec391accded0ca06f60a2 Reviewed-by: Jinshan Xiong Reviewed-by: Bob Glossman Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/19442 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago --- lustre/utils/liblustreapi_hsm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index 95ac6da..b7678d7 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -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); -- 1.8.3.1