xref: /dflybsd-src/sys/dev/disk/dm/device-mapper.c (revision 956c8d716bb0166e3061a37d96d0415ef44f564c)
1 /*        $NetBSD: device-mapper.c,v 1.22 2010/03/26 15:46:04 jakllsch Exp $ */
2 
3 /*
4  * Copyright (c) 2010 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Adam Hamsik.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*
33  * I want to say thank you to all people who helped me with this project.
34  */
35 
36 #include <sys/types.h>
37 #include <sys/param.h>
38 
39 #include <sys/buf.h>
40 #include <sys/conf.h>
41 #include <sys/device.h>
42 #include <sys/devfs.h>
43 #include <sys/disk.h>
44 #include <sys/disklabel.h>
45 #include <sys/dtype.h>
46 #include <sys/ioccom.h>
47 #include <sys/malloc.h>
48 #include <sys/module.h>
49 #include <sys/sysctl.h>
50 
51 #include "netbsd-dm.h"
52 #include "dm.h"
53 
54 static	d_ioctl_t	dmioctl;
55 static	d_open_t	dmopen;
56 static	d_close_t	dmclose;
57 static	d_psize_t	dmsize;
58 static	d_strategy_t	dmstrategy;
59 static	d_dump_t	dmdump;
60 
61 /* attach and detach routines */
62 void dmattach(int);
63 static int dm_modcmd(module_t mod, int cmd, void *unused);
64 static int dmdestroy(void);
65 
66 static void dm_doinit(void);
67 
68 static int dm_cmd_to_fun(prop_dictionary_t);
69 static int disk_ioctl_switch(cdev_t, u_long, void *);
70 static int dm_ioctl_switch(u_long);
71 #if 0
72 static void dmminphys(struct buf *);
73 #endif
74 
75 struct devfs_bitmap dm_minor_bitmap;
76 
77 /* ***Variable-definitions*** */
78 struct dev_ops dm_ops = {
79 	{ "dm", 0, D_DISK | D_MPSAFE },
80 	.d_open		= dmopen,
81 	.d_close	= dmclose,
82 	.d_read 	= physread,
83 	.d_write 	= physwrite,
84 	.d_ioctl	= dmioctl,
85 	.d_strategy	= dmstrategy,
86 	.d_psize	= dmsize,
87 	.d_dump		= dmdump,
88 /* D_DISK */
89 };
90 
91 MALLOC_DEFINE(M_DM, "dm", "Device Mapper allocations");
92 
93 int dm_debug_level = 0;
94 
95 extern uint64_t dm_dev_counter;
96 
97 static cdev_t dmcdev;
98 
99 static moduledata_t dm_mod = {
100     "dm",
101     dm_modcmd,
102     NULL
103 };
104 DECLARE_MODULE(dm, dm_mod, SI_SUB_RAID, SI_ORDER_ANY);
105 
106 /*
107  * This array is used to translate cmd to function pointer.
108  *
109  * Interface between libdevmapper and lvm2tools uses different
110  * names for one IOCTL call because libdevmapper do another thing
111  * then. When I run "info" or "mknodes" libdevmapper will send same
112  * ioctl to kernel but will do another things in userspace.
113  *
114  */
115 static struct cmd_function cmd_fn[] = {
116 		{ .cmd = "version", .fn = dm_get_version_ioctl},
117 		{ .cmd = "targets", .fn = dm_list_versions_ioctl},
118 		{ .cmd = "create",  .fn = dm_dev_create_ioctl},
119 		{ .cmd = "info",    .fn = dm_dev_status_ioctl},
120 		{ .cmd = "mknodes", .fn = dm_dev_status_ioctl},
121 		{ .cmd = "names",   .fn = dm_dev_list_ioctl},
122 		{ .cmd = "suspend", .fn = dm_dev_suspend_ioctl},
123 		{ .cmd = "remove",  .fn = dm_dev_remove_ioctl},
124 		{ .cmd = "rename",  .fn = dm_dev_rename_ioctl},
125 		{ .cmd = "resume",  .fn = dm_dev_resume_ioctl},
126 		{ .cmd = "clear",   .fn = dm_table_clear_ioctl},
127 		{ .cmd = "deps",    .fn = dm_table_deps_ioctl},
128 		{ .cmd = "reload",  .fn = dm_table_load_ioctl},
129 		{ .cmd = "status",  .fn = dm_table_status_ioctl},
130 		{ .cmd = "table",   .fn = dm_table_status_ioctl},
131 		{NULL, NULL}
132 };
133 
134 /* New module handle routine */
135 static int
136 dm_modcmd(module_t mod, int cmd, void *unused)
137 {
138 	int error, bmajor, cmajor;
139 
140 	error = 0;
141 	bmajor = -1;
142 	cmajor = -1;
143 
144 	switch (cmd) {
145 	case MOD_LOAD:
146 		devfs_clone_bitmap_init(&dm_minor_bitmap);
147 		dm_doinit();
148 		kprintf("Device Mapper version %d.%d.%d loaded\n",
149 		    DM_VERSION_MAJOR, DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL);
150 		break;
151 
152 	case MOD_UNLOAD:
153 		/*
154 		 * Disable unloading of dm module if there are any devices
155 		 * defined in driver. This is probably too strong we need
156 		 * to disable auto-unload only if there is mounted dm device
157 		 * present.
158 		 */
159 		if (dm_dev_counter > 0)
160 			return EBUSY;
161 
162 		error = dmdestroy();
163 		if (error)
164 			break;
165 		kprintf("Device Mapper unloaded\n");
166 		break;
167 
168 	default:
169 		break;
170 	}
171 
172 	return error;
173 }
174 
175 /*
176  * dm_detach:
177  *
178  *	Autoconfiguration detach function for pseudo-device glue.
179  * This routine is called by dm_ioctl::dm_dev_remove_ioctl and by autoconf to
180  * remove devices created in device-mapper.
181  */
182 int
183 dm_detach(dm_dev_t *dmv)
184 {
185 	int minor;
186 
187 	disable_dev(dmv);
188 
189 	/* Destroy active table first.  */
190 	dm_table_destroy(&dmv->table_head, DM_TABLE_ACTIVE);
191 
192 	/* Destroy inactive table if exits, too. */
193 	dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
194 
195 	dm_table_head_destroy(&dmv->table_head);
196 
197 	minor = dkunit(dmv->devt);
198 	disk_destroy(dmv->diskp);
199 	devstat_remove_entry(&dmv->stats);
200 
201 	release_dev(dmv->devt);
202 	devfs_clone_bitmap_put(&dm_minor_bitmap, minor);
203 
204 	/* Destroy device */
205 	(void)dm_dev_free(dmv);
206 
207 	/* Decrement device counter After removing device */
208 	--dm_dev_counter; /* XXX: was atomic 64 */
209 
210 	return 0;
211 }
212 
213 static void
214 dm_doinit(void)
215 {
216 	dm_target_init();
217 	dm_dev_init();
218 	dm_pdev_init();
219 	dmcdev = make_dev(&dm_ops, 0, UID_ROOT, GID_OPERATOR, 0640, "mapper/control");
220 }
221 
222 /* Destroy routine */
223 static int
224 dmdestroy(void)
225 {
226 	destroy_dev(dmcdev);
227 
228 	dm_dev_destroy();
229 	dm_pdev_destroy();
230 	dm_target_destroy();
231 
232 	return 0;
233 }
234 
235 static int
236 dmopen(struct dev_open_args *ap)
237 {
238 	cdev_t dev = ap->a_head.a_dev;
239 	dm_dev_t *dmv;
240 
241 	/* Shortcut for the control device */
242 	if (minor(dev) == 0)
243 		return 0;
244 
245 	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
246 		return ENXIO;
247 
248 	dmv->is_open = 1;
249 	dm_dev_unbusy(dmv);
250 
251 	aprint_debug("dm open routine called %" PRIu32 "\n",
252 	    minor(ap->a_head.a_dev));
253 	return 0;
254 }
255 
256 static int
257 dmclose(struct dev_close_args *ap)
258 {
259 	cdev_t dev = ap->a_head.a_dev;
260 	dm_dev_t *dmv;
261 
262 	/* Shortcut for the control device */
263 	if (minor(dev) == 0)
264 		return 0;
265 
266 	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
267 		return ENXIO;
268 
269 	dmv->is_open = 0;
270 	dm_dev_unbusy(dmv);
271 
272 	aprint_debug("dm close routine called %" PRIu32 "\n",
273 	    minor(ap->a_head.a_dev));
274 	return 0;
275 }
276 
277 
278 static int
279 dmioctl(struct dev_ioctl_args *ap)
280 {
281 	cdev_t dev = ap->a_head.a_dev;
282 	u_long cmd = ap->a_cmd;
283 	void *data = ap->a_data;
284 
285 	int r, err;
286 	prop_dictionary_t dm_dict_in;
287 
288 	err = r = 0;
289 
290 	aprint_debug("dmioctl called\n");
291 
292 	KKASSERT(data != NULL);
293 
294 	if (( r = disk_ioctl_switch(dev, cmd, data)) == ENOTTY) {
295 		struct plistref *pref = (struct plistref *) data;
296 
297 		/* Check if we were called with NETBSD_DM_IOCTL ioctl
298 		   otherwise quit. */
299 		if ((r = dm_ioctl_switch(cmd)) != 0)
300 			return r;
301 
302 		if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0)
303 			return r;
304 
305 		if ((r = dm_check_version(dm_dict_in)) != 0)
306 			goto cleanup_exit;
307 
308 		/* run ioctl routine */
309 		if ((err = dm_cmd_to_fun(dm_dict_in)) != 0)
310 			goto cleanup_exit;
311 
312 cleanup_exit:
313 		r = prop_dictionary_copyout_ioctl(pref, cmd, dm_dict_in);
314 		prop_object_release(dm_dict_in);
315 	}
316 
317 	/*
318 	 * Return the error of the actual command if one one has
319 	 * happened. Otherwise return 'r' which indicates errors
320 	 * that occurred during helper operations.
321 	 */
322 	return (err != 0)?err:r;
323 }
324 
325 /*
326  * Translate command sent from libdevmapper to func.
327  */
328 static int
329 dm_cmd_to_fun(prop_dictionary_t dm_dict){
330 	int i, r;
331 	prop_string_t command;
332 
333 	r = 0;
334 
335 	if ((command = prop_dictionary_get(dm_dict, DM_IOCTL_COMMAND)) == NULL)
336 		return EINVAL;
337 
338 	for(i = 0; cmd_fn[i].cmd != NULL; i++)
339 		if (prop_string_equals_cstring(command, cmd_fn[i].cmd))
340 			break;
341 
342 	if (cmd_fn[i].cmd == NULL)
343 		return EINVAL;
344 
345 	aprint_debug("ioctl %s called\n", cmd_fn[i].cmd);
346 	r = cmd_fn[i].fn(dm_dict);
347 
348 	return r;
349 }
350 
351 /* Call apropriate ioctl handler function. */
352 static int
353 dm_ioctl_switch(u_long cmd)
354 {
355 
356 	switch(cmd) {
357 
358 	case NETBSD_DM_IOCTL:
359 		aprint_debug("dm NetBSD_DM_IOCTL called\n");
360 		break;
361 	default:
362 		 aprint_debug("dm unknown ioctl called\n");
363 		 return ENOTTY;
364 		 break; /* NOT REACHED */
365 	}
366 
367 	 return 0;
368 }
369 
370  /*
371   * Check for disk specific ioctls.
372   */
373 
374 static int
375 disk_ioctl_switch(cdev_t dev, u_long cmd, void *data)
376 {
377 	dm_dev_t *dmv;
378 
379 	/* disk ioctls make sense only on block devices */
380 	if (minor(dev) == 0)
381 		return ENOTTY;
382 
383 	switch(cmd) {
384 	case DIOCGPART:
385 	{
386 		struct partinfo *dpart;
387 		u_int64_t size;
388 		dpart = (void *)data;
389 		bzero(dpart, sizeof(*dpart));
390 
391 		if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
392 			return ENODEV;
393 		if (dmv->diskp->d_info.d_media_blksize == 0) {
394 			dm_dev_unbusy(dmv);
395 			return ENOTSUP;
396 		} else {
397 			size = dm_table_size(&dmv->table_head);
398 			dpart->media_offset  = 0;
399 			dpart->media_size    = size * DEV_BSIZE;
400 			dpart->media_blocks  = size;
401 			dpart->media_blksize = DEV_BSIZE;
402 			dpart->fstype = FS_BSDFFS;
403 		}
404 		dm_dev_unbusy(dmv);
405 		break;
406 	}
407 
408 	default:
409 		aprint_debug("unknown disk_ioctl called\n");
410 		return ENOTTY;
411 		break; /* NOT REACHED */
412 	}
413 
414 	return 0;
415 }
416 
417 /*
418  * Do all IO operations on dm logical devices.
419  */
420 static int
421 dmstrategy(struct dev_strategy_args *ap)
422 {
423 	cdev_t dev = ap->a_head.a_dev;
424 	struct bio *bio = ap->a_bio;
425 	struct buf *bp = bio->bio_buf;
426 	int bypass;
427 
428 	dm_dev_t *dmv;
429 	dm_table_t  *tbl;
430 	dm_table_entry_t *table_en;
431 	struct buf *nestbuf;
432 
433 	uint32_t dev_type;
434 
435 	uint64_t buf_start, buf_len, issued_len;
436 	uint64_t table_start, table_end;
437 	uint64_t start, end;
438 
439 	buf_start = bio->bio_offset;
440 	buf_len = bp->b_bcount;
441 
442 	tbl = NULL;
443 
444 	table_end = 0;
445 	dev_type = 0;
446 	issued_len = 0;
447 
448 	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) {
449 		bp->b_error = EIO;
450 		bp->b_resid = bp->b_bcount;
451 		biodone(bio);
452 		return 0;
453 	}
454 
455 	switch(bp->b_cmd) {
456 	case BUF_CMD_READ:
457 	case BUF_CMD_WRITE:
458 	case BUF_CMD_FREEBLKS:
459 		bypass = 0;
460 		break;
461 	case BUF_CMD_FLUSH:
462 		bypass = 1;
463 		KKASSERT(buf_len == 0);
464 		break;
465 	default:
466 		dm_dev_unbusy(dmv);
467 		bp->b_error = EIO;
468 		bp->b_resid = bp->b_bcount;
469 		biodone(bio);
470 		return 0;
471 	}
472 
473 	if (bypass == 0 &&
474 	    bounds_check_with_mediasize(bio, DEV_BSIZE,
475 					dm_table_size(&dmv->table_head)) <= 0) {
476 		dm_dev_unbusy(dmv);
477 		bp->b_resid = bp->b_bcount;
478 		biodone(bio);
479 		return 0;
480 	}
481 
482 	/* Select active table */
483 	tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
484 
485 	nestiobuf_init(bio);
486 	devstat_start_transaction(&dmv->stats);
487 
488 	/*
489 	 * Find out what tables I want to select.
490 	 */
491 	SLIST_FOREACH(table_en, tbl, next) {
492 		/*
493 		 * I need need number of bytes not blocks.
494 		 */
495 		table_start = table_en->start * DEV_BSIZE;
496 		table_end = table_start + (table_en->length) * DEV_BSIZE;
497 
498 		/*
499 		 * Calculate the start and end
500 		 */
501 		start = MAX(table_start, buf_start);
502 		end = MIN(table_end, buf_start + buf_len);
503 
504 		aprint_debug("----------------------------------------\n");
505 		aprint_debug("table_start %010" PRIu64", table_end %010"
506 		    PRIu64 "\n", table_start, table_end);
507 		aprint_debug("buf_start %010" PRIu64", buf_len %010"
508 		    PRIu64"\n", buf_start, buf_len);
509 		aprint_debug("start-buf_start %010"PRIu64", end %010"
510 		    PRIu64"\n", start - buf_start, end);
511 		aprint_debug("start %010" PRIu64" , end %010"
512                     PRIu64"\n", start, end);
513 		aprint_debug("\n----------------------------------------\n");
514 
515 		if (bypass) {
516 			nestbuf = getpbuf(NULL);
517 			nestbuf->b_flags |= bio->bio_buf->b_flags & B_HASBOGUS;
518 
519 			nestiobuf_add(bio, nestbuf, 0, 0, &dmv->stats);
520 			nestbuf->b_bio1.bio_offset = 0;
521 			table_en->target->strategy(table_en, nestbuf);
522 		} else if (start < end) {
523 			nestbuf = getpbuf(NULL);
524 			nestbuf->b_flags |= bio->bio_buf->b_flags & B_HASBOGUS;
525 
526 			nestiobuf_add(bio, nestbuf,
527 				      start - buf_start, (end - start),
528 				      &dmv->stats);
529 			issued_len += end - start;
530 
531 			nestbuf->b_bio1.bio_offset = (start - table_start);
532 			table_en->target->strategy(table_en, nestbuf);
533 		}
534 	}
535 
536 	if (issued_len < buf_len)
537 		nestiobuf_error(bio, EINVAL);
538 	nestiobuf_start(bio);
539 	dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
540 	dm_dev_unbusy(dmv);
541 
542 	return 0;
543 }
544 
545 static int
546 dmdump(struct dev_dump_args *ap)
547 {
548 	cdev_t dev = ap->a_head.a_dev;
549 	dm_dev_t *dmv;
550 	dm_table_t  *tbl;
551 	dm_table_entry_t *table_en;
552 	uint32_t dev_type;
553 	uint64_t buf_start, buf_len, issued_len;
554 	uint64_t table_start, table_end;
555 	uint64_t start, end, data_offset;
556 	off_t offset;
557 	size_t length;
558 	int error = 0;
559 
560 	buf_start = ap->a_offset;
561 	buf_len = ap->a_length;
562 
563 	tbl = NULL;
564 
565 	table_end = 0;
566 	dev_type = 0;
567 	issued_len = 0;
568 
569 	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL) {
570 		return EIO;
571 	}
572 
573 	/* Select active table */
574 	tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
575 
576 
577 	/*
578 	 * Find out what tables I want to select.
579 	 */
580 	SLIST_FOREACH(table_en, tbl, next) {
581 		/*
582 		 * I need need number of bytes not blocks.
583 		 */
584 		table_start = table_en->start * DEV_BSIZE;
585 		table_end = table_start + (table_en->length) * DEV_BSIZE;
586 
587 		/*
588 		 * Calculate the start and end
589 		 */
590 		start = MAX(table_start, buf_start);
591 		end = MIN(table_end, buf_start + buf_len);
592 
593 		if (ap->a_length == 0) {
594 			if (table_en->target->dump == NULL) {
595 				error = ENXIO;
596 				goto out;
597 			}
598 
599 			table_en->target->dump(table_en, NULL, 0, 0);
600 		} else if (start < end) {
601 			data_offset = start - buf_start;
602 			offset = start - table_start;
603 			length = end - start;
604 
605 			if (table_en->target->dump == NULL) {
606 				error = ENXIO;
607 				goto out;
608 			}
609 
610 			table_en->target->dump(table_en,
611 			    (char *)ap->a_virtual + data_offset,
612 			    length, offset);
613 
614 			issued_len += end - start;
615 		}
616 	}
617 
618 	if (issued_len < buf_len)
619 		error = EINVAL;
620 
621 out:
622 	dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
623 	dm_dev_unbusy(dmv);
624 
625 	return error;
626 }
627 
628 static int
629 dmsize(struct dev_psize_args *ap)
630 {
631 	cdev_t dev = ap->a_head.a_dev;
632 	dm_dev_t *dmv;
633 	uint64_t size;
634 
635 	size = 0;
636 
637 	if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
638 			return ENOENT;
639 
640 	size = dm_table_size(&dmv->table_head);
641 	dm_dev_unbusy(dmv);
642 
643 	ap->a_result = (int64_t)size;
644 
645 	return 0;
646 }
647 
648 #if 0
649 static void
650 dmminphys(struct buf *bp)
651 {
652 
653 	bp->b_bcount = MIN(bp->b_bcount, MAXPHYS);
654 }
655 #endif
656 
657 void
658 dmsetdiskinfo(struct disk *disk, dm_table_head_t *head)
659 {
660 	struct disk_info info;
661 	uint64_t dmp_size;
662 
663 	dmp_size = dm_table_size(head);
664 
665 	bzero(&info, sizeof(struct disk_info));
666 	info.d_media_blksize = DEV_BSIZE;
667 	info.d_media_blocks = dmp_size;
668 #if 0
669 	/* this is set by disk_setdiskinfo */
670 	info.d_media_size = dmp_size * DEV_BSIZE;
671 #endif
672 	info.d_dsflags = DSO_MBRQUIET | DSO_DEVICEMAPPER;
673 
674 	info.d_secpertrack = 32;
675 	info.d_nheads = 64;
676 	info.d_secpercyl = info.d_secpertrack * info.d_nheads;
677 	info.d_ncylinders = dmp_size / info.d_secpercyl;
678 
679 	disk_setdiskinfo(disk, &info);
680 }
681 
682 prop_dictionary_t
683 dmgetdiskinfo(struct disk *disk)
684 {
685 	prop_dictionary_t disk_info, geom;
686 	struct disk_info *pinfo;
687 
688 	pinfo = &disk->d_info;
689 
690 	disk_info = prop_dictionary_create();
691 	geom = prop_dictionary_create();
692 
693 	prop_dictionary_set_cstring_nocopy(disk_info, "type", "ESDI");
694 	prop_dictionary_set_uint64(geom, "sectors-per-unit", pinfo->d_media_blocks);
695 	prop_dictionary_set_uint32(geom, "sector-size",
696 	    DEV_BSIZE /* XXX 512? */);
697 	prop_dictionary_set_uint32(geom, "sectors-per-track", 32);
698 	prop_dictionary_set_uint32(geom, "tracks-per-cylinder", 64);
699 	prop_dictionary_set_uint32(geom, "cylinders-per-unit",
700 	    pinfo->d_media_blocks / 2048);
701 	prop_dictionary_set(disk_info, "geometry", geom);
702 	prop_object_release(geom);
703 
704 	return disk_info;
705 }
706 
707 void
708 dmgetproperties(struct disk *disk, dm_table_head_t *head)
709 {
710 #if 0
711 	prop_dictionary_t disk_info, odisk_info, geom;
712 	int dmp_size;
713 
714 	dmp_size = dm_table_size(head);
715 	disk_info = prop_dictionary_create();
716 	geom = prop_dictionary_create();
717 
718 	prop_dictionary_set_cstring_nocopy(disk_info, "type", "ESDI");
719 	prop_dictionary_set_uint64(geom, "sectors-per-unit", dmp_size);
720 	prop_dictionary_set_uint32(geom, "sector-size",
721 	    DEV_BSIZE /* XXX 512? */);
722 	prop_dictionary_set_uint32(geom, "sectors-per-track", 32);
723 	prop_dictionary_set_uint32(geom, "tracks-per-cylinder", 64);
724 	prop_dictionary_set_uint32(geom, "cylinders-per-unit", dmp_size / 2048);
725 	prop_dictionary_set(disk_info, "geometry", geom);
726 	prop_object_release(geom);
727 
728 	odisk_info = disk->dk_info;
729 	disk->dk_info = disk_info;
730 
731 	if (odisk_info != NULL)
732 		prop_object_release(odisk_info);
733 #endif
734 }
735 
736 TUNABLE_INT("debug.dm_debug", &dm_debug_level);
737 SYSCTL_INT(_debug, OID_AUTO, dm_debug, CTLFLAG_RW, &dm_debug_level,
738 	       0, "Eanble device mapper debugging");
739 
740