From nobody@FreeBSD.org  Thu Jan 21 16:37:13 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 87E8A106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jan 2010 16:37:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DDF48FC1E
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jan 2010 16:37:13 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0LGbC5x033413
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 21 Jan 2010 16:37:12 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0LGbCNU033412;
	Thu, 21 Jan 2010 16:37:12 GMT
	(envelope-from nobody)
Message-Id: <201001211637.o0LGbCNU033412@www.freebsd.org>
Date: Thu, 21 Jan 2010 16:37:12 GMT
From: Nikos Vassiliadis <nvass9573@gmx.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] make mdconfig -o reserve default for malloc-backed memory disks
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143058
>Category:       bin
>Synopsis:       [patch] mdconfig(8): make mdconfig -o reserve default for malloc-backed memory disks
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 21 16:40:06 UTC 2010
>Closed-Date:    
>Last-Modified:  Sat Jan 23 00:10:08 UTC 2010
>Originator:     Nikos Vassiliadis
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD lab.localdomain 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Fri Jan  8 12:01:55 EET 2010     root@lab.localdomain:/usr/obj/usr/src/sys/LAB  i386

>Description:
Creating and filling a big malloc-backed memory disk is a way to panic
the system. This could be easily avoided if the reseve option became the
default for malloc disks.
>How-To-Repeat:
mdconfig -at malloc -s 200m
dd if=/dev/zero of=/dev/md0
>Fix:
The attached patch adds reserve to the defaults for malloc disks

Patch attached with submission follows:

Index: src/sbin/mdconfig/mdconfig.8
===================================================================
RCS file: /home/ncvs/src/sbin/mdconfig/mdconfig.8,v
retrieving revision 1.44
diff -u -r1.44 mdconfig.8
--- src/sbin/mdconfig/mdconfig.8	10 Jan 2009 17:17:18 -0000	1.44
+++ src/sbin/mdconfig/mdconfig.8	21 Jan 2010 16:12:10 -0000
@@ -91,8 +91,8 @@
 .Xr malloc 9 .
 This limits the size to the malloc bucket limit in the kernel.
 If the
-.Fl o Cm reserve
-option is not set, creating and filling a large
+.Fl o Cm noreserve
+option is set, creating and filling a large
 malloc-backed memory disk is a very easy way to
 panic a system.
 .It Cm vnode
Index: src/sbin/mdconfig/mdconfig.c
===================================================================
RCS file: /home/ncvs/src/sbin/mdconfig/mdconfig.c,v
retrieving revision 1.57
diff -u -r1.57 mdconfig.c
--- src/sbin/mdconfig/mdconfig.c	10 Jan 2009 17:17:18 -0000	1.57
+++ src/sbin/mdconfig/mdconfig.c	21 Jan 2010 16:12:10 -0000
@@ -115,7 +115,7 @@
 				usage();
 			if (!strcmp(optarg, "malloc")) {
 				mdio.md_type = MD_MALLOC;
-				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS;
+				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS | MD_RESERVE;
 			} else if (!strcmp(optarg, "preload")) {
 				mdio.md_type = MD_PRELOAD;
 				mdio.md_options = 0;


>Release-Note:
>Audit-Trail:
>Unformatted:
