diff options
author | Josef Bacik <jbacik@redhat.com> | 2007-08-29 15:47:34 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-08-29 15:47:34 -0400 |
commit | 58176a9604c5db1784d2c979aea472b3be40b6f0 (patch) | |
tree | a0d887c81b2f174de619dfefca19674a43756971 /fs/btrfs/ctree.h | |
parent | b888db2bd7b67f190b32934e6a86181f262ac3ec (diff) |
Btrfs: Add per-root block accounting and sysfs entries
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 947f061ed118..ffeee546a0d7 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <linux/completion.h> | ||
25 | #include "bit-radix.h" | 26 | #include "bit-radix.h" |
26 | 27 | ||
27 | struct btrfs_trans_handle; | 28 | struct btrfs_trans_handle; |
@@ -313,6 +314,8 @@ struct btrfs_fs_info { | |||
313 | struct list_head trans_list; | 314 | struct list_head trans_list; |
314 | struct list_head dead_roots; | 315 | struct list_head dead_roots; |
315 | struct delayed_work trans_work; | 316 | struct delayed_work trans_work; |
317 | struct kobject super_kobj; | ||
318 | struct completion kobj_unregister; | ||
316 | int do_barriers; | 319 | int do_barriers; |
317 | int closing; | 320 | int closing; |
318 | }; | 321 | }; |
@@ -328,6 +331,8 @@ struct btrfs_root { | |||
328 | struct btrfs_key root_key; | 331 | struct btrfs_key root_key; |
329 | struct btrfs_fs_info *fs_info; | 332 | struct btrfs_fs_info *fs_info; |
330 | struct inode *inode; | 333 | struct inode *inode; |
334 | struct kobject root_kobj; | ||
335 | struct completion kobj_unregister; | ||
331 | u64 objectid; | 336 | u64 objectid; |
332 | u64 last_trans; | 337 | u64 last_trans; |
333 | u32 blocksize; | 338 | u32 blocksize; |
@@ -338,6 +343,7 @@ struct btrfs_root { | |||
338 | struct btrfs_key defrag_progress; | 343 | struct btrfs_key defrag_progress; |
339 | int defrag_running; | 344 | int defrag_running; |
340 | int defrag_level; | 345 | int defrag_level; |
346 | char *name; | ||
341 | }; | 347 | }; |
342 | 348 | ||
343 | /* the lower bits in the key flags defines the item type */ | 349 | /* the lower bits in the key flags defines the item type */ |
@@ -814,6 +820,28 @@ static inline void btrfs_set_root_flags(struct btrfs_root_item *item, u32 val) | |||
814 | item->flags = cpu_to_le32(val); | 820 | item->flags = cpu_to_le32(val); |
815 | } | 821 | } |
816 | 822 | ||
823 | static inline void btrfs_set_root_blocks_used(struct btrfs_root_item *item, | ||
824 | u64 val) | ||
825 | { | ||
826 | item->blocks_used = cpu_to_le64(val); | ||
827 | } | ||
828 | |||
829 | static inline u64 btrfs_root_blocks_used(struct btrfs_root_item *item) | ||
830 | { | ||
831 | return le64_to_cpu(item->blocks_used); | ||
832 | } | ||
833 | |||
834 | static inline void btrfs_set_root_block_limit(struct btrfs_root_item *item, | ||
835 | u64 val) | ||
836 | { | ||
837 | item->block_limit = cpu_to_le64(val); | ||
838 | } | ||
839 | |||
840 | static inline u64 btrfs_root_block_limit(struct btrfs_root_item *item) | ||
841 | { | ||
842 | return le64_to_cpu(item->block_limit); | ||
843 | } | ||
844 | |||
817 | static inline u64 btrfs_super_blocknr(struct btrfs_super_block *s) | 845 | static inline u64 btrfs_super_blocknr(struct btrfs_super_block *s) |
818 | { | 846 | { |
819 | return le64_to_cpu(s->blocknr); | 847 | return le64_to_cpu(s->blocknr); |
@@ -1014,6 +1042,23 @@ static inline void btrfs_memmove(struct btrfs_root *root, | |||
1014 | memmove(dst, src, nr); | 1042 | memmove(dst, src, nr); |
1015 | } | 1043 | } |
1016 | 1044 | ||
1045 | static inline int btrfs_set_root_name(struct btrfs_root *root, | ||
1046 | const char *name, int len) | ||
1047 | { | ||
1048 | /* if we already have a name just free it */ | ||
1049 | if (root->name) | ||
1050 | kfree(root->name); | ||
1051 | |||
1052 | root->name = kmalloc(len+1, GFP_KERNEL); | ||
1053 | if (!root->name) | ||
1054 | return -ENOMEM; | ||
1055 | |||
1056 | memcpy(root->name, name, len); | ||
1057 | root->name[len] ='\0'; | ||
1058 | |||
1059 | return 0; | ||
1060 | } | ||
1061 | |||
1017 | /* helper function to cast into the data area of the leaf. */ | 1062 | /* helper function to cast into the data area of the leaf. */ |
1018 | #define btrfs_item_ptr(leaf, slot, type) \ | 1063 | #define btrfs_item_ptr(leaf, slot, type) \ |
1019 | ((type *)(btrfs_leaf_data(leaf) + \ | 1064 | ((type *)(btrfs_leaf_data(leaf) + \ |
@@ -1191,4 +1236,13 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, | |||
1191 | /* tree-defrag.c */ | 1236 | /* tree-defrag.c */ |
1192 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | 1237 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
1193 | struct btrfs_root *root, int cache_only); | 1238 | struct btrfs_root *root, int cache_only); |
1239 | |||
1240 | /* sysfs.c */ | ||
1241 | int btrfs_init_sysfs(void); | ||
1242 | void btrfs_exit_sysfs(void); | ||
1243 | int btrfs_sysfs_add_super(struct btrfs_fs_info *fs); | ||
1244 | int btrfs_sysfs_add_root(struct btrfs_root *root); | ||
1245 | void btrfs_sysfs_del_root(struct btrfs_root *root); | ||
1246 | void btrfs_sysfs_del_super(struct btrfs_fs_info *root); | ||
1247 | |||
1194 | #endif | 1248 | #endif |