From david@catwhisker.org  Mon Oct 10 16:37:50 2005
Return-Path: <david@catwhisker.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 11FC516A41F;
	Mon, 10 Oct 2005 16:37:50 +0000 (GMT)
	(envelope-from david@catwhisker.org)
Received: from bunrab.catwhisker.org (adsl-63-193-123-122.dsl.snfc21.pacbell.net [63.193.123.122])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B046D43D45;
	Mon, 10 Oct 2005 16:37:49 +0000 (GMT)
	(envelope-from david@catwhisker.org)
Received: from bunrab.catwhisker.org (localhost [127.0.0.1])
	by bunrab.catwhisker.org (8.13.3/8.13.3) with ESMTP id j9AGbntJ058768;
	Mon, 10 Oct 2005 09:37:49 -0700 (PDT)
	(envelope-from david@bunrab.catwhisker.org)
Received: (from david@localhost)
	by bunrab.catwhisker.org (8.13.3/8.13.1/Submit) id j9AGbnk8058767;
	Mon, 10 Oct 2005 09:37:49 -0700 (PDT)
	(envelope-from david)
Message-Id: <200510101637.j9AGbnk8058767@bunrab.catwhisker.org>
Date: Mon, 10 Oct 2005 09:37:49 -0700 (PDT)
From: David Wolfskill <david@catwhisker.org>
Reply-To: David Wolfskill <david@catwhisker.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: yar@freebsd.org
Subject: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         87218
>Category:       bin
>Synopsis:       Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 10 16:40:14 GMT 2005
>Closed-Date:    Tue Oct 11 14:52:07 GMT 2005
>Last-Modified:  Tue Oct 11 15:00:25 GMT 2005
>Originator:     David Wolfskill
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
Wolfskill & Dowling Residence
>Environment:
System: FreeBSD g1-18.catwhisker.org. 5.4-STABLE FreeBSD 5.4-STABLE #622: Mon Oct 10 07:48:53 PDT 2005     root@g1-18.catwhisker.org.:/common/S2/obj/usr/src/sys/LAPTOP_30W  i386

>Description:
On 24 Aug 2005 16:25:47 +0000 (UTC), Yar Tikhiy <yar@FreeBSD.org>
committed a change to src/etc/rc.subr (1.37) and src/etc/defaults/rc.conf
(1.259) to move the "-M" flag for the mdmfs invocation from the
mount_md() function in rc.subr to the tmpmfs_flags and varmfs_flags in
defaults/rc.conf.

That change was MFCed to RELENG_6 by Yar on 2005-08-28 09:08:06 UTC.

I am asking that it also be MFCed to RELENG_5, which suffers from the
same problem.  (RELENG_4 does not, however, so I am not requesting
that.)

The incident that catalyzed this PR is documented was described in a
message posted to freebsd-stable, and may be found at
<http://docs.FreeBSD.org/cgi/mid.cgi?20051010020729.GA56351>.

>How-To-Repeat:
See <http://docs.FreeBSD.org/cgi/mid.cgi?20051010020729.GA56351>.

And yes, I've tested the fix/MFC under RELENG_5.  With the below fix
implemented , the machine under test (ref the "uname -a" output above)
survived being a CVS server while a CVS client did a "cvs update"  on
/usr/ports -- while the machine under test was also updating a RELENG_6
/usr/src at the same time.  I try to get some use out of a laptop.

>Fix:

Index: rc.subr
===================================================================
RCS file: /cvs/freebsd/src/etc/rc.subr,v
retrieving revision 1.31.2.1
diff -u -r1.31.2.1 rc.subr
--- rc.subr	17 Jan 2005 11:51:00 -0000	1.31.2.1
+++ rc.subr	10 Oct 2005 16:32:42 -0000
@@ -1294,7 +1294,7 @@
 	if [ -n "$3" ]; then
 		flags="$3"
 	fi
-	/sbin/mdmfs $flags -s $1 -M md $2
+	/sbin/mdmfs $flags -s $1 md $2
 }
 
 fi
Index: defaults/rc.conf
===================================================================
RCS file: /cvs/freebsd/src/etc/defaults/rc.conf,v
retrieving revision 1.212.2.19
diff -u -r1.212.2.19 rc.conf
--- defaults/rc.conf	25 Sep 2005 19:06:24 -0000	1.212.2.19
+++ defaults/rc.conf	10 Oct 2005 16:33:07 -0000
@@ -44,10 +44,10 @@
 removable_interfaces=""	# Removable network interfaces for /etc/pccard_ether.
 tmpmfs="AUTO"		# Set to YES to always create an mfs /tmp, NO to never
 tmpsize="20m"		# Size of mfs /tmp if created
