zfs.h 4.4 KB

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