vdev_missing.c revision 219089
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/* 27168404Spjd * The 'missing' vdev is a special vdev type used only during import. It 28168404Spjd * signifies a placeholder in the root vdev for some vdev that we know is 29168404Spjd * missing. We pass it down to the kernel to allow the rest of the 30168404Spjd * configuration to parsed and an attempt made to open all available devices. 31168404Spjd * Because its GUID is always 0, we know that the guid sum will mismatch and we 32168404Spjd * won't be able to open the pool anyway. 33168404Spjd */ 34168404Spjd 35168404Spjd#include <sys/zfs_context.h> 36168404Spjd#include <sys/spa.h> 37168404Spjd#include <sys/vdev_impl.h> 38168404Spjd#include <sys/fs/zfs.h> 39168404Spjd#include <sys/zio.h> 40168404Spjd 41168404Spjd/* ARGSUSED */ 42168404Spjdstatic int 43168404Spjdvdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) 44168404Spjd{ 45168404Spjd /* 46168404Spjd * Really this should just fail. But then the root vdev will be in the 47168404Spjd * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is 48168404Spjd * VDEV_AUX_BAD_GUID_SUM. So we pretend to succeed, knowing that we 49168404Spjd * will fail the GUID sum check before ever trying to open the pool. 50168404Spjd */ 51219089Spjd *psize = 0; 52219089Spjd *ashift = 0; 53168404Spjd return (0); 54168404Spjd} 55168404Spjd 56168404Spjd/* ARGSUSED */ 57168404Spjdstatic void 58168404Spjdvdev_missing_close(vdev_t *vd) 59168404Spjd{ 60168404Spjd} 61168404Spjd 62168404Spjd/* ARGSUSED */ 63185029Spjdstatic int 64168404Spjdvdev_missing_io_start(zio_t *zio) 65168404Spjd{ 66168404Spjd zio->io_error = ENOTSUP; 67185029Spjd return (ZIO_PIPELINE_CONTINUE); 68168404Spjd} 69168404Spjd 70168404Spjd/* ARGSUSED */ 71168404Spjdstatic void 72168404Spjdvdev_missing_io_done(zio_t *zio) 73168404Spjd{ 74168404Spjd} 75168404Spjd 76168404Spjdvdev_ops_t vdev_missing_ops = { 77168404Spjd vdev_missing_open, 78168404Spjd vdev_missing_close, 79168404Spjd vdev_default_asize, 80168404Spjd vdev_missing_io_start, 81168404Spjd vdev_missing_io_done, 82168404Spjd NULL, 83219089Spjd NULL, 84219089Spjd NULL, 85168404Spjd VDEV_TYPE_MISSING, /* name of this vdev type */ 86168404Spjd B_TRUE /* leaf vdev */ 87168404Spjd}; 88219089Spjd 89219089Spjdvdev_ops_t vdev_hole_ops = { 90219089Spjd vdev_missing_open, 91219089Spjd vdev_missing_close, 92219089Spjd vdev_default_asize, 93219089Spjd vdev_missing_io_start, 94219089Spjd vdev_missing_io_done, 95219089Spjd NULL, 96219089Spjd NULL, 97219089Spjd NULL, 98219089Spjd VDEV_TYPE_HOLE, /* name of this vdev type */ 99219089Spjd B_TRUE /* leaf vdev */ 100219089Spjd}; 101