usr/src/uts/common/sys/fs/zfs.h
author eschrock
Mon, 30 Jan 2006 18:23:00 -0800
changeset 1352 b7039548de2f
parent 1175 759d20c7e57b
child 1354 81359ee1ee63
permissions -rw-r--r--
6343802 zpool(1M) should make better use of libdiskmgt 6354197 setting env variable NOINUSE_CHECK causes zpool to core dump 6364275 internal error: disk configuration error 19 at line 518 of file zpool_vdev.c
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
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     5
 * Common Development and Distribution License, Version 1.0 only
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     6
 * (the "License").  You may not use this file except in compliance
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 * with the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    22
/*
1352
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
    23
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 * Use is subject to license terms.
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
#ifndef	_SYS_FS_ZFS_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#define	_SYS_FS_ZFS_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/types.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
 * Types and constants shared between userland and the kernel.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
 * Each dataset can be one of the following types.  These constants can be
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
 * combined into masks that can be passed to various functions.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
typedef enum {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
	ZFS_TYPE_FILESYSTEM	= 0x1,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
	ZFS_TYPE_SNAPSHOT	= 0x2,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
	ZFS_TYPE_VOLUME		= 0x4
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
} zfs_type_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
#define	ZFS_TYPE_ANY	\
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
	(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
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
 * Properties are identified by these constants.  They are arranged in order of
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
 * how they should be displayed by 'zfs get'.  If you make any changes to this
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
 * list, be sure to update the property table in usr/src/common/zfs/zfs_prop.c.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
typedef enum {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
	ZFS_PROP_INVAL = -1,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
	ZFS_PROP_TYPE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
	ZFS_PROP_CREATION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	ZFS_PROP_USED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
	ZFS_PROP_AVAILABLE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
	ZFS_PROP_REFERENCED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	ZFS_PROP_COMPRESSRATIO,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
	ZFS_PROP_MOUNTED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	ZFS_PROP_ORIGIN,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
	ZFS_PROP_QUOTA,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
	ZFS_PROP_RESERVATION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
	ZFS_PROP_VOLSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	ZFS_PROP_VOLBLOCKSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	ZFS_PROP_RECORDSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	ZFS_PROP_MOUNTPOINT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	ZFS_PROP_SHARENFS,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	ZFS_PROP_CHECKSUM,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	ZFS_PROP_COMPRESSION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	ZFS_PROP_ATIME,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
	ZFS_PROP_DEVICES,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	ZFS_PROP_EXEC,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	ZFS_PROP_SETUID,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	ZFS_PROP_READONLY,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
	ZFS_PROP_ZONED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
	ZFS_PROP_SNAPDIR,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
	ZFS_PROP_ACLMODE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
	ZFS_PROP_ACLINHERIT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
	/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
	 * The following properties are not exposed to the user, but are
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
	 * accessible by libzfs clients.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
	ZFS_PROP_CREATETXG,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
	ZFS_PROP_NAME,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
	ZFS_NPROP_ALL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
} zfs_prop_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
#define	ZFS_NPROP_VISIBLE	ZFS_PROP_CREATETXG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
 * The following functions are shared between libzfs and the kernel.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
zfs_prop_t zfs_name_to_prop(const char *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
int zfs_prop_readonly(zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
void zfs_prop_default_string(zfs_prop_t, char *, size_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
uint64_t zfs_prop_default_numeric(zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
 * The following are configuration names used in the nvlist describing a pool's
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
 * configuration.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
#define	ZPOOL_CONFIG_VERSION		"version"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
#define	ZPOOL_CONFIG_POOL_NAME		"name"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
#define	ZPOOL_CONFIG_POOL_STATE		"state"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
#define	ZPOOL_CONFIG_POOL_TXG		"txg"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
#define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
#define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
#define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
#define	ZPOOL_CONFIG_POOL_HEALTH	"pool_health"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
#define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
#define	ZPOOL_CONFIG_TYPE		"type"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
#define	ZPOOL_CONFIG_CHILDREN		"children"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
#define	ZPOOL_CONFIG_ID			"id"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
#define	ZPOOL_CONFIG_GUID		"guid"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
#define	ZPOOL_CONFIG_PATH		"path"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
#define	ZPOOL_CONFIG_DEVID		"devid"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
#define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
#define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
#define	ZPOOL_CONFIG_ASHIFT		"ashift"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
#define	ZPOOL_CONFIG_ASIZE		"asize"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
#define	ZPOOL_CONFIG_DTL		"DTL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
#define	ZPOOL_CONFIG_STATS		"stats"
1171
b501e9f31cab 6344272 re-think how whole disks are stored
eschrock
parents: 789
diff changeset
   132
#define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
#define	VDEV_TYPE_ROOT			"root"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
#define	VDEV_TYPE_MIRROR		"mirror"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
#define	VDEV_TYPE_REPLACING		"replacing"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
#define	VDEV_TYPE_RAIDZ			"raidz"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
#define	VDEV_TYPE_DISK			"disk"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
#define	VDEV_TYPE_FILE			"file"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
#define	VDEV_TYPE_MISSING		"missing"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
 * This is needed in userland to report the minimum necessary device size.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
#define	SPA_MINDEVSIZE		(64ULL << 20)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
 * The location of the pool configuration repository, shared between kernel and
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
 * userland.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
#define	ZPOOL_CACHE_DIR		"/etc/zfs"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
#define	ZPOOL_CACHE_FILE	"zpool.cache"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
#define	ZPOOL_CACHE_TMP		".zpool.cache"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
#define	ZPOOL_CACHE		ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
 * vdev states are ordered from least to most healthy.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
 * A vdev that's CANT_OPEN or below is considered unusable.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
typedef enum vdev_state {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
	VDEV_STATE_UNKNOWN = 0,	/* Uninitialized vdev			*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
	VDEV_STATE_CLOSED,	/* Not currently open			*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
	VDEV_STATE_OFFLINE,	/* Not allowed to open			*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
	VDEV_STATE_CANT_OPEN,	/* Tried to open, but failed		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	VDEV_STATE_DEGRADED,	/* Replicated vdev with unhealthy kids	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
	VDEV_STATE_HEALTHY	/* Presumed good			*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
} vdev_state_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
 * vdev aux states.  When a vdev is in the CANT_OPEN state, the aux field
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
 * of the vdev stats structure uses these constants to distinguish why.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
typedef enum vdev_aux {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
	VDEV_AUX_NONE,		/* no error				*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
	VDEV_AUX_OPEN_FAILED,	/* ldi_open_*() or vn_open() failed	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
	VDEV_AUX_CORRUPT_DATA,	/* bad label or disk contents		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
	VDEV_AUX_NO_REPLICAS,	/* insufficient number of replicas	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
	VDEV_AUX_BAD_GUID_SUM,	/* vdev guid sum doesn't match		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
	VDEV_AUX_TOO_SMALL,	/* vdev size is too small		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
	VDEV_AUX_BAD_LABEL	/* the label is OK but invalid		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
} vdev_aux_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
/*
1352
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
   185
 * pool state.  The following states are written to disk as part of the normal
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
   186
 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED.  The remaining states are
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
   187
 * software abstractions used at various levels to communicate pool state.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
typedef enum pool_state {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
	POOL_STATE_ACTIVE = 0,		/* In active use		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
1352
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
   194
	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
b7039548de2f 6343802 zpool(1M) should make better use of libdiskmgt
eschrock
parents: 1175
diff changeset
   195
	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
} pool_state_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
 * Scrub types.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
typedef enum pool_scrub_type {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
	POOL_SCRUB_NONE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
	POOL_SCRUB_RESILVER,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   204
	POOL_SCRUB_EVERYTHING,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
	POOL_SCRUB_TYPES
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
} pool_scrub_type_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
 * ZIO types.  Needed to interpret vdev statistics below.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
typedef enum zio_type {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
	ZIO_TYPE_NULL = 0,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
	ZIO_TYPE_READ,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
	ZIO_TYPE_WRITE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
	ZIO_TYPE_FREE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
	ZIO_TYPE_CLAIM,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
	ZIO_TYPE_IOCTL,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
	ZIO_TYPES
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
} zio_type_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
 * Vdev statistics.  Note: all fields should be 64-bit because this
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
 * is passed between kernel and userland as an nvlist uint64 array.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
typedef struct vdev_stat {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
	hrtime_t	vs_timestamp;		/* time since vdev load	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
	uint64_t	vs_state;		/* vdev state		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
	uint64_t	vs_aux;			/* see vdev_aux_t	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
	uint64_t	vs_alloc;		/* space allocated	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
	uint64_t	vs_space;		/* total capacity	*/
