diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 175 |
1 files changed, 169 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 7a3492d5888e..dbf3917833fe 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -132,6 +132,37 @@ struct btrfs_extent_item { | |||
132 | __le64 owner; | 132 | __le64 owner; |
133 | } __attribute__ ((__packed__)); | 133 | } __attribute__ ((__packed__)); |
134 | 134 | ||
135 | struct btrfs_inode_timespec { | ||
136 | __le32 sec; | ||
137 | __le32 nsec; | ||
138 | } __attribute__ ((__packed__)); | ||
139 | |||
140 | /* | ||
141 | * there is no padding here on purpose. If you want to extent the inode, | ||
142 | * make a new item type | ||
143 | */ | ||
144 | struct btrfs_inode_item { | ||
145 | __le64 generation; | ||
146 | __le64 size; | ||
147 | __le64 nblocks; | ||
148 | __le32 nlink; | ||
149 | __le32 uid; | ||
150 | __le32 gid; | ||
151 | __le32 mode; | ||
152 | __le32 rdev; | ||
153 | __le16 flags; | ||
154 | __le16 compat_flags; | ||
155 | struct btrfs_inode_timespec atime; | ||
156 | struct btrfs_inode_timespec ctime; | ||
157 | struct btrfs_inode_timespec mtime; | ||
158 | struct btrfs_inode_timespec otime; | ||
159 | } __attribute__ ((__packed__)); | ||
160 | |||
161 | /* inline data is just a blob of bytes */ | ||
162 | struct btrfs_inline_data_item { | ||
163 | u8 data; | ||
164 | } __attribute__ ((__packed__)); | ||
165 | |||
135 | struct btrfs_dir_item { | 166 | struct btrfs_dir_item { |
136 | __le64 objectid; | 167 | __le64 objectid; |
137 | __le16 flags; | 168 | __le16 flags; |
@@ -170,15 +201,149 @@ struct btrfs_root { | |||
170 | u32 blocksize; | 201 | u32 blocksize; |
171 | }; | 202 | }; |
172 | 203 | ||
173 | |||
174 | /* the lower bits in the key flags defines the item type */ | 204 | /* the lower bits in the key flags defines the item type */ |
175 | #define BTRFS_KEY_TYPE_MAX 256 | 205 | #define BTRFS_KEY_TYPE_MAX 256 |
176 | #define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1) | 206 | #define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1) |
207 | |||
208 | /* | ||
209 | * inode items have the data typically returned from stat and store other | ||
210 | * info about object characteristics. There is one for every file and dir in | ||
211 | * the FS | ||
212 | */ | ||
177 | #define BTRFS_INODE_ITEM_KEY 1 | 213 | #define BTRFS_INODE_ITEM_KEY 1 |
214 | |||
215 | /* | ||
216 | * dir items are the name -> inode pointers in a directory. There is one | ||
217 | * for every name in a directory. | ||
218 | */ | ||
178 | #define BTRFS_DIR_ITEM_KEY 2 | 219 | #define BTRFS_DIR_ITEM_KEY 2 |
179 | #define BTRFS_ROOT_ITEM_KEY 3 | 220 | /* |
180 | #define BTRFS_EXTENT_ITEM_KEY 4 | 221 | * inline data is file data that fits in the btree. |
181 | #define BTRFS_STRING_ITEM_KEY 5 | 222 | */ |
223 | #define BTRFS_INLINE_DATA_KEY 3 | ||
224 | /* | ||
225 | * extent data is for data that can't fit in the btree. It points to | ||
226 | * a (hopefully) huge chunk of disk | ||
227 | */ | ||
228 | #define BTRFS_EXTENT_DATA_KEY 4 | ||
229 | /* | ||
230 | * root items point to tree roots. There are typically in the root | ||
231 | * tree used by the super block to find all the other trees | ||
232 | */ | ||
233 | #define BTRFS_ROOT_ITEM_KEY 5 | ||
234 | /* | ||
235 | * extent items are in the extent map tree. These record which blocks | ||
236 | * are used, and how many references there are to each block | ||
237 | */ | ||
238 | #define BTRFS_EXTENT_ITEM_KEY 6 | ||
239 | /* | ||
240 | * string items are for debugging. They just store a short string of | ||
241 | * data in the FS | ||
242 | */ | ||
243 | #define BTRFS_STRING_ITEM_KEY 7 | ||
244 | |||
245 | static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) | ||
246 | { | ||
247 | return le64_to_cpu(i->generation); | ||
248 | } | ||
249 | |||
250 | static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i, | ||
251 | u64 val) | ||
252 | { | ||
253 | i->generation = cpu_to_le64(val); | ||
254 | } | ||
255 | |||
256 | static inline u64 btrfs_inode_size(struct btrfs_inode_item *i) | ||
257 | { | ||
258 | return le64_to_cpu(i->size); | ||
259 | } | ||
260 | |||
261 | static inline void btrfs_set_inode_size(struct btrfs_inode_item *i, u64 val) | ||
262 | { | ||
263 | i->size = cpu_to_le64(val); | ||
264 | } | ||
265 | |||
266 | static inline u64 btrfs_inode_nblocks(struct btrfs_inode_item *i) | ||
267 | { | ||
268 | return le64_to_cpu(i->nblocks); | ||
269 | } | ||
270 | |||
271 | static inline void btrfs_set_inode_nblocks(struct btrfs_inode_item *i, u64 val) | ||
272 | { | ||
273 | i->nblocks = cpu_to_le64(val); | ||
274 | } | ||
275 | |||
276 | static inline u32 btrfs_inode_nlink(struct btrfs_inode_item *i) | ||
277 | { | ||
278 | return le32_to_cpu(i->nlink); | ||
279 | } | ||
280 | |||
281 | static inline void btrfs_set_inode_nlink(struct btrfs_inode_item *i, u32 val) | ||
282 | { | ||
283 | i->nlink = cpu_to_le32(val); | ||
284 | } | ||
285 | |||
286 | static inline u32 btrfs_inode_uid(struct btrfs_inode_item *i) | ||
287 | { | ||
288 | return le32_to_cpu(i->uid); | ||
289 | } | ||
290 | |||
291 | static inline void btrfs_set_inode_uid(struct btrfs_inode_item *i, u32 val) | ||
292 | { | ||
293 | i->uid = cpu_to_le32(val); | ||
294 | } | ||
295 | |||
296 | static inline u32 btrfs_inode_gid(struct btrfs_inode_item *i) | ||
297 | { | ||
298 | return le32_to_cpu(i->gid); | ||
299 | } | ||
300 | |||
301 | static inline void btrfs_set_inode_gid(struct btrfs_inode_item *i, u32 val) | ||
302 | { | ||
303 | i->gid = cpu_to_le32(val); | ||
304 | } | ||
305 | |||
306 | static inline u32 btrfs_inode_mode(struct btrfs_inode_item *i) | ||
307 | { | ||
308 | return le32_to_cpu(i->mode); | ||
309 | } | ||
310 | |||
311 | static inline void btrfs_set_inode_mode(struct btrfs_inode_item *i, u32 val) | ||
312 | { | ||
313 | i->mode = cpu_to_le32(val); | ||
314 | } | ||
315 | |||
316 | static inline u32 btrfs_inode_rdev(struct btrfs_inode_item *i) | ||
317 | { | ||
318 | return le32_to_cpu(i->rdev); | ||
319 | } | ||
320 | |||
321 | static inline void btrfs_set_inode_rdev(struct btrfs_inode_item *i, u32 val) | ||
322 | { | ||
323 | i->rdev = cpu_to_le32(val); | ||
324 | } | ||
325 | |||
326 | static inline u16 btrfs_inode_flags(struct btrfs_inode_item *i) | ||
327 | { | ||
328 | return le16_to_cpu(i->flags); | ||
329 | } | ||
330 | |||
331 | static inline void btrfs_set_inode_flags(struct btrfs_inode_item *i, u16 val) | ||
332 | { | ||
333 | i->flags = cpu_to_le16(val); | ||
334 | } | ||
335 | |||
336 | static inline u16 btrfs_inode_compat_flags(struct btrfs_inode_item *i) | ||
337 | { | ||
338 | return le16_to_cpu(i->compat_flags); | ||
339 | } | ||
340 | |||
341 | static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item *i, | ||
342 | u16 val) | ||
343 | { | ||
344 | i->compat_flags = cpu_to_le16(val); | ||
345 | } | ||
346 | |||
182 | 347 | ||
183 | static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei) | 348 | static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei) |
184 | { | 349 | { |
@@ -344,8 +509,6 @@ static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u32 type) | |||
344 | btrfs_set_disk_key_flags(key, flags); | 509 | btrfs_set_disk_key_flags(key, flags); |
345 | } | 510 | } |
346 | 511 | ||
347 | |||
348 | |||
349 | static inline u64 btrfs_header_blocknr(struct btrfs_header *h) | 512 | static inline u64 btrfs_header_blocknr(struct btrfs_header *h) |
350 | { | 513 | { |
351 | return le64_to_cpu(h->blocknr); | 514 | return le64_to_cpu(h->blocknr); |