]> git.proxmox.com Git - mirror_zfs.git/blame - module/zfs/vdev_missing.c
vdev_disk: reorganise vdev_disk_io_start
[mirror_zfs.git] / module / zfs / vdev_missing.c
CommitLineData
34dc7c2f
BB
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d3ba0bf 9 * or https://opensource.org/licenses/CDDL-1.0.
34dc7c2f
BB
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
428870ff 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
34dc7c2f
BB
23 * Use is subject to license terms.
24 */
25
1bd201e7 26/*
619f0976 27 * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
1bd201e7
CS
28 */
29
34dc7c2f
BB
30/*
31 * The 'missing' vdev is a special vdev type used only during import. It
32 * signifies a placeholder in the root vdev for some vdev that we know is
33 * missing. We pass it down to the kernel to allow the rest of the
34 * configuration to parsed and an attempt made to open all available devices.
35 * Because its GUID is always 0, we know that the guid sum will mismatch and we
36 * won't be able to open the pool anyway.
37 */
38
39#include <sys/zfs_context.h>
40#include <sys/spa.h>
41#include <sys/vdev_impl.h>
42#include <sys/fs/zfs.h>
43#include <sys/zio.h>
44
34dc7c2f 45static int
1bd201e7 46vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
6fe3498c 47 uint64_t *ashift, uint64_t *pshift)
34dc7c2f
BB
48{
49 /*
50 * Really this should just fail. But then the root vdev will be in the
51 * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is
52 * VDEV_AUX_BAD_GUID_SUM. So we pretend to succeed, knowing that we
53 * will fail the GUID sum check before ever trying to open the pool.
54 */
14e4e3cb 55 (void) vd;
428870ff 56 *psize = 0;
1bd201e7 57 *max_psize = 0;
428870ff 58 *ashift = 0;
6fe3498c 59 *pshift = 0;
34dc7c2f
BB
60 return (0);
61}
62
34dc7c2f
BB
63static void
64vdev_missing_close(vdev_t *vd)
65{
14e4e3cb 66 (void) vd;
34dc7c2f
BB
67}
68
98b25418 69static void
34dc7c2f
BB
70vdev_missing_io_start(zio_t *zio)
71{
2e528b49 72 zio->io_error = SET_ERROR(ENOTSUP);
98b25418 73 zio_execute(zio);
34dc7c2f
BB
74}
75
b128c09f 76static void
34dc7c2f
BB
77vdev_missing_io_done(zio_t *zio)
78{
14e4e3cb 79 (void) zio;
34dc7c2f
BB
80}
81
82vdev_ops_t vdev_missing_ops = {
b2255edc
BB
83 .vdev_op_init = NULL,
84 .vdev_op_fini = NULL,
a64f8276
I
85 .vdev_op_open = vdev_missing_open,
86 .vdev_op_close = vdev_missing_close,
87 .vdev_op_asize = vdev_default_asize,
b2255edc
BB
88 .vdev_op_min_asize = vdev_default_min_asize,
89 .vdev_op_min_alloc = NULL,
a64f8276
I
90 .vdev_op_io_start = vdev_missing_io_start,
91 .vdev_op_io_done = vdev_missing_io_done,
92 .vdev_op_state_change = NULL,
93 .vdev_op_need_resilver = NULL,
94 .vdev_op_hold = NULL,
95 .vdev_op_rele = NULL,
96 .vdev_op_remap = NULL,
97 .vdev_op_xlate = NULL,
b2255edc
BB
98 .vdev_op_rebuild_asize = NULL,
99 .vdev_op_metaslab_init = NULL,
100 .vdev_op_config_generate = NULL,
101 .vdev_op_nparity = NULL,
102 .vdev_op_ndisks = NULL,
a64f8276
I
103 .vdev_op_type = VDEV_TYPE_MISSING, /* name of this vdev type */
104 .vdev_op_leaf = B_TRUE /* leaf vdev */
34dc7c2f 105};
428870ff
BB
106
107vdev_ops_t vdev_hole_ops = {
b2255edc
BB
108 .vdev_op_init = NULL,
109 .vdev_op_fini = NULL,
a64f8276
I
110 .vdev_op_open = vdev_missing_open,
111 .vdev_op_close = vdev_missing_close,
112 .vdev_op_asize = vdev_default_asize,
b2255edc
BB
113 .vdev_op_min_asize = vdev_default_min_asize,
114 .vdev_op_min_alloc = NULL,
a64f8276
I
115 .vdev_op_io_start = vdev_missing_io_start,
116 .vdev_op_io_done = vdev_missing_io_done,
117 .vdev_op_state_change = NULL,
118 .vdev_op_need_resilver = NULL,
119 .vdev_op_hold = NULL,
120 .vdev_op_rele = NULL,
121 .vdev_op_remap = NULL,
122 .vdev_op_xlate = NULL,
b2255edc
BB
123 .vdev_op_rebuild_asize = NULL,
124 .vdev_op_metaslab_init = NULL,
125 .vdev_op_config_generate = NULL,
126 .vdev_op_nparity = NULL,
127 .vdev_op_ndisks = NULL,
a64f8276
I
128 .vdev_op_type = VDEV_TYPE_HOLE, /* name of this vdev type */
129 .vdev_op_leaf = B_TRUE /* leaf vdev */
428870ff 130};