Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2004 14:10:33 +0100 (CET)
From:      Phil Regnauld <regnauld+freebsd@catpipe.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/63388: Patch to make syslogd optionally not fsync kernel messages
Message-ID:  <20040226131033.990E276317@chef.catpipe.net>
Resent-Message-ID: <200402261320.i1QDKD0w027193@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040226131033.990E276317>