From 9e6a0fcbf02942caff9d769d644913964d34c028 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 17 May 2011 01:19:41 -0400 Subject: [PATCH] LU-316 Fix changelog deadlock when changelog client is killed Make sure that all unused filedescriptors are closed to ensure that when the reader is dead, ther are no holders of the read fd and we do get EPIPE to our writes. Signed-off-by: Oleg Drokin Change-Id: Id0a53361862124e6b4febdbb3f8cacce34799e68 Reviewed-on: http://review.whamcloud.com/555 Tested-by: Hudson Reviewed-by: Alex Zhuravlev Reviewed-by: Mikhail Pershin --- lustre/mdc/mdc_request.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 2848c10..d8d6303 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1255,6 +1255,13 @@ static int mdc_changelog_send_thread(void *csdata) CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n", cs->cs_fp, cs->cs_startrec); + /* + * It's important to daemonize here to close unused FDs. + * The write fd from pipe is already opened by the caller, + * so it's fine to clear all files here + */ + cfs_daemonize("mdc_clg_send_thread"); + OBD_ALLOC(cs->cs_buf, CR_MAXSIZE); if (cs->cs_buf == NULL) GOTO(out, rc = -ENOMEM); @@ -1274,9 +1281,7 @@ static int mdc_changelog_send_thread(void *csdata) GOTO(out, rc); } - /* We need the pipe fd open, so llog_process can't daemonize */ - rc = llog_cat_process_flags(llh, changelog_show_cb, cs, - LLOG_FLAG_NODEAMON, 0, 0); + rc = llog_cat_process_flags(llh, changelog_show_cb, cs, 0, 0, 0); /* Send EOF no matter what our result */ if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), -- 1.8.3.1