From owner-freebsd-hackers Thu May 10 20:20:49 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 9272C37B423 for ; Thu, 10 May 2001 20:20:41 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id F3FB43E28; Thu, 10 May 2001 20:20:40 -0700 (PDT) To: Poul-Henning Kamp Cc: hackers@freebsd.org Subject: Re: Who's cleaning up after disk_clone? In-Reply-To: <75404.989482620@critter>; from phk@critter.freebsd.dk on "Thu, 10 May 2001 10:17:00 +0200" Date: Thu, 10 May 2001 20:20:40 -0700 From: Dima Dorfman Message-Id: <20010511032041.F3FB43E28@bazooka.unixfreak.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Poul-Henning Kamp writes: > In message <20010510074028.847EE3E28@bazooka.unixfreak.org>, Dima Dorfman writes: > > - what should be destroying /dev/md0c? > > The disk-minilayer. > > We need some to keep track of cloned dev_t's so we can nuke them > at various strategic points, havn't gotten to that yet. Well, that sounds pretty easy to do. Patch attached. It solves this problem quite effectively. At this point it only nukes the clones when disk_destroy is called; I don't know if there are other places this should be done. Comments? Dima Dorfman dima@unixfreak.org Index: sys/conf.h =================================================================== RCS file: /st/src/FreeBSD/src/sys/sys/conf.h,v retrieving revision 1.127 diff -u -r1.127 conf.h --- sys/conf.h 2001/05/01 08:13:17 1.127 +++ sys/conf.h 2001/05/11 03:17:14 @@ -86,6 +86,7 @@ int __sid_bsize_best; /* optimal block size */ } __si_disk; } __si_u; + LIST_ENTRY(specinfo) si_clist; }; #define si_tty __si_u.__si_tty.__sit_tty Index: sys/disk.h =================================================================== RCS file: /st/src/FreeBSD/src/sys/sys/disk.h,v retrieving revision 1.17 diff -u -r1.17 disk.h --- sys/disk.h 2000/06/15 20:30:53 1.17 +++ sys/disk.h 2001/05/11 03:17:14 @@ -30,6 +30,7 @@ dev_t d_dev; struct diskslices *d_slice; struct disklabel d_label; + LIST_HEAD(, specinfo) d_clones; LIST_ENTRY(disk) d_list; }; Index: kern/subr_disk.c =================================================================== RCS file: /st/src/FreeBSD/src/sys/kern/subr_disk.c,v retrieving revision 1.36 diff -u -r1.36 subr_disk.c --- kern/subr_disk.c 2001/05/06 21:55:22 1.36 +++ kern/subr_disk.c 2001/05/11 03:17:14 @@ -86,6 +86,7 @@ *dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p), UID_ROOT, GID_OPERATOR, 0640, name); + LIST_INSERT_HEAD(&dp->d_clones, *dev, si_clist); return; } } @@ -129,6 +130,7 @@ dp->d_dev = dev; dp->d_dsflags = flags; dp->d_devsw = cdevsw; + LIST_INIT(&dp->d_clones); LIST_INSERT_HEAD(&disklist, dp, d_list); if (!once) { EVENTHANDLER_REGISTER(dev_clone, disk_clone, 0, 1000); @@ -174,7 +176,14 @@ void disk_destroy(dev_t dev) { + dev_t pdev; + LIST_REMOVE(dev->si_disk, d_list); + while (!LIST_EMPTY(&dev->si_disk->d_clones)) { + pdev = LIST_FIRST(&dev->si_disk->d_clones); + LIST_REMOVE(pdev, si_clist); + destroy_dev(pdev); + } bzero(dev->si_disk, sizeof(*dev->si_disk)); dev->si_disk = NULL; destroy_dev(dev); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message