bin/63388: Patch to make syslogd optionally not fsync kernel messages

Phil Regnauld regnauld+freebsd at catpipe.net
Thu Feb 26 05:20:14 PST 2004


>Number:         63388
>Category:       bin
>Synopsis:       Patch to make syslogd optionally not fsync kernel messages
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 26 05:20:13 PST 2004
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list