--- linux-last/drivers/md/dm.c	Wed Nov 28 17:09:02 2001
+++ linux/drivers/md/dm.c	Thu Nov 29 11:37:13 2001
@@ -636,7 +636,14 @@
 
 static void __unbind(struct mapped_device *md)
 {
+	int minor = MINOR(md->dev);
+
+	dm_table_destroy(md->map);
 	md->map = NULL;
+
+	_block_size[minor] = 0;
+	_blksize_size[minor] = 0;
+	_hardsect_size[minor] = 0;
 }
 
 
@@ -709,10 +716,8 @@
 }
 
 /*
- * destructor for the device.  md->map is
- * deliberately not destroyed, dm-fs/dm-ioctl
- * should manage table objects.  You cannot
- * destroy a suspended device.
+ * Destructor for the device.  You cannot destroy
+ * a suspended device.
  */
 int dm_destroy(struct mapped_device *md)
 {
@@ -767,7 +772,7 @@
 }
 
 /*
- * Swap in a new table.
+ * Swap in a new table (destroying old one).
  */
 int dm_swap_table(struct mapped_device *md, struct dm_table *table)
 {
--- linux-last/drivers/md/dm-ioctl.c	Wed Nov 28 17:09:02 2001
+++ linux/drivers/md/dm-ioctl.c	Thu Nov 29 11:36:27 2001
@@ -212,7 +212,7 @@
 {
 	int r;
 	struct mapped_device *md = dm_get(param->name);
-	struct dm_table *t, *old;
+	struct dm_table *t;
 
 	if (!md)
 		return -ENXIO;
@@ -225,14 +225,11 @@
 		return r;
 	}
 
-	old = md->map;
-
 	if ((r = dm_swap_table(md, t))) {
 		dm_table_destroy(t);
 		return r;
 	}
 
-	dm_table_destroy(old);
 	return 0;
 }
 
