1/*
2 *  GRUB  --  GRand Unified Bootloader
3 *  Copyright (C) 1999,2000,2001,2002,2003,2004  Free Software Foundation, Inc.
4 *
5 *  This program is free software; you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation; either version 2 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program; if not, write to the Free Software
17 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20/*
21 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
22 * Copyright (c) 2012 by Delphix. All rights reserved.
23 */
24
25#ifndef	_SYS_FS_ZFS_H
26#define	_SYS_FS_ZFS_H
27
28/*
29 * On-disk version number.
30 */
31#define	SPA_VERSION_INITIAL		1ULL
32#define	SPA_VERSION_BEFORE_FEATURES	28ULL
33#define	SPA_VERSION			5000ULL
34#define	SPA_VERSION_FEATURES		5000ULL
35
36#define	SPA_VERSION_IS_SUPPORTED(v) \
37	(((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
38	((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
39
40/*
41 * The following are configuration names used in the nvlist describing a pool's
42 * configuration.
43 */
44#define	ZPOOL_CONFIG_VERSION		"version"
45#define	ZPOOL_CONFIG_POOL_NAME		"name"
46#define	ZPOOL_CONFIG_POOL_STATE		"state"
47#define	ZPOOL_CONFIG_POOL_TXG		"txg"
48#define	ZPOOL_CONFIG_POOL_GUID		"pool_guid"
49#define	ZPOOL_CONFIG_CREATE_TXG		"create_txg"
50#define	ZPOOL_CONFIG_TOP_GUID		"top_guid"
51#define	ZPOOL_CONFIG_VDEV_TREE		"vdev_tree"
52#define	ZPOOL_CONFIG_TYPE		"type"
53#define	ZPOOL_CONFIG_CHILDREN		"children"
54#define	ZPOOL_CONFIG_ID			"id"
55#define	ZPOOL_CONFIG_GUID		"guid"
56#define	ZPOOL_CONFIG_PATH		"path"
57#define	ZPOOL_CONFIG_DEVID		"devid"
58#define	ZPOOL_CONFIG_METASLAB_ARRAY	"metaslab_array"
59#define	ZPOOL_CONFIG_METASLAB_SHIFT	"metaslab_shift"
60#define	ZPOOL_CONFIG_ASHIFT		"ashift"
61#define	ZPOOL_CONFIG_ASIZE		"asize"
62#define	ZPOOL_CONFIG_DTL		"DTL"
63#define	ZPOOL_CONFIG_STATS		"stats"
64#define	ZPOOL_CONFIG_WHOLE_DISK		"whole_disk"
65#define	ZPOOL_CONFIG_ERRCOUNT		"error_count"
66#define	ZPOOL_CONFIG_NOT_PRESENT	"not_present"
67#define	ZPOOL_CONFIG_SPARES		"spares"
68#define	ZPOOL_CONFIG_IS_SPARE		"is_spare"
69#define	ZPOOL_CONFIG_NPARITY		"nparity"
70#define	ZPOOL_CONFIG_PHYS_PATH		"phys_path"
71#define	ZPOOL_CONFIG_L2CACHE		"l2cache"
72#define	ZPOOL_CONFIG_HOLE_ARRAY		"hole_array"
73#define	ZPOOL_CONFIG_VDEV_CHILDREN	"vdev_children"
74#define	ZPOOL_CONFIG_IS_HOLE		"is_hole"
75#define	ZPOOL_CONFIG_DDT_HISTOGRAM	"ddt_histogram"
76#define	ZPOOL_CONFIG_DDT_OBJ_STATS	"ddt_object_stats"
77#define	ZPOOL_CONFIG_DDT_STATS		"ddt_stats"
78#define	ZPOOL_CONFIG_FEATURES_FOR_READ	"features_for_read"
79/*
80 * The persistent vdev state is stored as separate values rather than a single
81 * 'vdev_state' entry.  This is because a device can be in multiple states, such
82 * as offline and degraded.
83 */
84#define	ZPOOL_CONFIG_OFFLINE		"offline"
85#define	ZPOOL_CONFIG_FAULTED		"faulted"
86#define	ZPOOL_CONFIG_DEGRADED		"degraded"
87#define	ZPOOL_CONFIG_REMOVED		"removed"
88
89#define	VDEV_TYPE_ROOT			"root"
90#define	VDEV_TYPE_MIRROR		"mirror"
91#define	VDEV_TYPE_REPLACING		"replacing"
92#define	VDEV_TYPE_RAIDZ			"raidz"
93#define	VDEV_TYPE_DISK			"disk"
94#define	VDEV_TYPE_FILE			"file"
95#define	VDEV_TYPE_MISSING		"missing"
96#define	VDEV_TYPE_HOLE			"hole"
97#define	VDEV_TYPE_SPARE			"spare"
98#define	VDEV_TYPE_L2CACHE		"l2cache"
99
100/*
101 * pool state.  The following states are written to disk as part of the normal
102 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE.  The remaining
103 * states are software abstractions used at various levels to communicate pool
104 * state.
105 */
106typedef enum pool_state {
107	POOL_STATE_ACTIVE = 0,		/* In active use		*/
108	POOL_STATE_EXPORTED,		/* Explicitly exported		*/
109	POOL_STATE_DESTROYED,		/* Explicitly destroyed		*/
110	POOL_STATE_SPARE,		/* Reserved for hot spare use	*/
111	POOL_STATE_L2CACHE,		/* Level 2 ARC device		*/
112	POOL_STATE_UNINITIALIZED,	/* Internal spa_t state		*/
113	POOL_STATE_UNAVAIL,		/* Internal libzfs state	*/
114	POOL_STATE_POTENTIALLY_ACTIVE	/* Internal libzfs state	*/
115} pool_state_t;
116
117#endif	/* _SYS_FS_ZFS_H */
118