-tmpmfs_flags="-S"	# Extra mdmfs options for the mfs /tmp
+tmpmfs_flags="-S -M"	# Extra mdmfs options for the mfs /tmp
 varmfs="AUTO"		# Set to YES to always create an mfs /var, NO to never
 varsize="32m"		# Size of mfs /var if created
-varmfs_flags="-S"	# Extra mount options for the mfs /var
+varmfs_flags="-S -M"	# Extra mount options for the mfs /var
 populate_var="AUTO"	# Set to YES to always (re)populate /var, NO to never
 local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs.
 script_name_sep=" "	# Change if your startup scripts' names contain spaces
	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Mon Oct 10 16:43:40 GMT 2005 
Responsible-Changed-Why:  
My stuff. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87218 
State-Changed-From-To: open->feedback 
State-Changed-By: yar 
State-Changed-When: Tue Oct 11 09:20:57 GMT 2005 
State-Changed-Why:  
The change has been merged to RELENG_5.  Now it's possible to control 
the -M flag to mdmfs in RELENG_5, too. 

By the way, why did you say your system survived w/o -M? 
Had it paniced or failed in other way with mfs mounted memory-backed? 
Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87218 

From: David Wolfskill <david@catwhisker.org>
To: Yar Tikhiy <yar@freebsd.org>
Cc:  
Subject: Re: bin/87218: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
Date: Tue, 11 Oct 2005 04:53:11 -0700

 On Tue, Oct 11, 2005 at 09:24:24AM +0000, Yar Tikhiy wrote:
 > Synopsis: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: yar
 > State-Changed-When: Tue Oct 11 09:20:57 GMT 2005
 > State-Changed-Why: 
 > The change has been merged to RELENG_5.  Now it's possible to control
 > the -M flag to mdmfs in RELENG_5, too.
 
 Cool; thanks!  :-)
  
 > By the way, why did you say your system survived w/o -M?
 > Had it paniced or failed in other way with mfs mounted memory-backed?
 
 Oh, yeah.  Twice, before I got clever enough to switch from the normal X
 environment to ttyv0, and run the commands from xterms displaying on the
 "client" system (another laptop -- the one assigned by my employer).
 (The "server" is my personal laptop, where I keep a private mirror of
 the FreeBSD CVS repository updated daily.)
 
 Turns out that just doing a "cvs update" in /usr/ports on the client box
 was enough to crash the server.  (This came as a rather rude surprise to
 me, as I'd done it before -- but when my persoanl laptop was running
 RELENG_4.)
 
 Each machine was configured to use a 512 MB tmpmfs; the work laptop had
 1 GB swap and my personal laptop had 2 GB swap.
 
 But since /tmp was malloc-based, the amount of swap wasn't all that
 relevant.   :-{
 
 Once /tmp became swap-backed, things were fine.  :-)
 
 > Thanks.
 
 Thank *you*!  :-) 
 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=87218
 
 Peace,
 david
 -- 
 David H. Wolfskill				david@catwhisker.org
 Prediction is difficult, especially if it involves the future. -- Niels Bohr
 
 See http://www.catwhisker.org/~david/publickey.gpg for public key.

From: Yar Tikhiy <yar@comp.chem.msu.su>
To: David Wolfskill <david@catwhisker.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/87218: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
Date: Tue, 11 Oct 2005 17:58:23 +0400

 On Tue, Oct 11, 2005 at 04:53:11AM -0700, David Wolfskill wrote:
 >  
 > > By the way, why did you say your system survived w/o -M?
 > > Had it paniced or failed in other way with mfs mounted memory-backed?
 > 
 > Oh, yeah.  Twice, before I got clever enough to switch from the normal X
 > environment to ttyv0, and run the commands from xterms displaying on the
 > "client" system (another laptop -- the one assigned by my employer).
 > (The "server" is my personal laptop, where I keep a private mirror of
 > the FreeBSD CVS repository updated daily.)
 > 
 > Turns out that just doing a "cvs update" in /usr/ports on the client box
 > was enough to crash the server.  (This came as a rather rude surprise to
 > me, as I'd done it before -- but when my persoanl laptop was running
 > RELENG_4.)
 > 
 > Each machine was configured to use a 512 MB tmpmfs; the work laptop had
 > 1 GB swap and my personal laptop had 2 GB swap.
 > 
 > But since /tmp was malloc-based, the amount of swap wasn't all that
 > relevant.   :-{
 > 
 > Once /tmp became swap-backed, things were fine.  :-)
 
 And how much RAM did you have in your server and client laptops?
 Just want to see how large part of the RAM was occupied by the
 malloc-based mfs disk...  But in any case, I think the OS shouldn't
 panic even if the disk size is too large.  If I can reproduce a
 similar problem in CURRENT, I'll file a problem report on it.
 
 -- 
 Yar

