zfs.h 3.8 KB

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