xref: /freebsd/sys/geom/mountver/g_mountver.c (revision 50896984cd36c1724905e41819f5236399a4972d)
1 /*-
2  * Copyright (c) 2010 Edward Tomasz Napierala <trasz@FreeBSD.org>
3  * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/module.h>
35 #include <sys/lock.h>
36 #include <sys/mutex.h>
37 #include <sys/bio.h>
38 #include <sys/disk.h>
39 #include <sys/proc.h>
40 #include <sys/sbuf.h>
41 #include <sys/sysctl.h>
42 #include <sys/malloc.h>
43 #include <sys/eventhandler.h>
44 #include <geom/geom.h>
45 #include <geom/mountver/g_mountver.h>
46 
47 
48 SYSCTL_DECL(_kern_geom);
49 static SYSCTL_NODE(_kern_geom, OID_AUTO, mountver, CTLFLAG_RW,
50     0, "GEOM_MOUNTVER stuff");
51 static u_int g_mountver_debug = 0;
52 static u_int g_mountver_check_ident = 1;
53 SYSCTL_UINT(_kern_geom_mountver, OID_AUTO, debug, CTLFLAG_RW,
54     &g_mountver_debug, 0, "Debug level");
55 SYSCTL_UINT(_kern_geom_mountver, OID_AUTO, check_ident, CTLFLAG_RW,
56     &g_mountver_check_ident, 0, "Check disk ident when reattaching");
57 
58 static eventhandler_tag g_mountver_pre_sync = NULL;
59 
60 static void g_mountver_queue(struct bio *bp);
61 static void g_mountver_orphan(struct g_consumer *cp);
62 static void g_mountver_resize(struct g_consumer *cp);
63 static int g_mountver_destroy(struct g_geom *gp, boolean_t force);
64 static g_taste_t g_mountver_taste;
65 static int g_mountver_destroy_geom(struct gctl_req *req, struct g_class *mp,
66     struct g_geom *gp);
67 static void g_mountver_config(struct gctl_req *req, struct g_class *mp,
68     const char *verb);
69 static void g_mountver_dumpconf(struct sbuf *sb, const char *indent,
70     struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp);
71 static void g_mountver_init(struct g_class *mp);
72 static void g_mountver_fini(struct g_class *mp);
73 
74 struct g_class g_mountver_class = {
75 	.name = G_MOUNTVER_CLASS_NAME,
76 	.version = G_VERSION,
77 	.ctlreq = g_mountver_config,
78 	.taste = g_mountver_taste,
79 	.destroy_geom = g_mountver_destroy_geom,
80 	.init = g_mountver_init,
81 	.fini = g_mountver_fini
82 };
83 
84 static void
85 g_mountver_done(struct bio *bp)
86 {
87 	struct g_geom *gp;
88 	struct bio *pbp;
89 
90 	if (bp->bio_error != ENXIO) {
91 		g_std_done(bp);
92 		return;
93 	}
94 
95 	/*
96 	 * When the device goes away, it's possible that few requests
97 	 * will be completed with ENXIO before g_mountver_orphan()
98 	 * gets called.  To work around that, we have to queue requests
99 	 * that failed with ENXIO, in order to send them later.
100 	 */
101 	gp = bp->bio_from->geom;
102 
103 	pbp = bp->bio_parent;
104 	KASSERT(pbp->bio_to == LIST_FIRST(&gp->provider),
105 	    ("parent request was for someone else"));
106 	g_destroy_bio(bp);
107 	pbp->bio_inbed++;
108 	g_mountver_queue(pbp);
109 }
110 
111 static void
112 g_mountver_send(struct bio *bp)
113 {
114 	struct g_geom *gp;
115 	struct bio *cbp;
116 
117 	gp = bp->bio_to->geom;
118 
119 	cbp = g_clone_bio(bp);
120 	if (cbp == NULL) {
121 		g_io_deliver(bp, ENOMEM);
122 		return;
123 	}
124 
125 	cbp->bio_done = g_mountver_done;
126 	g_io_request(cbp, LIST_FIRST(&gp->consumer));
127 }
128 
129 static void
130 g_mountver_queue(struct bio *bp)
131 {
132 	struct g_mountver_softc *sc;
133 	struct g_geom *gp;
134 
135 	gp = bp->bio_to->geom;
136 	sc = gp->softc;
137 
138 	mtx_lock(&sc->sc_mtx);
139 	TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue);
140 	mtx_unlock(&sc->sc_mtx);
141 }
142 
143 static void
144 g_mountver_send_queued(struct g_geom *gp)
145 {
146 	struct g_mountver_softc *sc;
147 	struct bio *bp;
148 
149 	sc = gp->softc;
150 
151 	mtx_lock(&sc->sc_mtx);
152 	while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL) {
153 		TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue);
154 		G_MOUNTVER_LOGREQ(bp, "Sending queued request.");
155 		g_mountver_send(bp);
156 	}
157 	mtx_unlock(&sc->sc_mtx);
158 }
159 
160 static void
161 g_mountver_discard_queued(struct g_geom *gp)
162 {
163 	struct g_mountver_softc *sc;
164 	struct bio *bp;
165 
166 	sc = gp->softc;
167 
168 	mtx_lock(&sc->sc_mtx);
169 	while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL) {
170 		TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue);
171 		G_MOUNTVER_LOGREQ(bp, "Discarding queued request.");
172 		g_io_deliver(bp, ENXIO);
173 	}
174 	mtx_unlock(&sc->sc_mtx);
175 }
176 
177 static void
178 g_mountver_start(struct bio *bp)
179 {
180 	struct g_mountver_softc *sc;
181 	struct g_geom *gp;
182 
183 	gp = bp->bio_to->geom;
184 	sc = gp->softc;
185 	G_MOUNTVER_LOGREQ(bp, "Request received.");
186 
187 	/*
188 	 * It is possible that some bios were returned with ENXIO, even though
189 	 * orphaning didn't happen yet.  In that case, queue all subsequent
190 	 * requests in order to maintain ordering.
191 	 */
192 	if (sc->sc_orphaned || !TAILQ_EMPTY(&sc->sc_queue)) {
193 		if (sc->sc_shutting_down) {
194 			G_MOUNTVER_LOGREQ(bp, "Discarding request due to shutdown.");
195 			g_io_deliver(bp, ENXIO);
196 			return;
197 		}
198 		G_MOUNTVER_LOGREQ(bp, "Queueing request.");
199 		g_mountver_queue(bp);
200 		if (!sc->sc_orphaned)
201 			g_mountver_send_queued(gp);
202 	} else {
203 		G_MOUNTVER_LOGREQ(bp, "Sending request.");
204 		g_mountver_send(bp);
205 	}
206 }
207 
208 static int
209 g_mountver_access(struct g_provider *pp, int dr, int dw, int de)
210 {
211 	struct g_mountver_softc *sc;
212 	struct g_geom *gp;
213 	struct g_consumer *cp;
214 
215 	g_topology_assert();
216 
217 	gp = pp->geom;
218 	cp = LIST_FIRST(&gp->consumer);
219 	sc = gp->softc;
220 	if (sc == NULL && dr <= 0 && dw <= 0 && de <= 0)
221 		return (0);
222 	KASSERT(sc != NULL, ("Trying to access withered provider \"%s\".", pp->name));
223 
224 	sc->sc_access_r += dr;
225 	sc->sc_access_w += dw;
226 	sc->sc_access_e += de;
227 
228 	if (sc->sc_orphaned)
229 		return (0);
230 
231 	return (g_access(cp, dr, dw, de));
232 }
233 
234 static int
235 g_mountver_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp)
236 {
237 	struct g_mountver_softc *sc;
238 	struct g_geom *gp;
239 	struct g_provider *newpp;
240 	struct g_consumer *cp;
241 	char name[64];
242 	int error;
243 	int identsize = DISK_IDENT_SIZE;
244 
245 	g_topology_assert();
246 
247 	gp = NULL;
248 	newpp = NULL;
249 	cp = NULL;
250 
251 	snprintf(name, sizeof(name), "%s%s", pp->name, G_MOUNTVER_SUFFIX);
252 	LIST_FOREACH(gp, &mp->geom, geom) {
253 		if (strcmp(gp->name, name) == 0) {
254 			gctl_error(req, "Provider %s already exists.", name);
255 			return (EEXIST);
256 		}
257 	}
258 	gp = g_new_geomf(mp, "%s", name);
259 	sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
260 	mtx_init(&sc->sc_mtx, "gmountver", NULL, MTX_DEF);
261 	TAILQ_INIT(&sc->sc_queue);
262 	sc->sc_provider_name = strdup(pp->name, M_GEOM);
263 	gp->softc = sc;
264 	gp->start = g_mountver_start;
265 	gp->orphan = g_mountver_orphan;
266 	gp->resize = g_mountver_resize;
267 	gp->access = g_mountver_access;
268 	gp->dumpconf = g_mountver_dumpconf;
269 
270 	newpp = g_new_providerf(gp, "%s", gp->name);
271 	newpp->mediasize = pp->mediasize;
272 	newpp->sectorsize = pp->sectorsize;
273 
274 	cp = g_new_consumer(gp);
275 	error = g_attach(cp, pp);
276 	if (error != 0) {
277 		gctl_error(req, "Cannot attach to provider %s.", pp->name);
278 		goto fail;
279 	}
280 	error = g_access(cp, 1, 0, 0);
281 	if (error != 0) {
282 		gctl_error(req, "Cannot access provider %s.", pp->name);
283 		goto fail;
284 	}
285 	error = g_io_getattr("GEOM::ident", cp, &identsize, sc->sc_ident);
286 	g_access(cp, -1, 0, 0);
287 	if (error != 0) {
288 		if (g_mountver_check_ident) {
289 			gctl_error(req, "Cannot get disk ident from %s; error = %d.", pp->name, error);
290 			goto fail;
291 		}
292 
293 		G_MOUNTVER_DEBUG(0, "Cannot get disk ident from %s; error = %d.", pp->name, error);
294 		sc->sc_ident[0] = '\0';
295 	}
296 
297 	g_error_provider(newpp, 0);
298 	G_MOUNTVER_DEBUG(0, "Device %s created.", gp->name);
299 	return (0);
300 fail:
301 	g_free(sc->sc_provider_name);
302 	if (cp->provider != NULL)
303 		g_detach(cp);
304 	g_destroy_consumer(cp);
305 	g_destroy_provider(newpp);
306 	g_free(gp->softc);
307 	g_destroy_geom(gp);
308 	return (error);
309 }
310 
311 static int
312 g_mountver_destroy(struct g_geom *gp, boolean_t force)
313 {
314 	struct g_mountver_softc *sc;
315 	struct g_provider *pp;
316 
317 	g_topology_assert();
318 	if (gp->softc == NULL)
319 		return (ENXIO);
320 	sc = gp->softc;
321 	pp = LIST_FIRST(&gp->provider);
322 	if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
323 		if (force) {
324 			G_MOUNTVER_DEBUG(0, "Device %s is still open, so it "
325 			    "can't be definitely removed.", pp->name);
326 		} else {
327 			G_MOUNTVER_DEBUG(1, "Device %s is still open (r%dw%de%d).",
328 			    pp->name, pp->acr, pp->acw, pp->ace);
329 			return (EBUSY);
330 		}
331 	} else {
332 		G_MOUNTVER_DEBUG(0, "Device %s removed.", gp->name);
333 	}
334 	if (pp != NULL)
335 		g_wither_provider(pp, ENXIO);
336 	g_mountver_discard_queued(gp);
337 	g_free(sc->sc_provider_name);
338 	g_free(gp->softc);
339 	gp->softc = NULL;
340 	g_wither_geom(gp, ENXIO);
341 
342 	return (0);
343 }
344 
345 static int
346 g_mountver_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
347 {
348 
349 	return (g_mountver_destroy(gp, 0));
350 }
351 
352 static void
353 g_mountver_ctl_create(struct gctl_req *req, struct g_class *mp)
354 {
355 	struct g_provider *pp;
356 	const char *name;
357 	char param[16];
358 	int i, *nargs;
359 
360 	g_topology_assert();
361 
362 	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
363 	if (nargs == NULL) {
364 		gctl_error(req, "No '%s' argument", "nargs");
365 		return;
366 	}
367 	if (*nargs <= 0) {
368 		gctl_error(req, "Missing device(s).");
369 		return;
370 	}
371 	for (i = 0; i < *nargs; i++) {
372 		snprintf(param, sizeof(param), "arg%d", i);
373 		name = gctl_get_asciiparam(req, param);
374 		if (name == NULL) {
375 			gctl_error(req, "No 'arg%d' argument", i);
376 			return;
377 		}
378 		if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
379 			name += strlen("/dev/");
380 		pp = g_provider_by_name(name);
381 		if (pp == NULL) {
382 			G_MOUNTVER_DEBUG(1, "Provider %s is invalid.", name);
383 			gctl_error(req, "Provider %s is invalid.", name);
384 			return;
385 		}
386 		if (g_mountver_create(req, mp, pp) != 0)
387 			return;
388 	}
389 }
390 
391 static struct g_geom *
392 g_mountver_find_geom(struct g_class *mp, const char *name)
393 {
394 	struct g_geom *gp;
395 
396 	LIST_FOREACH(gp, &mp->geom, geom) {
397 		if (strcmp(gp->name, name) == 0)
398 			return (gp);
399 	}
400 	return (NULL);
401 }
402 
403 static void
404 g_mountver_ctl_destroy(struct gctl_req *req, struct g_class *mp)
405 {
406 	int *nargs, *force, error, i;
407 	struct g_geom *gp;
408 	const char *name;
409 	char param[16];
410 
411 	g_topology_assert();
412 
413 	nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
414 	if (nargs == NULL) {
415 		gctl_error(req, "No '%s' argument", "nargs");
416 		return;
417 	}
418 	if (*nargs <= 0) {
419 		gctl_error(req, "Missing device(s).");
420 		return;
421 	}
422 	force = gctl_get_paraml(req, "force", sizeof(*force));
423 	if (force == NULL) {
424 		gctl_error(req, "No 'force' argument");
425 		return;
426 	}
427 
428 	for (i = 0; i < *nargs; i++) {
429 		snprintf(param, sizeof(param), "arg%d", i);
430 		name = gctl_get_asciiparam(req, param);
431 		if (name == NULL) {
432 			gctl_error(req, "No 'arg%d' argument", i);
433 			return;
434 		}
435 		if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
436 			name += strlen("/dev/");
437 		gp = g_mountver_find_geom(mp, name);
438 		if (gp == NULL) {
439 			G_MOUNTVER_DEBUG(1, "Device %s is invalid.", name);
440 			gctl_error(req, "Device %s is invalid.", name);
441 			return;
442 		}
443 		error = g_mountver_destroy(gp, *force);
444 		if (error != 0) {
445 			gctl_error(req, "Cannot destroy device %s (error=%d).",
446 			    gp->name, error);
447 			return;
448 		}
449 	}
450 }
451 
452 static void
453 g_mountver_orphan(struct g_consumer *cp)
454 {
455 	struct g_mountver_softc *sc;
456 
457 	g_topology_assert();
458 
459 	sc = cp->geom->softc;
460 	sc->sc_orphaned = 1;
461 	if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
462 		g_access(cp, -cp->acr, -cp->acw, -cp->ace);
463 	g_detach(cp);
464 	G_MOUNTVER_DEBUG(0, "%s is offline.  Mount verification in progress.", sc->sc_provider_name);
465 }
466 
467 static void
468 g_mountver_resize(struct g_consumer *cp)
469 {
470 	struct g_geom *gp;
471 	struct g_provider *pp;
472 
473 	gp = cp->geom;
474 
475 	LIST_FOREACH(pp, &gp->provider, provider)
476 		g_resize_provider(pp, cp->provider->mediasize);
477 }
478 
479 static int
480 g_mountver_ident_matches(struct g_geom *gp)
481 {
482 	struct g_consumer *cp;
483 	struct g_mountver_softc *sc;
484 	char ident[DISK_IDENT_SIZE];
485 	int error, identsize = DISK_IDENT_SIZE;
486 
487 	sc = gp->softc;
488 	cp = LIST_FIRST(&gp->consumer);
489 
490 	if (g_mountver_check_ident == 0)
491 		return (0);
492 
493 	error = g_access(cp, 1, 0, 0);
494 	if (error != 0) {
495 		G_MOUNTVER_DEBUG(0, "Cannot access %s; "
496 		    "not attaching; error = %d.", gp->name, error);
497 		return (1);
498 	}
499 	error = g_io_getattr("GEOM::ident", cp, &identsize, ident);
500 	g_access(cp, -1, 0, 0);
501 	if (error != 0) {
502 		G_MOUNTVER_DEBUG(0, "Cannot get disk ident for %s; "
503 		    "not attaching; error = %d.", gp->name, error);
504 		return (1);
505 	}
506 	if (strcmp(ident, sc->sc_ident) != 0) {
507 		G_MOUNTVER_DEBUG(1, "Disk ident for %s (\"%s\") is different "
508 		    "from expected \"%s\", not attaching.", gp->name, ident,
509 		    sc->sc_ident);
510 		return (1);
511 	}
512 
513 	return (0);
514 }
515 
516 static struct g_geom *
517 g_mountver_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
518 {
519 	struct g_mountver_softc *sc;
520 	struct g_consumer *cp;
521 	struct g_geom *gp;
522 	int error;
523 
524 	g_topology_assert();
525 	g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
526 	G_MOUNTVER_DEBUG(2, "Tasting %s.", pp->name);
527 
528 	/*
529 	 * Let's check if device already exists.
530 	 */
531 	LIST_FOREACH(gp, &mp->geom, geom) {
532 		sc = gp->softc;
533 		if (sc == NULL)
534 			continue;
535 
536 		/* Already attached? */
537 		if (pp == LIST_FIRST(&gp->provider))
538 			return (NULL);
539 
540 		if (sc->sc_orphaned && strcmp(pp->name, sc->sc_provider_name) == 0)
541 			break;
542 	}
543 	if (gp == NULL)
544 		return (NULL);
545 
546 	cp = LIST_FIRST(&gp->consumer);
547 	g_attach(cp, pp);
548 	error = g_mountver_ident_matches(gp);
549 	if (error != 0) {
550 		g_detach(cp);
551 		return (NULL);
552 	}
553 	if (sc->sc_access_r > 0 || sc->sc_access_w > 0 || sc->sc_access_e > 0) {
554 		error = g_access(cp, sc->sc_access_r, sc->sc_access_w, sc->sc_access_e);
555 		if (error != 0) {
556 			G_MOUNTVER_DEBUG(0, "Cannot access %s; error = %d.", pp->name, error);
557 			g_detach(cp);
558 			return (NULL);
559 		}
560 	}
561 	g_mountver_send_queued(gp);
562 	sc->sc_orphaned = 0;
563 	G_MOUNTVER_DEBUG(0, "%s has completed mount verification.", sc->sc_provider_name);
564 
565 	return (gp);
566 }
567 
568 static void
569 g_mountver_config(struct gctl_req *req, struct g_class *mp, const char *verb)
570 {
571 	uint32_t *version;
572 
573 	g_topology_assert();
574 
575 	version = gctl_get_paraml(req, "version", sizeof(*version));
576 	if (version == NULL) {
577 		gctl_error(req, "No '%s' argument.", "version");
578 		return;
579 	}
580 	if (*version != G_MOUNTVER_VERSION) {
581 		gctl_error(req, "Userland and kernel parts are out of sync.");
582 		return;
583 	}
584 
585 	if (strcmp(verb, "create") == 0) {
586 		g_mountver_ctl_create(req, mp);
587 		return;
588 	} else if (strcmp(verb, "destroy") == 0) {
589 		g_mountver_ctl_destroy(req, mp);
590 		return;
591 	}
592 
593 	gctl_error(req, "Unknown verb.");
594 }
595 
596 static void
597 g_mountver_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
598     struct g_consumer *cp, struct g_provider *pp)
599 {
600 	struct g_mountver_softc *sc;
601 
602 	if (pp != NULL || cp != NULL)
603 		return;
604 
605 	sc = gp->softc;
606 	sbuf_printf(sb, "%s<State>%s</State>\n", indent,
607 	    sc->sc_orphaned ? "OFFLINE" : "ONLINE");
608 	sbuf_printf(sb, "%s<Provider-Name>%s</Provider-Name>\n", indent, sc->sc_provider_name);
609 	sbuf_printf(sb, "%s<Disk-Ident>%s</Disk-Ident>\n", indent, sc->sc_ident);
610 }
611 
612 static void
613 g_mountver_shutdown_pre_sync(void *arg, int howto)
614 {
615 	struct g_mountver_softc *sc;
616 	struct g_class *mp;
617 	struct g_geom *gp, *gp2;
618 
619 	mp = arg;
620 	g_topology_lock();
621 	LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) {
622 		if (gp->softc == NULL)
623 			continue;
624 		sc = gp->softc;
625 		sc->sc_shutting_down = 1;
626 		if (sc->sc_orphaned)
627 			g_mountver_destroy(gp, 1);
628 	}
629 	g_topology_unlock();
630 }
631 
632 static void
633 g_mountver_init(struct g_class *mp)
634 {
635 
636 	g_mountver_pre_sync = EVENTHANDLER_REGISTER(shutdown_pre_sync,
637 	    g_mountver_shutdown_pre_sync, mp, SHUTDOWN_PRI_FIRST);
638 	if (g_mountver_pre_sync == NULL)
639 		G_MOUNTVER_DEBUG(0, "Warning! Cannot register shutdown event.");
640 }
641 
642 static void
643 g_mountver_fini(struct g_class *mp)
644 {
645 
646 	if (g_mountver_pre_sync != NULL)
647 		EVENTHANDLER_DEREGISTER(shutdown_pre_sync, g_mountver_pre_sync);
648 }
649 
650 DECLARE_GEOM_CLASS(g_mountver_class, g_mountver);
651