xref: /onnv-gate/usr/src/uts/common/fs/zfs/vdev_missing.c (revision 7754:b80e4842ad54)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
55329Sgw25295  * Common Development and Distribution License (the "License").
65329Sgw25295  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
22*7754SJeff.Bonwick@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23789Sahrens  * Use is subject to license terms.
24789Sahrens  */
25789Sahrens 
26789Sahrens /*
27789Sahrens  * The 'missing' vdev is a special vdev type used only during import.  It
28789Sahrens  * signifies a placeholder in the root vdev for some vdev that we know is
29789Sahrens  * missing.  We pass it down to the kernel to allow the rest of the
30789Sahrens  * configuration to parsed and an attempt made to open all available devices.
31789Sahrens  * Because its GUID is always 0, we know that the guid sum will mismatch and we
32789Sahrens  * won't be able to open the pool anyway.
33789Sahrens  */
34789Sahrens 
35789Sahrens #include <sys/zfs_context.h>
36789Sahrens #include <sys/spa.h>
37789Sahrens #include <sys/vdev_impl.h>
38789Sahrens #include <sys/fs/zfs.h>
39789Sahrens #include <sys/zio.h>
40789Sahrens 
41789Sahrens /* ARGSUSED */
42789Sahrens static int
43789Sahrens vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
44789Sahrens {
45789Sahrens 	/*
46789Sahrens 	 * Really this should just fail.  But then the root vdev will be in the
47789Sahrens 	 * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is
48789Sahrens 	 * VDEV_AUX_BAD_GUID_SUM.  So we pretend to succeed, knowing that we
49789Sahrens 	 * will fail the GUID sum check before ever trying to open the pool.
50789Sahrens 	 */
51789Sahrens 	*psize = SPA_MINDEVSIZE;
52789Sahrens 	*ashift = SPA_MINBLOCKSHIFT;
53789Sahrens 	return (0);
54789Sahrens }
55789Sahrens 
56789Sahrens /* ARGSUSED */
57789Sahrens static void
58789Sahrens vdev_missing_close(vdev_t *vd)
59789Sahrens {
60789Sahrens }
61789Sahrens 
62789Sahrens /* ARGSUSED */
635530Sbonwick static int
64789Sahrens vdev_missing_io_start(zio_t *zio)
65789Sahrens {
66789Sahrens 	zio->io_error = ENOTSUP;
675530Sbonwick 	return (ZIO_PIPELINE_CONTINUE);
68789Sahrens }
69789Sahrens 
70789Sahrens /* ARGSUSED */
71*7754SJeff.Bonwick@Sun.COM static void
72789Sahrens vdev_missing_io_done(zio_t *zio)
73789Sahrens {
745329Sgw25295 }
755329Sgw25295 
76789Sahrens vdev_ops_t vdev_missing_ops = {
77789Sahrens 	vdev_missing_open,
78789Sahrens 	vdev_missing_close,
79789Sahrens 	vdev_default_asize,
80789Sahrens 	vdev_missing_io_start,
81789Sahrens 	vdev_missing_io_done,
82789Sahrens 	NULL,
83789Sahrens 	VDEV_TYPE_MISSING,	/* name of this vdev type */
84789Sahrens 	B_TRUE			/* leaf vdev */
85789Sahrens };
86