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