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