Jorgen Lundman | 9b4a1f9 | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * GRUB -- GRand Unified Bootloader |
| 3 | * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Jorgen Lundman | 9b4a1f9 | 2012-07-19 20:48:25 +0000 | [diff] [blame] | 6 | */ |
| 7 | /* |
| 8 | * Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
| 9 | * Use is subject to license terms. |
| 10 | */ |
| 11 | |
| 12 | #ifndef _SYS_DNODE_H |
| 13 | #define _SYS_DNODE_H |
| 14 | |
| 15 | #include <zfs/spa.h> |
| 16 | |
| 17 | /* |
| 18 | * Fixed constants. |
| 19 | */ |
| 20 | #define DNODE_SHIFT 9 /* 512 bytes */ |
| 21 | #define DN_MIN_INDBLKSHIFT 10 /* 1k */ |
| 22 | #define DN_MAX_INDBLKSHIFT 14 /* 16k */ |
| 23 | #define DNODE_BLOCK_SHIFT 14 /* 16k */ |
| 24 | #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ |
| 25 | #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ |
| 26 | #define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ |
| 27 | |
| 28 | /* |
| 29 | * Derived constants. |
| 30 | */ |
| 31 | #define DNODE_SIZE (1 << DNODE_SHIFT) |
| 32 | #define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT) |
| 33 | #define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT)) |
| 34 | #define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT) |
| 35 | |
| 36 | #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) |
| 37 | #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) |
| 38 | #define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) |
| 39 | |
| 40 | #define DNODE_FLAG_SPILL_BLKPTR (1<<2) |
| 41 | |
| 42 | #define DN_BONUS(dnp) ((void *)((dnp)->dn_bonus + \ |
| 43 | (((dnp)->dn_nblkptr - 1) * sizeof(blkptr_t)))) |
| 44 | |
| 45 | typedef struct dnode_phys { |
| 46 | uint8_t dn_type; /* dmu_object_type_t */ |
| 47 | uint8_t dn_indblkshift; /* ln2(indirect block size) */ |
| 48 | uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */ |
| 49 | uint8_t dn_nblkptr; /* length of dn_blkptr */ |
| 50 | uint8_t dn_bonustype; /* type of data in bonus buffer */ |
| 51 | uint8_t dn_checksum; /* ZIO_CHECKSUM type */ |
| 52 | uint8_t dn_compress; /* ZIO_COMPRESS type */ |
| 53 | uint8_t dn_flags; /* DNODE_FLAG_* */ |
| 54 | uint16_t dn_datablkszsec; /* data block size in 512b sectors */ |
| 55 | uint16_t dn_bonuslen; /* length of dn_bonus */ |
| 56 | uint8_t dn_pad2[4]; |
| 57 | |
| 58 | /* accounting is protected by dn_dirty_mtx */ |
| 59 | uint64_t dn_maxblkid; /* largest allocated block ID */ |
| 60 | uint64_t dn_used; /* bytes (or sectors) of disk space */ |
| 61 | |
| 62 | uint64_t dn_pad3[4]; |
| 63 | |
| 64 | blkptr_t dn_blkptr[1]; |
| 65 | uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof(blkptr_t)]; |
| 66 | blkptr_t dn_spill; |
| 67 | } dnode_phys_t; |
| 68 | |
| 69 | #endif /* _SYS_DNODE_H */ |