dnode.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
  4. *
  5. * GRUB 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 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
  20. * Use is subject to license terms.
  21. */
  22. #ifndef _SYS_DNODE_H
  23. #define _SYS_DNODE_H
  24. #include <grub/zfs/spa.h>
  25. /*
  26. * Fixed constants.
  27. */
  28. #define DNODE_SHIFT 9 /* 512 bytes */
  29. #define DNODE_BLOCK_SHIFT 14 /* 16k */
  30. #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */
  31. /*
  32. * Derived constants.
  33. */
  34. #define DNODE_SIZE (1 << DNODE_SHIFT)
  35. #define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
  36. #define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
  37. #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
  38. #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT)
  39. #define DNODE_FLAG_SPILL_BLKPTR (1<<2)
  40. #define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \
  41. (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
  42. typedef struct dnode_phys {
  43. grub_uint8_t dn_type; /* dmu_object_type_t */
  44. grub_uint8_t dn_indblkshift; /* ln2(indirect block size) */
  45. grub_uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */
  46. grub_uint8_t dn_nblkptr; /* length of dn_blkptr */
  47. grub_uint8_t dn_bonustype; /* type of data in bonus buffer */
  48. grub_uint8_t dn_checksum; /* ZIO_CHECKSUM type */
  49. grub_uint8_t dn_compress; /* ZIO_COMPRESS type */
  50. grub_uint8_t dn_flags; /* DNODE_FLAG_* */
  51. grub_uint16_t dn_datablkszsec; /* data block size in 512b sectors */
  52. grub_uint16_t dn_bonuslen; /* length of dn_bonus */
  53. grub_uint8_t dn_pad2[4];
  54. /* accounting is protected by dn_dirty_mtx */
  55. grub_uint64_t dn_maxblkid; /* largest allocated block ID */
  56. grub_uint64_t dn_used; /* bytes (or sectors) of disk space */
  57. grub_uint64_t dn_pad3[4];
  58. blkptr_t dn_blkptr[1];
  59. grub_uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof (blkptr_t)];
  60. blkptr_t dn_spill;
  61. } dnode_phys_t;
  62. #endif /* _SYS_DNODE_H */