blob: 8912732abee3dc6653172660c9615f11c99c57bc [file] [log] [blame]
Jorgen Lundman4d3c95f2012-07-19 20:48:25 +00001/*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Jorgen Lundman4d3c95f2012-07-19 20:48:25 +00006 */
7/*
8 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
9 */
10
11#ifndef GRUB_ZFS_HEADER
12#define GRUB_ZFS_HEADER 1
13
14
15/*
16 * On-disk version number.
17 */
18#define SPA_VERSION 28ULL
19
20/*
21 * The following are configuration names used in the nvlist describing a pool's
22 * configuration.
23 */
24#define ZPOOL_CONFIG_VERSION "version"
25#define ZPOOL_CONFIG_POOL_NAME "name"
26#define ZPOOL_CONFIG_POOL_STATE "state"
27#define ZPOOL_CONFIG_POOL_TXG "txg"
28#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
29#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
30#define ZPOOL_CONFIG_TOP_GUID "top_guid"
31#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
32#define ZPOOL_CONFIG_TYPE "type"
33#define ZPOOL_CONFIG_CHILDREN "children"
34#define ZPOOL_CONFIG_ID "id"
35#define ZPOOL_CONFIG_GUID "guid"
36#define ZPOOL_CONFIG_PATH "path"
37#define ZPOOL_CONFIG_DEVID "devid"
38#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
39#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
40#define ZPOOL_CONFIG_ASHIFT "ashift"
41#define ZPOOL_CONFIG_ASIZE "asize"
42#define ZPOOL_CONFIG_DTL "DTL"
43#define ZPOOL_CONFIG_STATS "stats"
44#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
45#define ZPOOL_CONFIG_ERRCOUNT "error_count"
46#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
47#define ZPOOL_CONFIG_SPARES "spares"
48#define ZPOOL_CONFIG_IS_SPARE "is_spare"
49#define ZPOOL_CONFIG_NPARITY "nparity"
50#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
51#define ZPOOL_CONFIG_L2CACHE "l2cache"
52#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
53#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
54#define ZPOOL_CONFIG_IS_HOLE "is_hole"
55#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
56#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
57#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
58/*
59 * The persistent vdev state is stored as separate values rather than a single
60 * 'vdev_state' entry. This is because a device can be in multiple states, such
61 * as offline and degraded.
62 */
63#define ZPOOL_CONFIG_OFFLINE "offline"
64#define ZPOOL_CONFIG_FAULTED "faulted"
65#define ZPOOL_CONFIG_DEGRADED "degraded"
66#define ZPOOL_CONFIG_REMOVED "removed"
67
68#define VDEV_TYPE_ROOT "root"
69#define VDEV_TYPE_MIRROR "mirror"
70#define VDEV_TYPE_REPLACING "replacing"
71#define VDEV_TYPE_RAIDZ "raidz"
72#define VDEV_TYPE_DISK "disk"
73#define VDEV_TYPE_FILE "file"
74#define VDEV_TYPE_MISSING "missing"
75#define VDEV_TYPE_HOLE "hole"
76#define VDEV_TYPE_SPARE "spare"
77#define VDEV_TYPE_L2CACHE "l2cache"
78
79/*
80 * pool state. The following states are written to disk as part of the normal
81 * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
82 * states are software abstractions used at various levels to communicate pool
83 * state.
84 */
85typedef enum pool_state {
86 POOL_STATE_ACTIVE = 0, /* In active use */
87 POOL_STATE_EXPORTED, /* Explicitly exported */
88 POOL_STATE_DESTROYED, /* Explicitly destroyed */
89 POOL_STATE_SPARE, /* Reserved for hot spare use */
90 POOL_STATE_L2CACHE, /* Level 2 ARC device */
91 POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
92 POOL_STATE_UNAVAIL, /* Internal libzfs state */
93 POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
94} pool_state_t;
95
96struct zfs_data;
97
98int zfs_fetch_nvlist(device_t dev, char **nvlist);
99int zfs_getmdnobj(device_t dev, const char *fsfilename,
100 uint64_t *mdnobj);
101
102char *zfs_nvlist_lookup_string(char *nvlist, char *name);
103char *zfs_nvlist_lookup_nvlist(char *nvlist, char *name);
104int zfs_nvlist_lookup_uint64(char *nvlist, char *name,
105 uint64_t *out);
106char *zfs_nvlist_lookup_nvlist_array(char *nvlist, char *name,
107 size_t index);
108int zfs_nvlist_lookup_nvlist_array_get_nelm(char *nvlist, char *name);
109
110#endif /* ! GRUB_ZFS_HEADER */