From pkern@utcs.utoronto.ca  Thu Jul  5 14:49:00 2001
Return-Path: <pkern@utcs.utoronto.ca>
Received: from rodent.utcs.utoronto.ca (rodent.utcs.utoronto.ca [128.100.102.5])
	by hub.freebsd.org (Postfix) with SMTP id F1EED37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  5 Jul 2001 14:48:59 -0700 (PDT)
	(envelope-from pkern@utcs.utoronto.ca)
Received: by rodent.utcs.utoronto.ca id <444525>; Thu, 5 Jul 2001 17:48:56 -0400
Message-Id: <01Jul5.174856edt.444525@rodent.utcs.utoronto.ca>
Date: Thu, 5 Jul 2001 17:48:48 -0400
From: pkern@utcs.utoronto.ca
Sender: P Kern <pkern@utcs.utoronto.ca>
Reply-To: pkern@utcs.utoronto.ca
To: FreeBSD-gnats-submit@freebsd.org
Cc: pkern@utcs.utoronto.ca
Subject: IPFW log messages causes syslogd to fsync.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         28738
>Category:       bin
>Synopsis:       IPFW log messages causes syslogd to fsync.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 05 14:50:01 PDT 2001
>Closed-Date:    Thu Nov 1 14:18:31 PST 2001
>Last-Modified:  Thu Nov 01 14:20:35 PST 2001
>Originator:     pkern
>Release:        FreeBSD 4.3-RELEASE i386
>Organization:
Computing and Network Services, University of Toronto
>Environment:
System: FreeBSD knobs.utcs 4.3-RELEASE FreeBSD 4.3-RELEASE #57: Thu Jul 5 18:49:34 EDT 2001 pkern@knobs.utcs:/usr/src/sys/compile/KWAI i386


>Description:
	
	syslogd is set to fsync after each klog message.
	This results in a lot of disk activity if IPFW is being used
	with verbose logging enabled -- an fsync for each IPFW syslog
	(and there could be more than one IPFW log message per packet).
	But IPFW syslogs use the LOG_SECURITY facility so it's possible
	to exempt those messages from being fsync'ed each time.

>How-To-Repeat:
>Fix:

	--- syslogd.c	2001/06/12 08:25:31	1.1
	+++ syslogd.c	2001/06/12 16:39:49
	@@ -712,6 +712,8 @@
				++p;
			if ((pri & LOG_FACMASK) == LOG_CONSOLE)
				flags |= IGN_CONS;
	+		if ((pri & LOG_FACMASK) == LOG_SECURITY)
	+			flags &= ~SYNC_FILE;
		} else {
			/* kernel printf's come out on console */
			flags |= IGN_CONS;
>Release-Note:
>Audit-Trail:

From: Dima Dorfman <dima@unixfreak.org>
To: pkern@utcs.utoronto.ca
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/28738: IPFW log messages causes syslogd to fsync. 
Date: Thu, 05 Jul 2001 18:13:14 -0700

 pkern@utcs.utoronto.ca writes:
 > >Description:
 > 	
 > 	syslogd is set to fsync after each klog message.
 > 	This results in a lot of disk activity if IPFW is being used
 > 	with verbose logging enabled -- an fsync for each IPFW syslog
 > 	(and there could be more than one IPFW log message per packet).
 > 	But IPFW syslogs use the LOG_SECURITY facility so it's possible
 > 	to exempt those messages from being fsync'ed each time.
 
 But it may not be the only one using LOG_SECURITY.  And if it is now,
 can you say that for N months in the future?

From: P Kern <pkern@utcs.utoronto.ca>
To: dima@unixfreak.org
Cc: FreeBSD-gnats-submit@freebsd.org, pkern@utcs.utoronto.ca
Subject: Re: bin/28738: IPFW log messages causes syslogd to fsync.
Date: Fri, 6 Jul 2001 14:15:21 -0400

 >From unixfreak.org!dima Thu Jul  5 21:13:29 2001
 >
 > pkern@utcs.utoronto.ca writes:
 > > >Description:
 > > 	
 > > 	syslogd is set to fsync after each klog message.
 > > 	This results in a lot of disk activity if IPFW is being used
 > > 	with verbose logging enabled -- an fsync for each IPFW syslog
 > > 	(and there could be more than one IPFW log message per packet).
 > > 	But IPFW syslogs use the LOG_SECURITY facility so it's possible
 > > 	to exempt those messages from being fsync'ed each time.
 >
 > But it may not be the only one using LOG_SECURITY.
 
 Hi.  I made sure to check the kernel sources before trying this change.
 In 4.3-RELEASE, IPFW messages are the only ones using LOG_SECURITY.
 So this change would only affect how syslogd behaves when it receives
 IPFW messages from the kernel.
 
 > And if it is now, can you say that for N months in the future?
 
 Hmmm, I'm guessing this implies that new code should include comments.
 Sorry about that.  Here's an updated patch.  Hope this helps.  pk.
 
 	--- syslogd.c	2001/06/12 08:25:31	1.1
 	+++ syslogd.c	2001/07/06 22:01:36
 	@@ -712,6 +712,11 @@
 				++p;
 			if ((pri & LOG_FACMASK) == LOG_CONSOLE)
 				flags |= IGN_CONS;
 	+
 	+		/* don't fsync for IPFW messages. */
 	+		if ((pri & LOG_FACMASK) == LOG_SECURITY)
 	+			flags &= ~SYNC_FILE;
 	+
 		} else {
 			/* kernel printf's come out on console */
 			flags |= IGN_CONS;

From: "Crist J. Clark" <cristjc@earthlink.net>
To: pkern@utcs.utoronto.ca, dima@unixfreak.org
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/28738: IPFW log messages causes syslogd to fsync.
Date: Wed, 3 Oct 2001 17:26:06 -0700

 IMHO, having LOG_SECURITY fsync for each message is a feature not a
 bug. However, there is a workaround available to those who don't want
 disk access for each message using the normal syslogd(8) capabilities.
 
 Instead of sending your security messages to a file,
 
   security.*				/var/log/security
 
 You can send them to a _program_ which sends them to a file. For
 example, we can make a simple buffer so that we need to get 10kB of
 messages before we write to the file,
 
   security.*				|/bin/dd obs=10k of=/var/log/security
 
 This will prevent the disk write for each message. Other utilities or
 even a custom program may suit your individual needs better.
 
 But I don't feel that messing with any hardcode is appropriate
 here. The ability to stop the fsync, which I think few people really
 want, can be done by simply reconfiguring your syslog.conf(5).
 
 Does this look workable to you?
 -- 
 Crist J. Clark                           cjclark@alum.mit.edu
                                          cjclark@jhu.edu
                                          cjc@freebsd.org
State-Changed-From-To: open->feedback 
State-Changed-By: cjc 
State-Changed-When: Thu Oct 25 00:58:13 PDT 2001 
State-Changed-Why:  
Feedback on using syslog.conf(5) to stop the constant sync's is 
requested. Unless there is a good reason why this solution is not 
sufficient, I'd like to clost this one up. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28738 
State-Changed-From-To: feedback->closed 
State-Changed-By: cjc 
State-Changed-When: Thu Nov 1 14:18:31 PST 2001 
State-Changed-Why:  
Submitter happy with workaround provided. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28738 
>Unformatted:
