From regnauld@catpipe.net  Thu Feb 26 05:10:36 2004
Return-Path: <regnauld@catpipe.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 048C016A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Feb 2004 05:10:36 -0800 (PST)
Received: from chef.catpipe.net (chef.catpipe.net [195.249.214.145])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8F01043D41
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Feb 2004 05:10:35 -0800 (PST)
	(envelope-from regnauld@catpipe.net)
Received: by chef.catpipe.net (Postfix, from userid 1001)
	id 990E276317; Thu, 26 Feb 2004 14:10:33 +0100 (CET)
Message-Id: <20040226131033.990E276317@chef.catpipe.net>
Date: Thu, 26 Feb 2004 14:10:33 +0100 (CET)
From: Phil Regnauld <regnauld+freebsd@catpipe.net>
Reply-To: Phil Regnauld <regnauld+freebsd@catpipe.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Patch to make syslogd optionally not fsync kernel messages
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         63388
>Category:       bin
>Synopsis:       Patch to make syslogd optionally not fsync kernel messages
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 26 05:20:13 PST 2004
>Closed-Date:    Sun May 30 07:34:15 PDT 2004
>Last-Modified:  Sun May 30 07:34:15 PDT 2004
>Originator:     Phil Regnauld
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
catpipe Systems ApS
>Environment:
System: gw.catpipe.net 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Sat Jan 17 15:37:54 CET 2004     regnauld@gw.catpipe.net:/data/src/sys/compile/GW  i386
>Description:
	By default, the syslogd will call fsync after every write when logging
	message coming from the kernel.  This can be problematic in the event
	that many kernel messages are being logged to disk in a rapid
	succession (i.e.: firewall logging).  This patch implements a new
	option for syslogd, -K, which disables fsyncing upon reception
	 kernel messages.

>How-To-Repeat:
	n/a
>Fix:

--- syslogd.c.orig	Tue Jan 20 16:12:43 2004
+++ syslogd.c	Tue Jan 20 16:16:53 2004
@@ -286,6 +286,7 @@
 static int	LogFacPri;	/* Put facility and priority in log message: */
 				/* 0=no, 1=numeric, 2=names */
 static int	KeepKernFac;	/* Keep remotely logged kernel facility */
+static int	NoSyncKern;	/* Don't fsync on /dev/klog messages */
 
 volatile sig_atomic_t MarkSet, WantDie;
 
@@ -367,6 +368,9 @@
 		case 'k':		/* keep remote kern fac */
 			KeepKernFac = 1;
 			break;
+		case 'K':		/* no sync on /dev/klog */
+			NoSyncKern = 1;
+			break;
 		case 'l':
 			if (nfunix < MAXFUNIX)
 				funixn[nfunix++] = optarg;
@@ -732,7 +736,7 @@
 {
 	int pri, flags;
 
-	flags = ISKERNEL | SYNC_FILE | ADDDATE;	/* fsync after write */
+	flags = ISKERNEL | ( NoSyncKern ? 0x000 : SYNC_FILE) | ADDDATE;	/* fsync after write */
 	pri = DEFSPRI;
 	if (*p == '<') {
 		pri = 0;

--- syslogd.8.orig	Tue Jan 20 16:19:33 2004
+++ syslogd.8	Tue Jan 20 16:21:17 2004
@@ -181,6 +181,9 @@
 .Dq kern
 facility is reserved for messages read directly from
 .Pa /dev/klog .
+.It Fl K
+Disable fsync after write (the default) on messages read from
+.Pa /dev/klog .
 .It Fl m
 Select the number of minutes between
 .Dq mark
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Mon Mar 22 03:28:52 PST 2004 
Responsible-Changed-Why:  
The patch looks reasonable to me - I'll look into committing it. I 
wonder if it might be worth extending it slightly to that you can 
say "-K 23" to fsync after every 23 lines or "-K 0" to disable 
fsyncing? 

David. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63388 
State-Changed-From-To: open->feedback 
State-Changed-By: dwmalone 
State-Changed-When: Sun May 30 03:12:41 PDT 2004 
State-Changed-Why:  
Hi Phil, 

I've just committed an option to turn off fsyncing of kernel messages 
on specific logfiles. I think this is probably a more flexible 
option than adding a flag to completly turning off fsyncing. If 
this meets your needs, then I can close this PR. 

David. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63388 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun May 30 07:33:21 PDT 2004 
State-Changed-Why:  
The option not to fsync a file should be enough. If not, we can reopen 
the PR later. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63388 
>Unformatted:
