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