Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 May 2001 20:20:40 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        hackers@freebsd.org
Subject:   Re: Who's cleaning up after disk_clone? 
Message-ID:  <20010511032041.F3FB43E28@bazooka.unixfreak.org>
In-Reply-To: <75404.989482620@critter>; from phk@critter.freebsd.dk on "Thu, 10 May 2001 10:17:00 %2B0200"

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp <phk@critter.freebsd.dk> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010511032041.F3FB43E28>