Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2008
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.31 KB | None | 0 0
  1. Index: sys/cddl/boot/zfs/sha256.c
  2. ===================================================================
  3. --- sys/cddl/boot/zfs/sha256.c (revision 185164)
  4. +++ sys/cddl/boot/zfs/sha256.c (working copy)
  5. @@ -2,9 +2,8 @@
  6. * CDDL HEADER START
  7. *
  8. * The contents of this file are subject to the terms of the
  9. - * Common Development and Distribution License, Version 1.0 only
  10. - * (the "License"). You may not use this file except in compliance
  11. - * with the License.
  12. + * Common Development and Distribution License (the "License").
  13. + * You may not use this file except in compliance with the License.
  14. *
  15. * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  16. * or http://www.opensolaris.org/os/licensing.
  17. @@ -20,27 +19,27 @@
  18. * CDDL HEADER END
  19. */
  20. /*
  21. - * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
  22. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  23. * Use is subject to license terms.
  24. */
  25.  
  26. /*#pragma ident "%Z%%M% %I% %E% SMI"*/
  27.  
  28. /*
  29. - * SHA-256 checksum, as specified in FIPS 180-2, available at:
  30. - * http://csrc.nist.gov/cryptval
  31. + * SHA-256 checksum, as specified in FIPS 180-3, available at:
  32. + * http://csrc.nist.gov/publications/PubsFIPS.html
  33. *
  34. * This is a very compact implementation of SHA-256.
  35. * It is designed to be simple and portable, not to be fast.
  36. */
  37.  
  38. /*
  39. - * The literal definitions according to FIPS180-2 would be:
  40. + * The literal definitions of Ch() and Maj() according to FIPS 180-3 are:
  41. *
  42. - * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z)))
  43. - * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
  44. + * Ch(x, y, z) (x & y) ^ (~x & z)
  45. + * Maj(x, y, z) (x & y) ^ (x & z) ^ (y & z)
  46. *
  47. - * We use logical equivalents which require one less op.
  48. + * We use equivalent logical reductions here that require one less op.
  49. */
  50. #define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  51. #define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y))))
  52. @@ -101,20 +100,19 @@
  53. uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  54. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
  55. uint8_t pad[128];
  56. - int padsize = size & 63;
  57. - int i;
  58. + int i, padsize;
  59.  
  60. - for (i = 0; i < size - padsize; i += 64)
  61. + for (i = 0; i < (size & ~63ULL); i += 64)
  62. SHA256Transform(H, (uint8_t *)buf + i);
  63.  
  64. - for (i = 0; i < padsize; i++)
  65. - pad[i] = ((uint8_t *)buf)[i];
  66. + for (padsize = 0; i < size; i++)
  67. + pad[padsize++] = *((uint8_t *)buf + i);
  68.  
  69. for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++)
  70. pad[padsize] = 0;
  71.  
  72. - for (i = 0; i < 8; i++)
  73. - pad[padsize++] = (size << 3) >> (56 - 8 * i);
  74. + for (i = 56; i >= 0; i -= 8)
  75. + pad[padsize++] = (size << 3) >> i;
  76.  
  77. for (i = 0; i < padsize; i += 64)
  78. SHA256Transform(H, pad + i);
  79. Index: sys/cddl/boot/zfs/zfsimpl.h
  80. ===================================================================
  81. --- sys/cddl/boot/zfs/zfsimpl.h (revision 185164)
  82. +++ sys/cddl/boot/zfs/zfsimpl.h (working copy)
  83. @@ -49,7 +49,7 @@
  84. * CDDL HEADER END
  85. */
  86. /*
  87. - * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  88. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
  89. * Use is subject to license terms.
  90. */
  91.  
  92. @@ -461,13 +461,14 @@
  93. #define SPA_VERSION_11 11ULL
  94. #define SPA_VERSION_12 12ULL
  95. #define SPA_VERSION_13 13ULL
  96. +#define SPA_VERSION_14 14ULL
  97. /*
  98. * When bumping up SPA_VERSION, make sure GRUB ZFS understand the on-disk
  99. * format change. Go to usr/src/grub/grub-0.95/stage2/{zfs-include/, fsys_zfs*},
  100. * and do the appropriate changes.
  101. */
  102. -#define SPA_VERSION SPA_VERSION_13
  103. -#define SPA_VERSION_STRING "13"
  104. +#define SPA_VERSION SPA_VERSION_14
  105. +#define SPA_VERSION_STRING "14"
  106.  
  107. /*
  108. * Symbolic names for the changes that caused a SPA_VERSION switch.
  109. @@ -502,8 +503,29 @@
  110. #define SPA_VERSION_DSL_SCRUB SPA_VERSION_11
  111. #define SPA_VERSION_SNAP_PROPS SPA_VERSION_12
  112. #define SPA_VERSION_USED_BREAKDOWN SPA_VERSION_13
  113. +#define SPA_VERSION_PASSTHROUGH_X SPA_VERSION_14
  114.  
  115. /*
  116. + * ZPL version - rev'd whenever an incompatible on-disk format change
  117. + * occurs. This is independent of SPA/DMU/ZAP versioning. You must
  118. + * also update the version_table[] and help message in zfs_prop.c.
  119. + *
  120. + * When changing, be sure to teach GRUB how to read the new format!
  121. + * See usr/src/grub/grub-0.95/stage2/{zfs-include/,fsys_zfs*}
  122. + */
  123. +#define ZPL_VERSION_1 1ULL
  124. +#define ZPL_VERSION_2 2ULL
  125. +#define ZPL_VERSION_3 3ULL
  126. +#define ZPL_VERSION ZPL_VERSION_3
  127. +#define ZPL_VERSION_STRING "3"
  128. +
  129. +#define ZPL_VERSION_INITIAL ZPL_VERSION_1
  130. +#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
  131. +#define ZPL_VERSION_FUID ZPL_VERSION_3
  132. +#define ZPL_VERSION_NORMALIZATION ZPL_VERSION_3
  133. +#define ZPL_VERSION_SYSATTR ZPL_VERSION_3
  134. +
  135. +/*
  136. * The following are configuration names used in the nvlist describing a pool's
  137. * configuration.
  138. */
  139. @@ -528,7 +550,6 @@
  140. #define ZPOOL_CONFIG_DTL "DTL"
  141. #define ZPOOL_CONFIG_STATS "stats"
  142. #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
  143. -#define ZPOOL_CONFIG_OFFLINE "offline"
  144. #define ZPOOL_CONFIG_ERRCOUNT "error_count"
  145. #define ZPOOL_CONFIG_NOT_PRESENT "not_present"
  146. #define ZPOOL_CONFIG_SPARES "spares"
  147. @@ -536,7 +557,22 @@
  148. #define ZPOOL_CONFIG_NPARITY "nparity"
  149. #define ZPOOL_CONFIG_HOSTID "hostid"
  150. #define ZPOOL_CONFIG_HOSTNAME "hostname"
  151. -#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
  152. +#define ZPOOL_CONFIG_UNSPARE "unspare"
  153. +#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
  154. +#define ZPOOL_CONFIG_IS_LOG "is_log"
  155. +#define ZPOOL_CONFIG_L2CACHE "l2cache"
  156. +#define ZPOOL_CONFIG_SUSPENDED "suspended" /* not stored on disk */
  157. +#define ZPOOL_CONFIG_TIMESTAMP "timestamp" /* not stored on disk */
  158. +#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
  159. +/*
  160. + * The persistent vdev state is stored as separate values rather than a single
  161. + * 'vdev_state' entry. This is because a device can be in multiple states, such
  162. + * as offline and degraded.
  163. + */
  164. +#define ZPOOL_CONFIG_OFFLINE "offline"
  165. +#define ZPOOL_CONFIG_FAULTED "faulted"
  166. +#define ZPOOL_CONFIG_DEGRADED "degraded"
  167. +#define ZPOOL_CONFIG_REMOVED "removed"
  168.  
  169. #define VDEV_TYPE_ROOT "root"
  170. #define VDEV_TYPE_MIRROR "mirror"
  171. @@ -546,6 +582,8 @@
  172. #define VDEV_TYPE_FILE "file"
  173. #define VDEV_TYPE_MISSING "missing"
  174. #define VDEV_TYPE_SPARE "spare"
  175. +#define VDEV_TYPE_LOG "log"
  176. +#define VDEV_TYPE_L2CACHE "l2cache"
  177.  
  178. /*
  179. * This is needed in userland to report the minimum necessary device size.
  180. @@ -556,12 +594,8 @@
  181. * The location of the pool configuration repository, shared between kernel and
  182. * userland.
  183. */
  184. -#define ZPOOL_CACHE_DIR "/boot/zfs"
  185. -#define ZPOOL_CACHE_FILE "zpool.cache"
  186. -#define ZPOOL_CACHE_TMP ".zpool.cache"
  187. +#define ZPOOL_CACHE "/boot/zfs/zpool.cache"
  188.  
  189. -#define ZPOOL_CACHE ZPOOL_CACHE_DIR "/" ZPOOL_CACHE_FILE
  190. -
  191. /*
  192. * vdev states are ordered from least to most healthy.
  193. * A vdev that's CANT_OPEN or below is considered unusable.
  194. @@ -570,11 +604,15 @@
  195. VDEV_STATE_UNKNOWN = 0, /* Uninitialized vdev */
  196. VDEV_STATE_CLOSED, /* Not currently open */
  197. VDEV_STATE_OFFLINE, /* Not allowed to open */
  198. + VDEV_STATE_REMOVED, /* Explicitly removed from system */
  199. VDEV_STATE_CANT_OPEN, /* Tried to open, but failed */
  200. + VDEV_STATE_FAULTED, /* External request to fault device */
  201. VDEV_STATE_DEGRADED, /* Replicated vdev with unhealthy kids */
  202. VDEV_STATE_HEALTHY /* Presumed good */
  203. } vdev_state_t;
  204.  
  205. +#define VDEV_STATE_ONLINE VDEV_STATE_HEALTHY
  206. +
  207. /*
  208. * vdev aux states. When a vdev is in the CANT_OPEN state, the aux field
  209. * of the vdev stats structure uses these constants to distinguish why.
  210. @@ -589,19 +627,24 @@
  211. VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
  212. VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
  213. VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
  214. - VDEV_AUX_SPARED /* hot spare used in another pool */
  215. + VDEV_AUX_SPARED, /* hot spare used in another pool */
  216. + VDEV_AUX_ERR_EXCEEDED, /* too many errors */
  217. + VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
  218. + VDEV_AUX_BAD_LOG /* cannot read log chain(s) */
  219. } vdev_aux_t;
  220.  
  221. /*
  222. * pool state. The following states are written to disk as part of the normal
  223. - * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE. The remaining states are
  224. - * software abstractions used at various levels to communicate pool state.
  225. + * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
  226. + * states are software abstractions used at various levels to communicate
  227. + * pool state.
  228. */
  229. typedef enum pool_state {
  230. POOL_STATE_ACTIVE = 0, /* In active use */
  231. POOL_STATE_EXPORTED, /* Explicitly exported */
  232. POOL_STATE_DESTROYED, /* Explicitly destroyed */
  233. POOL_STATE_SPARE, /* Reserved for hot spare use */
  234. + POOL_STATE_L2CACHE, /* Level 2 ARC device */
  235. POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
  236. POOL_STATE_UNAVAIL, /* Internal libzfs state */
  237. POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
  238. @@ -1068,13 +1111,6 @@
  239. #define ZFS_FLAG_NOGROWBLOCKS 0x2
  240.  
  241. /*
  242. - * ZPL version - rev'd whenever an incompatible on-disk format change
  243. - * occurs. Independent of SPA/DMU/ZAP versioning.
  244. - */
  245. -
  246. -#define ZPL_VERSION 1ULL
  247. -
  248. -/*
  249. * The directory entry has the type (currently unused on Solaris) in the
  250. * top 4 bits, and the object number in the low 48 bits. The "middle"
  251. * 12 bits are unused.
  252.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement