From owner-freebsd-current@FreeBSD.ORG Sat May 17 22:36:16 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E05537B401 for ; Sat, 17 May 2003 22:36:16 -0700 (PDT) Received: from HAL9000.homeunix.com (12-233-57-131.client.attbi.com [12.233.57.131]) by mx1.FreeBSD.org (Postfix) with ESMTP id 953F843F3F for ; Sat, 17 May 2003 22:36:15 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.5) with ESMTP id h4I5Zwd2000255; Sat, 17 May 2003 22:35:58 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.5/Submit) id h4I5ZvcD000254; Sat, 17 May 2003 22:35:57 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Sat, 17 May 2003 22:35:57 -0700 From: David Schultz To: Giorgos Keramidas Message-ID: <20030518053557.GA223@HAL9000.homeunix.com> Mail-Followup-To: Giorgos Keramidas , current@freebsd.org References: <20030514232428.GA731@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030514232428.GA731@gothmog.gr> cc: current@FreeBSD.ORG Subject: Re: Panic with swap-backed md devices X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2003 05:36:16 -0000 On Thu, May 15, 2003, Giorgos Keramidas wrote: > Trying to create and destroy a swap-backed md device results in panics > with today's CURRENT. I was trying to make a new -t swap md disk to > test the problem described in a PR. Using the following small shell > script I noticed that it always causes a panic when mdconfig -d is run: > > mdconfig -a -t swap -s 100m -u 10 > disklabel -r -w md10 auto > newfs -O 1 -b 8192 -s 1024 md10 > mount /dev/md10 /mnt > mount > umount /mnt > mount > mdconfig -d -u 10 The following patch should fix the panic, but there's a small vm_object leak that's still unfixed. I'll look into that. Index: sys/dev/md/md.c =================================================================== RCS file: /cvs/src/sys/dev/md/md.c,v retrieving revision 1.98 diff -u -r1.98 md.c --- sys/dev/md/md.c 2 May 2003 06:18:58 -0000 1.98 +++ sys/dev/md/md.c 18 May 2003 04:04:23 -0000 @@ -932,7 +932,9 @@ if (sc->cred != NULL) crfree(sc->cred); if (sc->object != NULL) { + VM_OBJECT_LOCK(sc->object); vm_pager_deallocate(sc->object); + VM_OBJECT_UNLOCK(sc->object); } if (sc->indir) destroy_indir(sc, sc->indir); @@ -990,7 +992,9 @@ sc->flags = mdio->md_options & MD_FORCE; if (mdio->md_options & MD_RESERVE) { if (swap_pager_reserve(sc->object, 0, sc->nsect) < 0) { + VM_OBJECT_LOCK(sc->object); vm_pager_deallocate(sc->object); + VM_OBJECT_UNLOCK(sc->object); sc->object = NULL; mddestroy(sc, td); return (EDOM);