fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
0a4e9518a44f226be6d39383330b5b1792d2f184gw * Common Development and Distribution License (the "License").
0a4e9518a44f226be6d39383330b5b1792d2f184gw * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
dcba9f3fbefe06ad19972b4de0351924601e5767George Wilson * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
4263d13f00c9691fa14620eff82abef795be0693George Wilson/*
738f37bc3dcd61e8a893af0f2d466d76690b70ecGeorge Wilson * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
4263d13f00c9691fa14620eff82abef795be0693George Wilson */
4263d13f00c9691fa14620eff82abef795be0693George Wilson
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The 'missing' vdev is a special vdev type used only during import. It
fa9e4066f08beec538e775443c5be79dd423fcabahrens * signifies a placeholder in the root vdev for some vdev that we know is
fa9e4066f08beec538e775443c5be79dd423fcabahrens * missing. We pass it down to the kernel to allow the rest of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * configuration to parsed and an attempt made to open all available devices.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Because its GUID is always 0, we know that the guid sum will mismatch and we
fa9e4066f08beec538e775443c5be79dd423fcabahrens * won't be able to open the pool anyway.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zfs_context.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/spa.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/vdev_impl.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/fs/zfs.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/zio.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
4263d13f00c9691fa14620eff82abef795be0693George Wilsonvdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
4263d13f00c9691fa14620eff82abef795be0693George Wilson uint64_t *ashift)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Really this should just fail. But then the root vdev will be in the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is
fa9e4066f08beec538e775443c5be79dd423fcabahrens * VDEV_AUX_BAD_GUID_SUM. So we pretend to succeed, knowing that we
fa9e4066f08beec538e775443c5be79dd423fcabahrens * will fail the GUID sum check before ever trying to open the pool.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson *psize = 0;
4263d13f00c9691fa14620eff82abef795be0693George Wilson *max_psize = 0;
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson *ashift = 0;
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensvdev_missing_close(vdev_t *vd)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
738f37bc3dcd61e8a893af0f2d466d76690b70ecGeorge Wilsonstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensvdev_missing_io_start(zio_t *zio)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens zio->io_error = SET_ERROR(ENOTSUP);
738f37bc3dcd61e8a893af0f2d466d76690b70ecGeorge Wilson zio_execute(zio);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwickstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensvdev_missing_io_done(zio_t *zio)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
0a4e9518a44f226be6d39383330b5b1792d2f184gw}
0a4e9518a44f226be6d39383330b5b1792d2f184gw
fa9e4066f08beec538e775443c5be79dd423fcabahrensvdev_ops_t vdev_missing_ops = {
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_missing_open,
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_missing_close,
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_default_asize,
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_missing_io_start,
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_missing_io_done,
fa9e4066f08beec538e775443c5be79dd423fcabahrens NULL,
dcba9f3fbefe06ad19972b4de0351924601e5767George Wilson NULL,
dcba9f3fbefe06ad19972b4de0351924601e5767George Wilson NULL,
fa9e4066f08beec538e775443c5be79dd423fcabahrens VDEV_TYPE_MISSING, /* name of this vdev type */
fa9e4066f08beec538e775443c5be79dd423fcabahrens B_TRUE /* leaf vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens};
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilsonvdev_ops_t vdev_hole_ops = {
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson vdev_missing_open,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson vdev_missing_close,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson vdev_default_asize,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson vdev_missing_io_start,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson vdev_missing_io_done,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson NULL,
dcba9f3fbefe06ad19972b4de0351924601e5767George Wilson NULL,
dcba9f3fbefe06ad19972b4de0351924601e5767George Wilson NULL,
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson VDEV_TYPE_HOLE, /* name of this vdev type */
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson B_TRUE /* leaf vdev */
88ecc943b4eb72f7c4fbbd8435997b85ef171fc3George Wilson};