Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Jorgen Lundman | 9b4a1f9 | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 2 | /* |
| 3 | * GRUB -- GRand Unified Bootloader |
| 4 | * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
Jorgen Lundman | 9b4a1f9 | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
| 7 | * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
| 8 | */ |
| 9 | |
| 10 | #ifndef GRUB_ZFS_HEADER |
| 11 | #define GRUB_ZFS_HEADER 1 |
| 12 | |
| 13 | |
| 14 | /* |
| 15 | * On-disk version number. |
| 16 | */ |
| 17 | #define SPA_VERSION 28ULL |
WHR | 54ef525 | 2024-05-01 00:28:32 +0800 | [diff] [blame] | 18 | #define FEATURES_SUPPORTED_SPA_VERSION 5000ULL |
Jorgen Lundman | 9b4a1f9 | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 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 | */ |
| 85 | typedef 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 | |
| 96 | struct zfs_data; |
| 97 | |
| 98 | int zfs_fetch_nvlist(device_t dev, char **nvlist); |
| 99 | int zfs_getmdnobj(device_t dev, const char *fsfilename, |
| 100 | uint64_t *mdnobj); |
| 101 | |
| 102 | char *zfs_nvlist_lookup_string(char *nvlist, char *name); |
| 103 | char *zfs_nvlist_lookup_nvlist(char *nvlist, char *name); |
| 104 | int zfs_nvlist_lookup_uint64(char *nvlist, char *name, |
| 105 | uint64_t *out); |
| 106 | char *zfs_nvlist_lookup_nvlist_array(char *nvlist, char *name, |
| 107 | size_t index); |
| 108 | int zfs_nvlist_lookup_nvlist_array_get_nelm(char *nvlist, char *name); |
| 109 | |
| 110 | #endif /* ! GRUB_ZFS_HEADER */ |