Whamcloud - gitweb
LU-316 Fix changelog deadlock when changelog client is killed
authorOleg Drokin <green@whamcloud.com>
Tue, 17 May 2011 05:19:41 +0000 (01:19 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 19 May 2011 20:14:18 +0000 (13:14 -0700)
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 <green@whamcloud.com>
Change-Id: Id0a53361862124e6b4febdbb3f8cacce34799e68
Reviewed-on: http://review.whamcloud.com/555
Tested-by: Hudson
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Mikhail Pershin <tappro@whamcloud.com>
lustre/mdc/mdc_request.c

index 2848c10..d8d6303 100644 (file)
@@ -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),