aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-12 12:29:44 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-12 12:29:44 -0400
commitbb492bb0a5453222109a72859353728959c2539d (patch)
tree06acf6a77c6c554ddd720cbcc5fd843a4d2a8cb8 /fs/btrfs/ctree.h
parent7518a238ea0152dc849d1ed76d3cae8b44e12f46 (diff)
Btrfs: Add sparse endian annotations to struct header
rename struct header to btrfs_header Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h65
1 files changed, 33 insertions, 32 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 60c21fe1566a..e1aaca66d590 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -24,19 +24,19 @@ struct key {
24/* 24/*
25 * every tree block (leaf or node) starts with this header. 25 * every tree block (leaf or node) starts with this header.
26 */ 26 */
27struct header { 27struct btrfs_header {
28 u64 fsid[2]; /* FS specific uuid */ 28 __le64 fsid[2]; /* FS specific uuid */
29 u64 blocknr; /* which block this node is supposed to live in */ 29 __le64 blocknr; /* which block this node is supposed to live in */
30 u64 parentid; /* objectid of the tree root */ 30 __le64 parentid; /* objectid of the tree root */
31 u32 csum; 31 __le32 csum;
32 u32 ham; 32 __le32 ham;
33 u16 nritems; 33 __le16 nritems;
34 u16 flags; 34 __le16 flags;
35 /* generation flags to be added */ 35 /* generation flags to be added */
36} __attribute__ ((__packed__)); 36} __attribute__ ((__packed__));
37 37
38#define MAX_LEVEL 8 38#define MAX_LEVEL 8
39#define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct header)) / \ 39#define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) / \
40 (sizeof(struct key) + sizeof(u64))) 40 (sizeof(struct key) + sizeof(u64)))
41 41
42struct tree_buffer; 42struct tree_buffer;
@@ -100,12 +100,12 @@ struct item {
100 * The data is separate from the items to get the keys closer together 100 * The data is separate from the items to get the keys closer together
101 * during searches. 101 * during searches.
102 */ 102 */
103#define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct header)) 103#define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct btrfs_header))
104struct leaf { 104struct leaf {
105 struct header header; 105 struct btrfs_header header;
106 union { 106 union {
107 struct item items[LEAF_DATA_SIZE/sizeof(struct item)]; 107 struct item items[LEAF_DATA_SIZE/sizeof(struct item)];
108 u8 data[CTREE_BLOCKSIZE-sizeof(struct header)]; 108 u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)];
109 }; 109 };
110} __attribute__ ((__packed__)); 110} __attribute__ ((__packed__));
111 111
@@ -114,7 +114,7 @@ struct leaf {
114 * other blocks 114 * other blocks
115 */ 115 */
116struct node { 116struct node {
117 struct header header; 117 struct btrfs_header header;
118 struct key keys[NODEPTRS_PER_BLOCK]; 118 struct key keys[NODEPTRS_PER_BLOCK];
119 u64 blockptrs[NODEPTRS_PER_BLOCK]; 119 u64 blockptrs[NODEPTRS_PER_BLOCK];
120} __attribute__ ((__packed__)); 120} __attribute__ ((__packed__));
@@ -141,54 +141,55 @@ struct ctree_path {
141 int slots[MAX_LEVEL]; 141 int slots[MAX_LEVEL];
142}; 142};
143 143
144static inline u64 btrfs_header_blocknr(struct header *h) 144static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
145{ 145{
146 return h->blocknr; 146 return le64_to_cpu(h->blocknr);
147} 147}
148 148
149static inline void btrfs_set_header_blocknr(struct header *h, u64 blocknr) 149static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
150{ 150{
151 h->blocknr = blocknr; 151 h->blocknr = cpu_to_le64(blocknr);
152} 152}
153 153
154static inline u64 btrfs_header_parentid(struct header *h) 154static inline u64 btrfs_header_parentid(struct btrfs_header *h)
155{ 155{
156 return h->parentid; 156 return le64_to_cpu(h->parentid);
157} 157}
158 158
159static inline void btrfs_set_header_parentid(struct header *h, u64 parentid) 159static inline void btrfs_set_header_parentid(struct btrfs_header *h,
160 u64 parentid)
160{ 161{
161 h->parentid = parentid; 162 h->parentid = cpu_to_le64(parentid);
162} 163}
163 164
164static inline u32 btrfs_header_nritems(struct header *h) 165static inline u16 btrfs_header_nritems(struct btrfs_header *h)
165{ 166{
166 return h->nritems; 167 return le16_to_cpu(h->nritems);
167} 168}
168 169
169static inline void btrfs_set_header_nritems(struct header *h, u32 val) 170static inline void btrfs_set_header_nritems(struct btrfs_header *h, u16 val)
170{ 171{
171 h->nritems = val; 172 h->nritems = cpu_to_le16(val);
172} 173}
173 174
174static inline u32 btrfs_header_flags(struct header *h) 175static inline u16 btrfs_header_flags(struct btrfs_header *h)
175{ 176{
176 return h->flags; 177 return le16_to_cpu(h->flags);
177} 178}
178 179
179static inline void btrfs_set_header_flags(struct header *h, u32 val) 180static inline void btrfs_set_header_flags(struct btrfs_header *h, u16 val)
180{ 181{
181 h->flags = val; 182 h->flags = cpu_to_le16(val);
182} 183}
183 184
184static inline int btrfs_header_level(struct header *h) 185static inline int btrfs_header_level(struct btrfs_header *h)
185{ 186{
186 return btrfs_header_flags(h) & (MAX_LEVEL - 1); 187 return btrfs_header_flags(h) & (MAX_LEVEL - 1);
187} 188}
188 189
189static inline void btrfs_set_header_level(struct header *h, int level) 190static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
190{ 191{
191 u32 flags; 192 u16 flags;
192 BUG_ON(level > MAX_LEVEL); 193 BUG_ON(level > MAX_LEVEL);
193 flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1); 194 flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1);
194 btrfs_set_header_flags(h, flags | level); 195 btrfs_set_header_flags(h, flags | level);