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