1168404Spjd/* 2168404Spjd * CDDL HEADER START 3168404Spjd * 4168404Spjd * The contents of this file are subject to the terms of the 5185029Spjd * Common Development and Distribution License (the "License"). 6185029Spjd * You may not use this file except in compliance with the License. 7168404Spjd * 8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9168404Spjd * or http://www.opensolaris.org/os/licensing. 10168404Spjd * See the License for the specific language governing permissions 11168404Spjd * and limitations under the License. 12168404Spjd * 13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each 14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15168404Spjd * If applicable, add the following below this CDDL HEADER, with the 16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying 17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner] 18168404Spjd * 19168404Spjd * CDDL HEADER END 20168404Spjd */ 21168404Spjd/* 22219089Spjd * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23168404Spjd * Use is subject to license terms. 24168404Spjd */ 25168404Spjd 26168404Spjd/* 27249195Smm * Copyright (c) 2013 by Delphix. All rights reserved. 28236155Smm */ 29236155Smm 30236155Smm/* 31168404Spjd * The 'missing' vdev is a special vdev type used only during import. It 32168404Spjd * signifies a placeholder in the root vdev for some vdev that we know is 33168404Spjd * missing. We pass it down to the kernel to allow the rest of the 34168404Spjd * configuration to parsed and an attempt made to open all available devices. 35168404Spjd * Because its GUID is always 0, we know that the guid sum will mismatch and we 36168404Spjd * won't be able to open the pool anyway. 37168404Spjd */ 38168404Spjd 39168404Spjd#include <sys/zfs_context.h> 40168404Spjd#include <sys/spa.h> 41168404Spjd#include <sys/vdev_impl.h> 42168404Spjd#include <sys/fs/zfs.h> 43168404Spjd#include <sys/zio.h> 44168404Spjd 45168404Spjd/* ARGSUSED */ 46168404Spjdstatic int 47236155Smmvdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, 48254591Sgibbs uint64_t *logical_ashift, uint64_t *physical_ashift) 49168404Spjd{ 50168404Spjd /* 51168404Spjd * Really this should just fail. But then the root vdev will be in the 52168404Spjd * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is 53168404Spjd * VDEV_AUX_BAD_GUID_SUM. So we pretend to succeed, knowing that we 54168404Spjd * will fail the GUID sum check before ever trying to open the pool. 55168404Spjd */ 56219089Spjd *psize = 0; 57236155Smm *max_psize = 0; 58254591Sgibbs *logical_ashift = 0; 59254591Sgibbs *physical_ashift = 0; 60168404Spjd return (0); 61168404Spjd} 62168404Spjd 63168404Spjd/* ARGSUSED */ 64168404Spjdstatic void 65168404Spjdvdev_missing_close(vdev_t *vd) 66168404Spjd{ 67168404Spjd} 68168404Spjd 69168404Spjd/* ARGSUSED */ 70185029Spjdstatic int 71168404Spjdvdev_missing_io_start(zio_t *zio) 72168404Spjd{ 73249195Smm zio->io_error = SET_ERROR(ENOTSUP); 74270312Ssmh zio_interrupt(zio); 75270312Ssmh return (ZIO_PIPELINE_STOP); 76168404Spjd} 77168404Spjd 78168404Spjd/* ARGSUSED */ 79168404Spjdstatic void 80168404Spjdvdev_missing_io_done(zio_t *zio) 81168404Spjd{ 82168404Spjd} 83168404Spjd 84168404Spjdvdev_ops_t vdev_missing_ops = { 85168404Spjd vdev_missing_open, 86168404Spjd vdev_missing_close, 87168404Spjd vdev_default_asize, 88168404Spjd vdev_missing_io_start, 89168404Spjd vdev_missing_io_done, 90168404Spjd NULL, 91219089Spjd NULL, 92219089Spjd NULL, 93168404Spjd VDEV_TYPE_MISSING, /* name of this vdev type */ 94168404Spjd B_TRUE /* leaf vdev */ 95168404Spjd}; 96219089Spjd 97219089Spjdvdev_ops_t vdev_hole_ops = { 98219089Spjd vdev_missing_open, 99219089Spjd vdev_missing_close, 100219089Spjd vdev_default_asize, 101219089Spjd vdev_missing_io_start, 102219089Spjd vdev_missing_io_done, 103219089Spjd NULL, 104219089Spjd NULL, 105219089Spjd NULL, 106219089Spjd VDEV_TYPE_HOLE, /* name of this vdev type */ 107219089Spjd B_TRUE /* leaf vdev */ 108219089Spjd}; 109