aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-24 15:01:56 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:00 -0400
commit0b86a832a1f38abec695864ec2eaedc9d2383f1b (patch)
tree8ec0db0b55f77eb6a23fe7db3c1064d298db55c1 /fs/btrfs/ctree.h
parent7f93bf8d27653726e3721c01fefc523487ecf2af (diff)
Btrfs: Add support for multiple devices per filesystem
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h313
1 files changed, 286 insertions, 27 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 92d892f92075..1453d995fef6 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -40,12 +40,44 @@ extern struct kmem_cache *btrfs_path_cachep;
40#define BTRFS_MAGIC "_B4RfS_M" 40#define BTRFS_MAGIC "_B4RfS_M"
41 41
42#define BTRFS_MAX_LEVEL 8 42#define BTRFS_MAX_LEVEL 8
43
44/* holds pointers to all of the tree roots */
43#define BTRFS_ROOT_TREE_OBJECTID 1ULL 45#define BTRFS_ROOT_TREE_OBJECTID 1ULL
46
47/* stores information about which extents are in use, and reference counts */
44#define BTRFS_EXTENT_TREE_OBJECTID 2ULL 48#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
49
50/* one per subvolume, storing files and directories */
45#define BTRFS_FS_TREE_OBJECTID 3ULL 51#define BTRFS_FS_TREE_OBJECTID 3ULL
52
53/* directory objectid inside the root tree */
46#define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL 54#define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
55
56
57/*
58 * chunk tree stores translations from logical -> physical block numbering
59 * the super block points to the chunk tree
60 */
61#define BTRFS_CHUNK_TREE_OBJECTID 5ULL
62
63/*
64 * stores information about which areas of a given device are in use.
65 * one per device. The tree of tree roots points to the device tree
66 */
67#define BTRFS_DEV_TREE_OBJECTID 6ULL
68
69/*
70 * All files have objectids higher than this.
71 */
47#define BTRFS_FIRST_FREE_OBJECTID 256ULL 72#define BTRFS_FIRST_FREE_OBJECTID 256ULL
48 73
74
75/*
76 * the device items go into the chunk tree. The key is in the form
77 * [ 1 BTRFS_DEV_ITEM_KEY device_id ]
78 */
79#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
80
49/* 81/*
50 * we can actually store much bigger names, but lets not confuse the rest 82 * we can actually store much bigger names, but lets not confuse the rest
51 * of linux 83 * of linux
@@ -95,6 +127,81 @@ struct btrfs_key {
95 u64 offset; 127 u64 offset;
96} __attribute__ ((__packed__)); 128} __attribute__ ((__packed__));
97 129
130struct btrfs_mapping_tree {
131 struct extent_map_tree map_tree;
132};
133
134#define BTRFS_DEV_UUID_SIZE 16
135struct btrfs_dev_item {
136 /* the internal btrfs device id */
137 __le64 devid;
138
139 /* size of the device */
140 __le64 total_bytes;
141
142 /* bytes used */
143 __le64 bytes_used;
144
145 /* optimal io alignment for this device */
146 __le32 io_align;
147
148 /* optimal io width for this device */
149 __le32 io_width;
150
151 /* minimal io size for this device */
152 __le32 sector_size;
153
154 /* the kernel device number */
155 __le64 rdev;
156
157 /* type and info about this device */
158 __le64 type;
159
160 /* partition number, 0 for whole dev */
161 __le32 partition;
162
163 /* length of the name data at the end of the item */
164 __le16 name_len;
165
166 /* physical drive uuid (or lvm uuid) */
167 u8 uuid[BTRFS_DEV_UUID_SIZE];
168 /* name goes here */
169} __attribute__ ((__packed__));
170
171struct btrfs_stripe {
172 __le64 devid;
173 __le64 offset;
174} __attribute__ ((__packed__));
175
176struct btrfs_chunk {
177 __le64 owner;
178 __le64 stripe_len;
179 __le64 type;
180
181 /* optimal io alignment for this chunk */
182 __le32 io_align;
183
184 /* optimal io width for this chunk */
185 __le32 io_width;
186
187 /* minimal io size for this chunk */
188 __le32 sector_size;
189
190 /* 2^16 stripes is quite a lot, a second limit is the size of a single
191 * item in the btree
192 */
193 __le16 num_stripes;
194 struct btrfs_stripe stripe;
195 /* additional stripes go here */
196} __attribute__ ((__packed__));
197
198static inline unsigned long btrfs_chunk_item_size(int num_stripes)
199{
200 BUG_ON(num_stripes == 0);
201 return sizeof(struct btrfs_chunk) +
202 sizeof(struct btrfs_stripe) * (num_stripes - 1);
203}
204
98#define BTRFS_FSID_SIZE 16 205#define BTRFS_FSID_SIZE 16
99/* 206/*
100 * every tree block (leaf or node) starts with this header. 207 * every tree block (leaf or node) starts with this header.
@@ -119,6 +226,13 @@ struct btrfs_header {
119 sizeof(struct btrfs_item) - \ 226 sizeof(struct btrfs_item) - \
120 sizeof(struct btrfs_file_extent_item)) 227 sizeof(struct btrfs_file_extent_item))
121 228
229
230/*
231 * this is a very generous portion of the super block, giving us
232 * room to translate 14 chunks with 3 stripes each.
233 */
234#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
235
122/* 236/*
123 * the super block basically lists the main trees of the FS 237 * the super block basically lists the main trees of the FS
124 * it currently lacks any block count etc etc 238 * it currently lacks any block count etc etc
@@ -131,6 +245,7 @@ struct btrfs_super_block {
131 __le64 magic; 245 __le64 magic;
132 __le64 generation; 246 __le64 generation;
133 __le64 root; 247 __le64 root;
248 __le64 chunk_root;
134 __le64 total_bytes; 249 __le64 total_bytes;
135 __le64 bytes_used; 250 __le64 bytes_used;
136 __le64 root_dir_objectid; 251 __le64 root_dir_objectid;
@@ -138,7 +253,10 @@ struct btrfs_super_block {
138 __le32 nodesize; 253 __le32 nodesize;
139 __le32 leafsize; 254 __le32 leafsize;
140 __le32 stripesize; 255 __le32 stripesize;
256 __le32 sys_chunk_array_size;
141 u8 root_level; 257 u8 root_level;
258 u8 chunk_root_level;
259 u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
142} __attribute__ ((__packed__)); 260} __attribute__ ((__packed__));
143 261
144/* 262/*
@@ -208,12 +326,22 @@ struct btrfs_extent_ref {
208 __le64 offset; 326 __le64 offset;
209} __attribute__ ((__packed__)); 327} __attribute__ ((__packed__));
210 328
329/* dev extents record free space on individual devices. The owner
330 * field points back to the chunk allocation mapping tree that allocated
331 * the extent
332 */
333struct btrfs_dev_extent {
334 __le64 owner;
335 __le64 length;
336} __attribute__ ((__packed__));
337
338
211struct btrfs_inode_ref { 339struct btrfs_inode_ref {
212 __le16 name_len; 340 __le16 name_len;
213 /* name goes here */ 341 /* name goes here */
214} __attribute__ ((__packed__)); 342} __attribute__ ((__packed__));
215 343
216struct btrfs_inode_timespec { 344struct btrfs_timespec {
217 __le64 sec; 345 __le64 sec;
218 __le32 nsec; 346 __le32 nsec;
219} __attribute__ ((__packed__)); 347} __attribute__ ((__packed__));
@@ -231,13 +359,13 @@ struct btrfs_inode_item {
231 __le32 uid; 359 __le32 uid;
232 __le32 gid; 360 __le32 gid;
233 __le32 mode; 361 __le32 mode;
234 __le32 rdev; 362 __le64 rdev;
235 __le16 flags; 363 __le16 flags;
236 __le16 compat_flags; 364 __le16 compat_flags;
237 struct btrfs_inode_timespec atime; 365 struct btrfs_timespec atime;
238 struct btrfs_inode_timespec ctime; 366 struct btrfs_timespec ctime;
239 struct btrfs_inode_timespec mtime; 367 struct btrfs_timespec mtime;
240 struct btrfs_inode_timespec otime; 368 struct btrfs_timespec otime;
241} __attribute__ ((__packed__)); 369} __attribute__ ((__packed__));
242 370
243struct btrfs_dir_item { 371struct btrfs_dir_item {
@@ -290,29 +418,34 @@ struct btrfs_csum_item {
290 u8 csum; 418 u8 csum;
291} __attribute__ ((__packed__)); 419} __attribute__ ((__packed__));
292 420
293/* tag for the radix tree of block groups in ram */ 421/* different types of block groups (and chunks) */
294#define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024) 422#define BTRFS_BLOCK_GROUP_DATA (1 << 0)
295 423#define BTRFS_BLOCK_GROUP_SYSTEM (1 << 1)
424#define BTRFS_BLOCK_GROUP_METADATA (1 << 2)
296 425
297#define BTRFS_BLOCK_GROUP_DATA 1
298#define BTRFS_BLOCK_GROUP_MIXED 2
299 426
300struct btrfs_block_group_item { 427struct btrfs_block_group_item {
301 __le64 used; 428 __le64 used;
302 u8 flags; 429 __le64 chunk_tree;
430 __le64 chunk_objectid;
431 __le64 flags;
303} __attribute__ ((__packed__)); 432} __attribute__ ((__packed__));
304 433
305struct btrfs_block_group_cache { 434struct btrfs_block_group_cache {
306 struct btrfs_key key; 435 struct btrfs_key key;
307 struct btrfs_block_group_item item; 436 struct btrfs_block_group_item item;
308 int data;
309 int cached;
310 u64 pinned; 437 u64 pinned;
438 u64 flags;
439 int cached;
311}; 440};
441
442struct btrfs_device;
312struct btrfs_fs_info { 443struct btrfs_fs_info {
313 u8 fsid[BTRFS_FSID_SIZE]; 444 u8 fsid[BTRFS_FSID_SIZE];
314 struct btrfs_root *extent_root; 445 struct btrfs_root *extent_root;
315 struct btrfs_root *tree_root; 446 struct btrfs_root *tree_root;
447 struct btrfs_root *chunk_root;
448 struct btrfs_root *dev_root;
316 struct radix_tree_root fs_roots_radix; 449 struct radix_tree_root fs_roots_radix;
317 450
318 struct extent_io_tree free_space_cache; 451 struct extent_io_tree free_space_cache;
@@ -321,6 +454,9 @@ struct btrfs_fs_info {
321 struct extent_io_tree pending_del; 454 struct extent_io_tree pending_del;
322 struct extent_io_tree extent_ins; 455 struct extent_io_tree extent_ins;
323 456
457 /* logical->physical extent mapping */
458 struct btrfs_mapping_tree mapping_tree;
459
324 u64 generation; 460 u64 generation;
325 u64 last_trans_committed; 461 u64 last_trans_committed;
326 unsigned long mount_opt; 462 unsigned long mount_opt;
@@ -330,6 +466,7 @@ struct btrfs_fs_info {
330 struct btrfs_transaction *running_transaction; 466 struct btrfs_transaction *running_transaction;
331 struct btrfs_super_block super_copy; 467 struct btrfs_super_block super_copy;
332 struct extent_buffer *sb_buffer; 468 struct extent_buffer *sb_buffer;
469 struct block_device *__bdev;
333 struct super_block *sb; 470 struct super_block *sb;
334 struct inode *btree_inode; 471 struct inode *btree_inode;
335 spinlock_t hash_lock; 472 spinlock_t hash_lock;
@@ -350,12 +487,17 @@ struct btrfs_fs_info {
350 unsigned long throttles; 487 unsigned long throttles;
351 488
352 u64 total_pinned; 489 u64 total_pinned;
490 struct list_head dirty_cowonly_roots;
491
492 struct list_head devices;
493 struct list_head *last_device;
353 spinlock_t delalloc_lock; 494 spinlock_t delalloc_lock;
354 spinlock_t new_trans_lock; 495 spinlock_t new_trans_lock;
355 u64 delalloc_bytes; 496 u64 delalloc_bytes;
356 u64 last_alloc; 497 u64 last_alloc;
357 u64 last_data_alloc; 498 u64 last_data_alloc;
358}; 499};
500
359/* 501/*
360 * in ram representation of the tree. extent_root is used for all allocations 502 * in ram representation of the tree. extent_root is used for all allocations
361 * and for the extent tree extent_root root. 503 * and for the extent tree extent_root root.
@@ -387,14 +529,19 @@ struct btrfs_root {
387 u64 highest_inode; 529 u64 highest_inode;
388 u64 last_inode_alloc; 530 u64 last_inode_alloc;
389 int ref_cows; 531 int ref_cows;
532 int track_dirty;
390 struct btrfs_key defrag_progress; 533 struct btrfs_key defrag_progress;
391 int defrag_running; 534 int defrag_running;
392 int defrag_level; 535 int defrag_level;
393 char *name; 536 char *name;
394 int in_sysfs; 537 int in_sysfs;
538
539 /* the dirty list is only used by non-reference counted roots */
540 struct list_head dirty_list;
395}; 541};
396 542
397/* 543/*
544
398 * inode items have the data typically returned from stat and store other 545 * inode items have the data typically returned from stat and store other
399 * info about object characteristics. There is one for every file and dir in 546 * info about object characteristics. There is one for every file and dir in
400 * the FS 547 * the FS
@@ -439,6 +586,10 @@ struct btrfs_root {
439 */ 586 */
440#define BTRFS_BLOCK_GROUP_ITEM_KEY 50 587#define BTRFS_BLOCK_GROUP_ITEM_KEY 50
441 588
589#define BTRFS_DEV_EXTENT_KEY 75
590#define BTRFS_DEV_ITEM_KEY 76
591#define BTRFS_CHUNK_ITEM_KEY 77
592
442/* 593/*
443 * string items are for debugging. They just store a short string of 594 * string items are for debugging. They just store a short string of
444 * data in the FS 595 * data in the FS
@@ -518,13 +669,104 @@ static inline void btrfs_set_##name(type *s, u##bits val) \
518 s->member = cpu_to_le##bits(val); \ 669 s->member = cpu_to_le##bits(val); \
519} 670}
520 671
672BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64);
673BTRFS_SETGET_FUNCS(device_total_bytes, struct btrfs_dev_item, total_bytes, 64);
674BTRFS_SETGET_FUNCS(device_bytes_used, struct btrfs_dev_item, bytes_used, 64);
675BTRFS_SETGET_FUNCS(device_io_align, struct btrfs_dev_item, io_align, 32);
676BTRFS_SETGET_FUNCS(device_io_width, struct btrfs_dev_item, io_width, 32);
677BTRFS_SETGET_FUNCS(device_sector_size, struct btrfs_dev_item, sector_size, 32);
678BTRFS_SETGET_FUNCS(device_id, struct btrfs_dev_item, devid, 64);
679BTRFS_SETGET_FUNCS(device_rdev, struct btrfs_dev_item, rdev, 64);
680BTRFS_SETGET_FUNCS(device_partition, struct btrfs_dev_item, partition, 32);
681BTRFS_SETGET_FUNCS(device_name_len, struct btrfs_dev_item, name_len, 16);
682
683static inline char *btrfs_device_uuid(struct btrfs_dev_item *d)
684{
685 return (char *)d + offsetof(struct btrfs_dev_item, uuid);
686}
687
688static inline char *btrfs_device_name(struct btrfs_dev_item *d)
689{
690 return (char *)(d + 1);
691}
692
693BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64);
694BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64);
695BTRFS_SETGET_FUNCS(chunk_io_align, struct btrfs_chunk, io_align, 32);
696BTRFS_SETGET_FUNCS(chunk_io_width, struct btrfs_chunk, io_width, 32);
697BTRFS_SETGET_FUNCS(chunk_sector_size, struct btrfs_chunk, sector_size, 32);
698BTRFS_SETGET_FUNCS(chunk_type, struct btrfs_chunk, type, 64);
699BTRFS_SETGET_FUNCS(chunk_num_stripes, struct btrfs_chunk, num_stripes, 16);
700BTRFS_SETGET_FUNCS(stripe_devid, struct btrfs_stripe, devid, 64);
701BTRFS_SETGET_FUNCS(stripe_offset, struct btrfs_stripe, offset, 64);
702
703BTRFS_SETGET_STACK_FUNCS(stack_chunk_owner, struct btrfs_chunk, owner, 64);
704BTRFS_SETGET_STACK_FUNCS(stack_chunk_stripe_len, struct btrfs_chunk,
705 stripe_len, 64);
706BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_align, struct btrfs_chunk,
707 io_align, 32);
708BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_width, struct btrfs_chunk,
709 io_width, 32);
710BTRFS_SETGET_STACK_FUNCS(stack_chunk_sector_size, struct btrfs_chunk,
711 sector_size, 32);
712BTRFS_SETGET_STACK_FUNCS(stack_chunk_type, struct btrfs_chunk, type, 64);
713BTRFS_SETGET_STACK_FUNCS(stack_chunk_num_stripes, struct btrfs_chunk,
714 num_stripes, 16);
715BTRFS_SETGET_STACK_FUNCS(stack_stripe_devid, struct btrfs_stripe, devid, 64);
716BTRFS_SETGET_STACK_FUNCS(stack_stripe_offset, struct btrfs_stripe, offset, 64);
717
718static inline struct btrfs_stripe *btrfs_stripe_nr(struct btrfs_chunk *c,
719 int nr)
720{
721 unsigned long offset = (unsigned long)c;
722 offset += offsetof(struct btrfs_chunk, stripe);
723 offset += nr * sizeof(struct btrfs_stripe);
724 return (struct btrfs_stripe *)offset;
725}
726
727static inline u64 btrfs_stripe_offset_nr(struct extent_buffer *eb,
728 struct btrfs_chunk *c, int nr)
729{
730 return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr));
731}
732
733static inline void btrfs_set_stripe_offset_nr(struct extent_buffer *eb,
734 struct btrfs_chunk *c, int nr,
735 u64 val)
736{
737 btrfs_set_stripe_offset(eb, btrfs_stripe_nr(c, nr), val);
738}
739
740static inline u64 btrfs_stripe_devid_nr(struct extent_buffer *eb,
741 struct btrfs_chunk *c, int nr)
742{
743 return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr));
744}
745
746static inline void btrfs_set_stripe_devid_nr(struct extent_buffer *eb,
747 struct btrfs_chunk *c, int nr,
748 u64 val)
749{
750 btrfs_set_stripe_devid(eb, btrfs_stripe_nr(c, nr), val);
751}
752
521/* struct btrfs_block_group_item */ 753/* struct btrfs_block_group_item */
522BTRFS_SETGET_STACK_FUNCS(block_group_used, struct btrfs_block_group_item, 754BTRFS_SETGET_STACK_FUNCS(block_group_used, struct btrfs_block_group_item,
523 used, 64); 755 used, 64);
524BTRFS_SETGET_FUNCS(disk_block_group_used, struct btrfs_block_group_item, 756BTRFS_SETGET_FUNCS(disk_block_group_used, struct btrfs_block_group_item,
525 used, 64); 757 used, 64);
526BTRFS_SETGET_FUNCS(disk_block_group_flags, struct btrfs_block_group_item, 758BTRFS_SETGET_STACK_FUNCS(block_group_chunk_tree, struct btrfs_block_group_item,
527 flags, 8); 759 chunk_tree, 64);
760BTRFS_SETGET_FUNCS(disk_block_group_chunk_tree, struct btrfs_block_group_item,
761 chunk_tree, 64);
762BTRFS_SETGET_STACK_FUNCS(block_group_chunk_objectid,
763 struct btrfs_block_group_item, chunk_objectid, 64);
764BTRFS_SETGET_FUNCS(disk_block_group_chunk_objecitd,
765 struct btrfs_block_group_item, chunk_objectid, 64);
766BTRFS_SETGET_FUNCS(disk_block_group_flags,
767 struct btrfs_block_group_item, flags, 64);
768BTRFS_SETGET_STACK_FUNCS(block_group_flags,
769 struct btrfs_block_group_item, flags, 64);
528 770
529/* struct btrfs_inode_ref */ 771/* struct btrfs_inode_ref */
530BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16); 772BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
@@ -538,49 +780,53 @@ BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
538BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32); 780BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
539BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32); 781BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
540BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32); 782BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
541BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 32); 783BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
542BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 16); 784BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 16);
543BTRFS_SETGET_FUNCS(inode_compat_flags, struct btrfs_inode_item, 785BTRFS_SETGET_FUNCS(inode_compat_flags, struct btrfs_inode_item,
544 compat_flags, 16); 786 compat_flags, 16);
545 787
546static inline struct btrfs_inode_timespec * 788static inline struct btrfs_timespec *
547btrfs_inode_atime(struct btrfs_inode_item *inode_item) 789btrfs_inode_atime(struct btrfs_inode_item *inode_item)
548{ 790{
549 unsigned long ptr = (unsigned long)inode_item; 791 unsigned long ptr = (unsigned long)inode_item;
550 ptr += offsetof(struct btrfs_inode_item, atime); 792 ptr += offsetof(struct btrfs_inode_item, atime);
551 return (struct btrfs_inode_timespec *)ptr; 793 return (struct btrfs_timespec *)ptr;
552} 794}
553 795
554static inline struct btrfs_inode_timespec * 796static inline struct btrfs_timespec *
555btrfs_inode_mtime(struct btrfs_inode_item *inode_item) 797btrfs_inode_mtime(struct btrfs_inode_item *inode_item)
556{ 798{
557 unsigned long ptr = (unsigned long)inode_item; 799 unsigned long ptr = (unsigned long)inode_item;
558 ptr += offsetof(struct btrfs_inode_item, mtime); 800 ptr += offsetof(struct btrfs_inode_item, mtime);
559 return (struct btrfs_inode_timespec *)ptr; 801 return (struct btrfs_timespec *)ptr;
560} 802}
561 803
562static inline struct btrfs_inode_timespec * 804static inline struct btrfs_timespec *
563btrfs_inode_ctime(struct btrfs_inode_item *inode_item) 805btrfs_inode_ctime(struct btrfs_inode_item *inode_item)
564{ 806{
565 unsigned long ptr = (unsigned long)inode_item; 807 unsigned long ptr = (unsigned long)inode_item;
566 ptr += offsetof(struct btrfs_inode_item, ctime); 808 ptr += offsetof(struct btrfs_inode_item, ctime);
567 return (struct btrfs_inode_timespec *)ptr; 809 return (struct btrfs_timespec *)ptr;
568} 810}
569 811
570static inline struct btrfs_inode_timespec * 812static inline struct btrfs_timespec *
571btrfs_inode_otime(struct btrfs_inode_item *inode_item) 813btrfs_inode_otime(struct btrfs_inode_item *inode_item)
572{ 814{
573 unsigned long ptr = (unsigned long)inode_item; 815 unsigned long ptr = (unsigned long)inode_item;
574 ptr += offsetof(struct btrfs_inode_item, otime); 816 ptr += offsetof(struct btrfs_inode_item, otime);
575 return (struct btrfs_inode_timespec *)ptr; 817 return (struct btrfs_timespec *)ptr;
576} 818}
577 819
578BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_inode_timespec, sec, 64); 820BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
579BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_inode_timespec, nsec, 32); 821BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
580 822
581/* struct btrfs_extent_item */ 823/* struct btrfs_extent_item */
582BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); 824BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32);
583 825
826/* struct btrfs_dev_extent */
827BTRFS_SETGET_FUNCS(dev_extent_owner, struct btrfs_dev_extent, owner, 64);
828BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64);
829
584/* struct btrfs_extent_ref */ 830/* struct btrfs_extent_ref */
585BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64); 831BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64);
586BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64); 832BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64);
@@ -846,8 +1092,14 @@ BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64);
846BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block, 1092BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block,
847 generation, 64); 1093 generation, 64);
848BTRFS_SETGET_STACK_FUNCS(super_root, struct btrfs_super_block, root, 64); 1094BTRFS_SETGET_STACK_FUNCS(super_root, struct btrfs_super_block, root, 64);
1095BTRFS_SETGET_STACK_FUNCS(super_sys_array_size,
1096 struct btrfs_super_block, sys_chunk_array_size, 32);
849BTRFS_SETGET_STACK_FUNCS(super_root_level, struct btrfs_super_block, 1097BTRFS_SETGET_STACK_FUNCS(super_root_level, struct btrfs_super_block,
850 root_level, 8); 1098 root_level, 8);
1099BTRFS_SETGET_STACK_FUNCS(super_chunk_root, struct btrfs_super_block,
1100 chunk_root, 64);
1101BTRFS_SETGET_STACK_FUNCS(super_chunk_root_level, struct btrfs_super_block,
1102 chunk_root_level, 64);
851BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block, 1103BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block,
852 total_bytes, 64); 1104 total_bytes, 64);
853BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block, 1105BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block,
@@ -1009,7 +1261,14 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1009 struct btrfs_root *root); 1261 struct btrfs_root *root);
1010int btrfs_free_block_groups(struct btrfs_fs_info *info); 1262int btrfs_free_block_groups(struct btrfs_fs_info *info);
1011int btrfs_read_block_groups(struct btrfs_root *root); 1263int btrfs_read_block_groups(struct btrfs_root *root);
1264int btrfs_make_block_group(struct btrfs_trans_handle *trans,
1265 struct btrfs_root *root, u64 bytes_used,
1266 u64 type, u64 chunk_tree, u64 chunk_objectid,
1267 u64 size);
1012/* ctree.c */ 1268/* ctree.c */
1269int btrfs_previous_item(struct btrfs_root *root,
1270 struct btrfs_path *path, u64 min_objectid,
1271 int type);
1013int btrfs_cow_block(struct btrfs_trans_handle *trans, 1272int btrfs_cow_block(struct btrfs_trans_handle *trans,
1014 struct btrfs_root *root, struct extent_buffer *buf, 1273 struct btrfs_root *root, struct extent_buffer *buf,
1015 struct extent_buffer *parent, int parent_slot, 1274 struct extent_buffer *parent, int parent_slot,