From: David Wolfskill <david@catwhisker.org>
To: Yar Tikhiy <yar@comp.chem.msu.su>
Cc:  
Subject: Re: bin/87218: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
Date: Tue, 11 Oct 2005 07:44:03 -0700

 On Tue, Oct 11, 2005 at 05:58:23PM +0400, Yar Tikhiy wrote:
 > ...
 
 > > But since /tmp was malloc-based, the amount of swap wasn't all that
 > > relevant.   :-{
 > > 
 > > Once /tmp became swap-backed, things were fine.  :-)
 > 
 > And how much RAM did you have in your server and client laptops?
 
 Client: 256 MB (physical); usable (from dmesg):
 
 real memory  = 234684416 (223 MB)
 avail memory = 219992064 (209 MB)
 
 Looks as if this laptop shares some system memory as video RAM.  It's a
 cheap laptop from Fry's -- brand name is "Great Quality" (really!).
 
 Server: 256 MB (physical); usable (from /var/log/messages -- dmesg
 didn't go back far enough because I boot verbose by default, and didn't
 kick the message buffer up high enough):
 
 real memory  = 268312576 (262024K bytes)
 avail memory = 255799296 (249804K bytes)
 
 This is a (used) Dell Inspiron 8200.
 
 > Just want to see how large part of the RAM was occupied by the
 > malloc-based mfs disk...  But in any case, I think the OS shouldn't
 > panic even if the disk size is too large.  If I can reproduce a
 > similar problem in CURRENT, I'll file a problem report on it.
 
 OK; should be easy with a malloc-based /tmp:
 
 * Set up a box running HEAD (or -CURRENT).  Ensure that it has plenty of
   swap space.  (Yes, swapping is fairly bad for performance.  Being
   unable to swap because of insufficient swap space when the OS needs to
   swap is nearly always worse.  Disk space is cheap.)  I suggest at
   least 1 GB for swap; as noted earlier, on my personal laptop (which
   acted as the server in my test cases), I had 2 GB swap allocated.
 
 * Set up the box to use a malloc-based /tmp.  Allocate at least 512 MB
   to it; double the default number of inodes.
 
 * Place a copy of (at least) the ports section of the FreeBSD CVS
   repository on the machine and set it (the machine) up to be a CVS
   server.
 
 * Ensure that you have a console available on the machine so you can see
   the panic.  :-}
 
 * Set up another machine to be a client.  Find some disk space on the
   machine and run something on the order of
 
 	cd ${parent_directory}
 	cvs -d ":ext:${USER}@${server}:${path_to_cvs_repo_on_server} co ports
 
 * Depending on speed of machines, NICs, and intermediate network
   infrastructure, the server should panic somewhere from 2 - 10 minutes
   into the excercise.
 
 Yes, if you can make the failure more graceful than a panic, that would
 be good.  :-}
 
 I did hand-transcribe the kernel backtrace from the 3rd one I got; I can
 send that to you, but I'm not sure how useful it would be for you.
 
 Peace,
 david
 -- 
 David H. Wolfskill				david@catwhisker.org
 Prediction is difficult, especially if it involves the future. -- Niels Bohr
 
 See http://www.catwhisker.org/~david/publickey.gpg for public key.
State-Changed-From-To: feedback->closed 
State-Changed-By: yar 
State-Changed-When: Tue Oct 11 14:51:27 GMT 2005 
State-Changed-Why:  
The present problem has been resolved.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87218 

From: Yar Tikhiy <yar@comp.chem.msu.su>
To: David Wolfskill <david@catwhisker.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/87218: Please MFC (to RELENG_5) changes to /etc/rc.subr and /etc/defaults/rc.conf
Date: Tue, 11 Oct 2005 18:49:51 +0400

 Thanks for the info.  I've just been able to reproduce a system
 panic with 256M of RAM and 200M of mfs.  It is enough just to
 write a large file with "cat /dev/urandom > /mnt/foo" to get the
 panic.  A new PR filed, too.
 
 OK, now this PR can be closed.
 
 -- 
 Yar
>Unformatted:
