Btrfs: remove empty block groups automatically
[cascardo/linux.git] / fs / btrfs / ctree.h
index be91397..089f6da 100644 (file)
@@ -62,13 +62,6 @@ struct btrfs_ordered_sum;
 
 #define BTRFS_COMPAT_EXTENT_TREE_V0
 
-/*
- * files bigger than this get some pre-flushing when they are added
- * to the ordered operations list.  That way we limit the total
- * work done by the commit
- */
-#define BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT (8 * 1024 * 1024)
-
 /* holds pointers to all of the tree roots */
 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
 
@@ -391,10 +384,10 @@ struct btrfs_header {
                                      sizeof(struct btrfs_header)) / \
                                     sizeof(struct btrfs_key_ptr))
 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
-#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
+#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
                                        sizeof(struct btrfs_item) - \
-                                       sizeof(struct btrfs_file_extent_item))
+                                       offsetof(struct btrfs_file_extent_item, disk_bytenr))
 #define BTRFS_MAX_XATTR_SIZE(r)        (BTRFS_LEAF_DATA_SIZE(r) - \
                                 sizeof(struct btrfs_item) -\
                                 sizeof(struct btrfs_dir_item))
@@ -474,7 +467,7 @@ struct btrfs_super_block {
        __le64 num_devices;
        __le32 sectorsize;
        __le32 nodesize;
-       __le32 leafsize;
+       __le32 __unused_leafsize;
        __le32 stripesize;
        __le32 sys_chunk_array_size;
        __le64 chunk_root_generation;
@@ -1305,8 +1298,8 @@ struct btrfs_block_group_cache {
         */
        struct list_head cluster_list;
 
-       /* For delayed block group creation */
-       struct list_head new_bg_list;
+       /* For delayed block group creation or deletion of empty block groups */
+       struct list_head bg_list;
 };
 
 /* delayed seq elem */
@@ -1545,6 +1538,7 @@ struct btrfs_fs_info {
        struct btrfs_workqueue *endio_workers;
        struct btrfs_workqueue *endio_meta_workers;
        struct btrfs_workqueue *endio_raid56_workers;
+       struct btrfs_workqueue *endio_repair_workers;
        struct btrfs_workqueue *rmw_workers;
        struct btrfs_workqueue *endio_meta_write_workers;
        struct btrfs_workqueue *endio_write_workers;
@@ -1574,6 +1568,7 @@ struct btrfs_fs_info {
        int do_barriers;
        int closing;
        int log_root_recovering;
+       int open;
 
        u64 total_pinned;
 
@@ -1723,6 +1718,9 @@ struct btrfs_fs_info {
 
        /* Used to reclaim the metadata space in the background. */
        struct work_struct async_reclaim_work;
+
+       spinlock_t unused_bgs_lock;
+       struct list_head unused_bgs;
 };
 
 struct btrfs_subvolume_writers {
@@ -1776,12 +1774,12 @@ struct btrfs_root {
 
        /* free ino cache stuff */
        struct btrfs_free_space_ctl *free_ino_ctl;
-       enum btrfs_caching_type cached;
-       spinlock_t cache_lock;
-       wait_queue_head_t cache_wait;
+       enum btrfs_caching_type ino_cache_state;
+       spinlock_t ino_cache_lock;
+       wait_queue_head_t ino_cache_wait;
        struct btrfs_free_space_ctl *free_ino_pinned;
-       u64 cache_progress;
-       struct inode *cache_inode;
+       u64 ino_cache_progress;
+       struct inode *ino_cache_inode;
 
        struct mutex log_mutex;
        wait_queue_head_t log_writer_wait;
@@ -1806,9 +1804,6 @@ struct btrfs_root {
        /* node allocations are done in nodesize units */
        u32 nodesize;
 
-       /* leaf allocations are done in leafsize units */
-       u32 leafsize;
-
        u32 stripesize;
 
        u32 type;
@@ -2995,8 +2990,6 @@ BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
                         sectorsize, 32);
 BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
                         nodesize, 32);
-BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block,
-                        leafsize, 32);
 BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
                         stripesize, 32);
 BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
@@ -3232,13 +3225,6 @@ static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
        return sb->s_fs_info;
 }
 
-static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
-{
-       if (level == 0)
-               return root->leafsize;
-       return root->nodesize;
-}
-
 /* helper function to cast into the data area of the leaf. */
 #define btrfs_item_ptr(leaf, slot, type) \
        ((type *)(btrfs_leaf_data(leaf) + \
@@ -3263,7 +3249,7 @@ static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
 static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
                                                 unsigned num_items)
 {
-       return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
+       return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
                2 * num_items;
 }
 
@@ -3274,8 +3260,7 @@ static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
 static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root,
                                                 unsigned num_items)
 {
-       return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
-               num_items;
+       return root->nodesize * BTRFS_MAX_LEVEL * num_items;
 }
 
 int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
@@ -3326,9 +3311,9 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes,
                         u64 min_alloc_size, u64 empty_size, u64 hint_byte,
                         struct btrfs_key *ins, int is_data, int delalloc);
 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-                 struct extent_buffer *buf, int full_backref, int no_quota);
+                 struct extent_buffer *buf, int full_backref);
 int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-                 struct extent_buffer *buf, int full_backref, int no_quota);
+                 struct extent_buffer *buf, int full_backref);
 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
                                struct btrfs_root *root,
                                u64 bytenr, u64 num_bytes, u64 flags,
@@ -3363,6 +3348,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
                           u64 size);
 int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root, u64 group_start);
+void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info);
 void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
                                       struct btrfs_root *root);
 u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data);
@@ -3739,8 +3725,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
 int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
                          struct bio *bio, u32 *dst);
 int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
-                             struct btrfs_dio_private *dip, struct bio *bio,
-                             u64 logical_offset);
+                             struct bio *bio, u64 logical_offset);
 int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root,
                             u64 objectid, u64 pos,