1175
759d20c7e57b 6366265 attach/replace should allow a new device size at least the min of all devs in a mirror/raidz
lling
parents: 1171
diff changeset
   231
	uint64_t	vs_rsize;		/* replaceable dev size */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
	uint64_t	vs_ops[ZIO_TYPES];	/* operation count	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
	uint64_t	vs_bytes[ZIO_TYPES];	/* bytes read/written	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
	uint64_t	vs_read_errors;		/* read errors		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
	uint64_t	vs_write_errors;	/* write errors		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
	uint64_t	vs_checksum_errors;	/* checksum errors	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
	uint64_t	vs_self_healed;		/* self-healed bytes	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
	uint64_t	vs_scrub_type;		/* pool_scrub_type_t	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
	uint64_t	vs_scrub_complete;	/* completed?		*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
	uint64_t	vs_scrub_examined;	/* bytes examined; top	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
	uint64_t	vs_scrub_repaired;	/* bytes repaired; leaf	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
	uint64_t	vs_scrub_errors;	/* errors during scrub	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
	uint64_t	vs_scrub_start;		/* UTC scrub start time	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
	uint64_t	vs_scrub_end;		/* UTC scrub end time	*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
} vdev_stat_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
#define	ZFS_DRIVER	"zfs"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
#define	ZFS_DEV		"/dev/zfs"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
 * zvol paths.  Irritatingly, the devfsadm interfaces want all these
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
 * paths without the /dev prefix, but for some things, we want the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
 * /dev prefix.  Below are the names without /dev.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
#define	ZVOL_DEV_DIR	"zvol/dsk"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
#define	ZVOL_RDEV_DIR	"zvol/rdsk"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
 * And here are the things we need with /dev, etc. in front of them.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
#define	ZVOL_PSEUDO_DEV		"/devices/pseudo/zvol@0:"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   262
#define	ZVOL_FULL_DEV_DIR	"/dev/" ZVOL_DEV_DIR
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   263
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
#define	ZVOL_PROP_NAME		"name"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   265
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
 * /dev/zfs ioctl numbers.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
#define	ZFS_IOC		('Z' << 8)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   271
typedef enum zfs_ioc {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   272
	ZFS_IOC_POOL_CREATE = ZFS_IOC,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
	ZFS_IOC_POOL_DESTROY,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
	ZFS_IOC_POOL_IMPORT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   275
	ZFS_IOC_POOL_EXPORT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   276
	ZFS_IOC_POOL_CONFIGS,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   277
	ZFS_IOC_POOL_GUID,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
	ZFS_IOC_POOL_STATS,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
	ZFS_IOC_POOL_TRYIMPORT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
	ZFS_IOC_POOL_SCRUB,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
	ZFS_IOC_POOL_FREEZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
	ZFS_IOC_VDEV_ADD,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   283
	ZFS_IOC_VDEV_REMOVE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   284
	ZFS_IOC_VDEV_ONLINE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   285
	ZFS_IOC_VDEV_OFFLINE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   286
	ZFS_IOC_VDEV_ATTACH,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   287
	ZFS_IOC_VDEV_DETACH,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   288
	ZFS_IOC_OBJSET_STATS,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   289
	ZFS_IOC_DATASET_LIST_NEXT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   290
	ZFS_IOC_SNAPSHOT_LIST_NEXT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   291
	ZFS_IOC_SET_PROP,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   292
	ZFS_IOC_SET_QUOTA,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   293
	ZFS_IOC_SET_RESERVATION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   294
	ZFS_IOC_SET_VOLSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   295
	ZFS_IOC_SET_VOLBLOCKSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   296
	ZFS_IOC_CREATE_MINOR,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   297
	ZFS_IOC_REMOVE_MINOR,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   298
	ZFS_IOC_CREATE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   299
	ZFS_IOC_DESTROY,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   300
	ZFS_IOC_ROLLBACK,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   301
	ZFS_IOC_RENAME,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   302
	ZFS_IOC_RECVBACKUP,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   303
	ZFS_IOC_SENDBACKUP
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   304
} zfs_ioc_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   305
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   306
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   307
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   308
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   309
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   310
#endif	/* _SYS_FS_ZFS_H */