usr/src/uts/common/fs/zfs/vdev_missing.c
author George Wilson <George.Wilson@Sun.COM>
Tue, 29 Sep 2009 07:29:35 -0700
changeset 10685 931790026ac6
parent 10594 986cb68d2347
child 11958 575ffe1e978d
permissions -rw-r--r--
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl 6872547 ztest LUN expansion test fails 6873635 zdb should be able to open a pool with a failed slog 6873654 system panics when a slog device is offlined 6875236 zdb should be able to dump the spa history
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 789
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
10594
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
 * The 'missing' vdev is a special vdev type used only during import.  It
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
 * signifies a placeholder in the root vdev for some vdev that we know is
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
 * missing.  We pass it down to the kernel to allow the rest of the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
 * configuration to parsed and an attempt made to open all available devices.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
 * Because its GUID is always 0, we know that the guid sum will mismatch and we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
 * won't be able to open the pool anyway.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#include <sys/vdev_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
#include <sys/fs/zfs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#include <sys/zio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
	/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
	 * Really this should just fail.  But then the root vdev will be in the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
	 * faulted state with VDEV_AUX_NO_REPLICAS, when what we really want is
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
	 * VDEV_AUX_BAD_GUID_SUM.  So we pretend to succeed, knowing that we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
	 * will fail the GUID sum check before ever trying to open the pool.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
	 */
10594
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    51
	*psize = 0;
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    52
	*ashift = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
/* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
vdev_missing_close(vdev_t *vd)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
/* ARGSUSED */
5530
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5329
diff changeset
    63
static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
vdev_missing_io_start(zio_t *zio)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
	zio->io_error = ENOTSUP;
5530
4ed96167d864 6354519 stack overflow in zfs due to zio pipeline
bonwick
parents: 5329
diff changeset
    67
	return (ZIO_PIPELINE_CONTINUE);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
/* ARGSUSED */
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 5530
diff changeset
    71
static void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
vdev_missing_io_done(zio_t *zio)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
{
5329
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 789
diff changeset
    74
}
33cb98223b2d PSARC 2007/567 zpool failmode property
gw25295
parents: 789
diff changeset
    75
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
vdev_ops_t vdev_missing_ops = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	vdev_missing_open,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	vdev_missing_close,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	vdev_default_asize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
	vdev_missing_io_start,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	vdev_missing_io_done,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	NULL,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	VDEV_TYPE_MISSING,	/* name of this vdev type */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
	B_TRUE			/* leaf vdev */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
};
10594
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    86
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    87
vdev_ops_t vdev_hole_ops = {
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    88
	vdev_missing_open,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    89
	vdev_missing_close,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    90
	vdev_default_asize,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    91
	vdev_missing_io_start,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    92
	vdev_missing_io_done,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    93
	NULL,
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    94
	VDEV_TYPE_HOLE,		/* name of this vdev type */
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    95
	B_TRUE			/* leaf vdev */
986cb68d2347 6574286 removing a slog doesn't work
George Wilson <George.Wilson@Sun.COM>
parents: 7754
diff changeset
    96
};