~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/libfsimage/zfs/zfs-include/dnode.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 2007 Sun Microsystems, Inc.  All rights reserved.
 
21
 * Use is subject to license terms.
 
22
 */
 
23
 
 
24
#ifndef _SYS_DNODE_H
 
25
#define _SYS_DNODE_H
 
26
 
 
27
/*
 
28
 * Fixed constants.
 
29
 */
 
30
#define DNODE_SHIFT             9       /* 512 bytes */
 
31
#define DN_MIN_INDBLKSHIFT      10      /* 1k */
 
32
#define DN_MAX_INDBLKSHIFT      14      /* 16k */
 
33
#define DNODE_BLOCK_SHIFT       14      /* 16k */
 
34
#define DNODE_CORE_SIZE         64      /* 64 bytes for dnode sans blkptrs */
 
35
#define DN_MAX_OBJECT_SHIFT     48      /* 256 trillion (zfs_fid_t limit) */
 
36
#define DN_MAX_OFFSET_SHIFT     64      /* 2^64 bytes in a dnode */
 
37
 
 
38
/*
 
39
 * Derived constants.
 
40
 */
 
41
#define DNODE_SIZE      (1 << DNODE_SHIFT)
 
42
#define DN_MAX_NBLKPTR  ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
 
43
#define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
 
44
#define DN_MAX_OBJECT   (1ULL << DN_MAX_OBJECT_SHIFT)
 
45
 
 
46
#define DNODES_PER_BLOCK_SHIFT  (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
 
47
#define DNODES_PER_BLOCK        (1ULL << DNODES_PER_BLOCK_SHIFT)
 
48
#define DNODES_PER_LEVEL_SHIFT  (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
 
49
 
 
50
#define DN_BONUS(dnp)   ((void*)((dnp)->dn_bonus + \
 
51
        (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
 
52
 
 
53
typedef struct dnode_phys {
 
54
        uint8_t dn_type;                /* dmu_object_type_t */
 
55
        uint8_t dn_indblkshift;         /* ln2(indirect block size) */
 
56
        uint8_t dn_nlevels;             /* 1=dn_blkptr->data blocks */
 
57
        uint8_t dn_nblkptr;             /* length of dn_blkptr */
 
58
        uint8_t dn_bonustype;           /* type of data in bonus buffer */
 
59
        uint8_t dn_checksum;            /* ZIO_CHECKSUM type */
 
60
        uint8_t dn_compress;            /* ZIO_COMPRESS type */
 
61
        uint8_t dn_flags;               /* DNODE_FLAG_* */
 
62
        uint16_t dn_datablkszsec;       /* data block size in 512b sectors */
 
63
        uint16_t dn_bonuslen;           /* length of dn_bonus */
 
64
        uint8_t dn_pad2[4];
 
65
 
 
66
        /* accounting is protected by dn_dirty_mtx */
 
67
        uint64_t dn_maxblkid;           /* largest allocated block ID */
 
68
        uint64_t dn_used;               /* bytes (or sectors) of disk space */
 
69
 
 
70
        uint64_t dn_pad3[4];
 
71
 
 
72
        blkptr_t dn_blkptr[1];
 
73
        uint8_t dn_bonus[DN_MAX_BONUSLEN];
 
74
} dnode_phys_t;
 
75
 
 
76
#endif  /* _SYS_DNODE_H */