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