aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h78
1 files changed, 74 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 8fd72331d600..0236d03c6732 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -173,6 +173,9 @@ static int btrfs_csum_sizes[] = { 4, 0 };
173#define BTRFS_FT_XATTR 8 173#define BTRFS_FT_XATTR 8
174#define BTRFS_FT_MAX 9 174#define BTRFS_FT_MAX 9
175 175
176/* ioprio of readahead is set to idle */
177#define BTRFS_IOPRIO_READA (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0))
178
176/* 179/*
177 * The key defines the order in the tree, and so it also defines (optimal) 180 * The key defines the order in the tree, and so it also defines (optimal)
178 * block layout. 181 * block layout.
@@ -823,6 +826,14 @@ struct btrfs_csum_item {
823 u8 csum; 826 u8 csum;
824} __attribute__ ((__packed__)); 827} __attribute__ ((__packed__));
825 828
829struct btrfs_dev_stats_item {
830 /*
831 * grow this item struct at the end for future enhancements and keep
832 * the existing values unchanged
833 */
834 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
835} __attribute__ ((__packed__));
836
826/* different types of block groups (and chunks) */ 837/* different types of block groups (and chunks) */
827#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) 838#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
828#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) 839#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
@@ -1129,6 +1140,15 @@ struct btrfs_fs_info {
1129 spinlock_t delayed_iput_lock; 1140 spinlock_t delayed_iput_lock;
1130 struct list_head delayed_iputs; 1141 struct list_head delayed_iputs;
1131 1142
1143 /* this protects tree_mod_seq_list */
1144 spinlock_t tree_mod_seq_lock;
1145 atomic_t tree_mod_seq;
1146 struct list_head tree_mod_seq_list;
1147
1148 /* this protects tree_mod_log */
1149 rwlock_t tree_mod_log_lock;
1150 struct rb_root tree_mod_log;
1151
1132 atomic_t nr_async_submits; 1152 atomic_t nr_async_submits;
1133 atomic_t async_submit_draining; 1153 atomic_t async_submit_draining;
1134 atomic_t nr_async_bios; 1154 atomic_t nr_async_bios;
@@ -1375,7 +1395,7 @@ struct btrfs_root {
1375 struct list_head root_list; 1395 struct list_head root_list;
1376 1396
1377 spinlock_t orphan_lock; 1397 spinlock_t orphan_lock;
1378 struct list_head orphan_list; 1398 atomic_t orphan_inodes;
1379 struct btrfs_block_rsv *orphan_block_rsv; 1399 struct btrfs_block_rsv *orphan_block_rsv;
1380 int orphan_item_inserted; 1400 int orphan_item_inserted;
1381 int orphan_cleanup_state; 1401 int orphan_cleanup_state;
@@ -1508,6 +1528,12 @@ struct btrfs_ioctl_defrag_range_args {
1508#define BTRFS_BALANCE_ITEM_KEY 248 1528#define BTRFS_BALANCE_ITEM_KEY 248
1509 1529
1510/* 1530/*
1531 * Persistantly stores the io stats in the device tree.
1532 * One key for all stats, (0, BTRFS_DEV_STATS_KEY, devid).
1533 */
1534#define BTRFS_DEV_STATS_KEY 249
1535
1536/*
1511 * string items are for debugging. They just store a short string of 1537 * string items are for debugging. They just store a short string of
1512 * data in the FS 1538 * data in the FS
1513 */ 1539 */
@@ -2415,6 +2441,30 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
2415 return btrfs_item_size(eb, e) - offset; 2441 return btrfs_item_size(eb, e) - offset;
2416} 2442}
2417 2443
2444/* btrfs_dev_stats_item */
2445static inline u64 btrfs_dev_stats_value(struct extent_buffer *eb,
2446 struct btrfs_dev_stats_item *ptr,
2447 int index)
2448{
2449 u64 val;
2450
2451 read_extent_buffer(eb, &val,
2452 offsetof(struct btrfs_dev_stats_item, values) +
2453 ((unsigned long)ptr) + (index * sizeof(u64)),
2454 sizeof(val));
2455 return val;
2456}
2457
2458static inline void btrfs_set_dev_stats_value(struct extent_buffer *eb,
2459 struct btrfs_dev_stats_item *ptr,
2460 int index, u64 val)
2461{
2462 write_extent_buffer(eb, &val,
2463 offsetof(struct btrfs_dev_stats_item, values) +
2464 ((unsigned long)ptr) + (index * sizeof(u64)),
2465 sizeof(val));
2466}
2467
2418static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb) 2468static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
2419{ 2469{
2420 return sb->s_fs_info; 2470 return sb->s_fs_info;
@@ -2496,11 +2546,11 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
2496 struct btrfs_root *root, u32 blocksize, 2546 struct btrfs_root *root, u32 blocksize,
2497 u64 parent, u64 root_objectid, 2547 u64 parent, u64 root_objectid,
2498 struct btrfs_disk_key *key, int level, 2548 struct btrfs_disk_key *key, int level,
2499 u64 hint, u64 empty_size, int for_cow); 2549 u64 hint, u64 empty_size);
2500void btrfs_free_tree_block(struct btrfs_trans_handle *trans, 2550void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
2501 struct btrfs_root *root, 2551 struct btrfs_root *root,
2502 struct extent_buffer *buf, 2552 struct extent_buffer *buf,
2503 u64 parent, int last_ref, int for_cow); 2553 u64 parent, int last_ref);
2504struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, 2554struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
2505 struct btrfs_root *root, 2555 struct btrfs_root *root,
2506 u64 bytenr, u32 blocksize, 2556 u64 bytenr, u32 blocksize,
@@ -2659,6 +2709,8 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
2659int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root 2709int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
2660 *root, struct btrfs_key *key, struct btrfs_path *p, int 2710 *root, struct btrfs_key *key, struct btrfs_path *p, int
2661 ins_len, int cow); 2711 ins_len, int cow);
2712int btrfs_search_old_slot(struct btrfs_root *root, struct btrfs_key *key,
2713 struct btrfs_path *p, u64 time_seq);
2662int btrfs_realloc_node(struct btrfs_trans_handle *trans, 2714int btrfs_realloc_node(struct btrfs_trans_handle *trans,
2663 struct btrfs_root *root, struct extent_buffer *parent, 2715 struct btrfs_root *root, struct extent_buffer *parent,
2664 int start_slot, int cache_only, u64 *last_ret, 2716 int start_slot, int cache_only, u64 *last_ret,
@@ -2922,7 +2974,6 @@ int btrfs_readpage(struct file *file, struct page *page);
2922void btrfs_evict_inode(struct inode *inode); 2974void btrfs_evict_inode(struct inode *inode);
2923int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); 2975int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc);
2924int btrfs_dirty_inode(struct inode *inode); 2976int btrfs_dirty_inode(struct inode *inode);
2925int btrfs_update_time(struct file *file);
2926struct inode *btrfs_alloc_inode(struct super_block *sb); 2977struct inode *btrfs_alloc_inode(struct super_block *sb);
2927void btrfs_destroy_inode(struct inode *inode); 2978void btrfs_destroy_inode(struct inode *inode);
2928int btrfs_drop_inode(struct inode *inode); 2979int btrfs_drop_inode(struct inode *inode);
@@ -3098,4 +3149,23 @@ void btrfs_reada_detach(void *handle);
3098int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, 3149int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
3099 u64 start, int err); 3150 u64 start, int err);
3100 3151
3152/* delayed seq elem */
3153struct seq_list {
3154 struct list_head list;
3155 u64 seq;
3156 u32 flags;
3157};
3158
3159void btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
3160 struct seq_list *elem);
3161void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
3162 struct seq_list *elem);
3163
3164static inline int is_fstree(u64 rootid)
3165{
3166 if (rootid == BTRFS_FS_TREE_OBJECTID ||
3167 (s64)rootid >= (s64)BTRFS_FIRST_FREE_OBJECTID)
3168 return 1;
3169 return 0;
3170}
3101#endif 3171#endif