xref: /onnv-gate/usr/src/uts/common/fs/zfs/vdev_missing.c (revision 789:b348f31ed315)
1*789Sahrens /*
2*789Sahrens  * CDDL HEADER START
3*789Sahrens  *
4*789Sahrens  * The contents of this file are subject to the terms of the
5*789Sahrens  * Common Development and Distribution License, Version 1.0 only
6*789Sahrens  * (the "License").  You may not use this file except in compliance
7*789Sahrens  * with the License.
8*789Sahrens  *
9*789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*789Sahrens  * or http://www.opensolaris.org/os/licensing.
11*789Sahrens  * See the License for the specific language governing permissions
12*789Sahrens  * and limitations under the License.
13*789Sahrens  *
14*789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
15*789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
17*789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
18*789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
19*789Sahrens  *
20*789Sahrens  * CDDL HEADER END
21*789Sahrens  */
22*789Sahrens /*
23*789Sahrens  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*789Sahrens  * Use is subject to license terms.
25*789Sahrens  */
26*789Sahrens 
27*789Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*789Sahrens 
29*789Sahrens /*
30*789Sahrens  * The 'missing' vdev is a special vdev type used only during import.  It
31*789Sahrens  * signifies a placeholder in the root vdev for some vdev that we know is
32*789Sahrens  * missing.  We pass it down to the kernel to allow the rest of the
33*789Sahrens  * configuration to parsed and an attempt made to open all available devices.
34*789Sahrens  * Because its GUID is always 0, we know that the guid sum will mismatch and we
35*789Sahrens  * won't be able to open the pool anyway.
36*789Sahrens  */
37*789Sahrens 
38*789Sahrens #include <sys/zfs_context.h>
39*789Sahrens #include <sys/spa.h>
40*789Sahrens #include <sys/vdev_impl.h>
41*789Sahrens #include <sys/fs/zfs.h>
42*789Sahrens #include <sys/zio.h>
43*789Sahrens 
44*789Sahrens /* ARGSUSED */
45*789Sahrens static int
46*789Sahrens vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
47*789Sahrens {
48*789Sahrens 	/*
49*789Sahrens 	 * Really this should just fail.  But then the root vdev will be in the
50*789Sahrens 	 * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is
51*789Sahrens 	 * VDEV_AUX_BAD_GUID_SUM.  So we pretend to succeed, knowing that we
52*789Sahrens 	 * will fail the GUID sum check before ever trying to open the pool.
53*789Sahrens 	 */
54*789Sahrens 	*psize = SPA_MINDEVSIZE;
55*789Sahrens 	*ashift = SPA_MINBLOCKSHIFT;
56*789Sahrens 	return (0);
57*789Sahrens }
58*789Sahrens 
59*789Sahrens /* ARGSUSED */
60*789Sahrens static void
61*789Sahrens vdev_missing_close(vdev_t *vd)
62*789Sahrens {
63*789Sahrens }
64*789Sahrens 
65*789Sahrens /* ARGSUSED */
66*789Sahrens static void
67*789Sahrens vdev_missing_io_start(zio_t *zio)
68*789Sahrens {
69*789Sahrens 	zio->io_error = ENOTSUP;
70*789Sahrens 	zio_next_stage_async(zio);
71*789Sahrens }
72*789Sahrens 
73*789Sahrens /* ARGSUSED */
74*789Sahrens static void
75*789Sahrens vdev_missing_io_done(zio_t *zio)
76*789Sahrens {
77*789Sahrens 	zio_next_stage(zio);
78*789Sahrens }
79*789Sahrens 
80*789Sahrens vdev_ops_t vdev_missing_ops = {
81*789Sahrens 	vdev_missing_open,
82*789Sahrens 	vdev_missing_close,
83*789Sahrens 	vdev_default_asize,
84*789Sahrens 	vdev_missing_io_start,
85*789Sahrens 	vdev_missing_io_done,
86*789Sahrens 	NULL,
87*789Sahrens 	VDEV_TYPE_MISSING,	/* name of this vdev type */
88*789Sahrens 	B_TRUE			/* leaf vdev */
89*789Sahrens };
90