From patchwork Fri Jan 16 20:23:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 5650541 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B2D4BC058D for ; Fri, 16 Jan 2015 21:33:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFC652034B for ; Fri, 16 Jan 2015 21:33:01 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C44D620340 for ; Fri, 16 Jan 2015 21:33:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0GLSnml018271; Fri, 16 Jan 2015 16:28:49 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t0GLRs9P012024 for ; Fri, 16 Jan 2015 16:27:54 -0500 Received: from redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t0GLRrJ0000412; Fri, 16 Jan 2015 16:27:53 -0500 Received: by redhat.com (sSMTP sendmail emulation); Fri, 16 Jan 2015 14:23:49 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Fri, 16 Jan 2015 14:23:31 -0600 Message-Id: <1421439812-11826-8-git-send-email-bmarzins@redhat.com> In-Reply-To: <1421439812-11826-1-git-send-email-bmarzins@redhat.com> References: <1421439812-11826-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 7/8] multipathd: don't buffer output with systemd X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When stdout isn't hooked up to a tty (like it isn't when you start multipathd through systemd) the stream is buffered, so messages only come out in big chunks, or when the program quits. Instead, we should send the messages out to systemd as we generate them, so that users know what's happening, and in the event of a crash, they get the most recent messages. I realize that there is a performance impact to this. If people are against this approach, we could change condlog to print messages above a certain priority to stderr and messages below that priority to stdout. If we included a configuration option to change the priority level, then we could always change it up if we needed to do debugging. However, the standard level messages are very helpful in quickly diagnosing a number of problems, so you could make a good argument that we always want priority 2 messages printed immediately. And if we intentionally bumped up the debugging level, we would usually want those messages printed immediately. This is exactly what we get with just unbuffering stdout. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index f9e3f33..bc21d04 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2011,9 +2011,11 @@ main (int argc, char *argv[]) exit(0); } - if (logsink < 1) + if (logsink < 1) { + if (!isatty(fileno(stdout))) + setbuf(stdout, NULL); err = 0; - else + } else err = daemonize(); if (err < 0)