btrfs: handle delayed ref head accounting cleanup in abort
[sfrench/cifs-2.6.git] / fs / btrfs / ctree.h
index 5fb4cb646c82377cf8008a3ccc5a87607d7fb842..34019c8b6158b4c46fcb5eafda0dd8a02d35bf36 100644 (file)
@@ -35,6 +35,7 @@
 struct btrfs_trans_handle;
 struct btrfs_transaction;
 struct btrfs_pending_snapshot;
+struct btrfs_delayed_ref_root;
 extern struct kmem_cache *btrfs_trans_handle_cachep;
 extern struct kmem_cache *btrfs_bit_radix_cachep;
 extern struct kmem_cache *btrfs_path_cachep;
@@ -468,6 +469,7 @@ enum {
        BTRFS_BLOCK_RSV_TRANS,
        BTRFS_BLOCK_RSV_CHUNK,
        BTRFS_BLOCK_RSV_DELOPS,
+       BTRFS_BLOCK_RSV_DELREFS,
        BTRFS_BLOCK_RSV_EMPTY,
        BTRFS_BLOCK_RSV_TEMP,
 };
@@ -831,6 +833,8 @@ struct btrfs_fs_info {
        struct btrfs_block_rsv chunk_block_rsv;
        /* block reservation for delayed operations */
        struct btrfs_block_rsv delayed_block_rsv;
+       /* block reservation for delayed refs */
+       struct btrfs_block_rsv delayed_refs_rsv;
 
        struct btrfs_block_rsv empty_block_rsv;
 
@@ -1194,6 +1198,7 @@ enum {
        BTRFS_ROOT_FORCE_COW,
        BTRFS_ROOT_MULTI_LOG_TASKS,
        BTRFS_ROOT_DIRTY,
+       BTRFS_ROOT_DELETING,
 };
 
 /*
@@ -2648,7 +2653,7 @@ static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_fs_info *fs_info,
 }
 
 int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans);
-int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans);
+bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info);
 void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info,
                                         const u64 start);
 void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg);
@@ -2660,6 +2665,9 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                           unsigned long count);
 int btrfs_async_run_delayed_refs(struct btrfs_fs_info *fs_info,
                                 unsigned long count, u64 transid, int wait);
+void btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info,
+                                 struct btrfs_delayed_ref_root *delayed_refs,
+                                 struct btrfs_delayed_ref_head *head);
 int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len);
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
                             struct btrfs_fs_info *fs_info, u64 bytenr,
@@ -2762,10 +2770,12 @@ enum btrfs_reserve_flush_enum {
 enum btrfs_flush_state {
        FLUSH_DELAYED_ITEMS_NR  =       1,
        FLUSH_DELAYED_ITEMS     =       2,
-       FLUSH_DELALLOC          =       3,
-       FLUSH_DELALLOC_WAIT     =       4,
-       ALLOC_CHUNK             =       5,
-       COMMIT_TRANS            =       6,
+       FLUSH_DELAYED_REFS_NR   =       3,
+       FLUSH_DELAYED_REFS      =       4,
+       FLUSH_DELALLOC          =       5,
+       FLUSH_DELALLOC_WAIT     =       6,
+       ALLOC_CHUNK             =       7,
+       COMMIT_TRANS            =       8,
 };
 
 int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
@@ -2816,6 +2826,13 @@ int btrfs_cond_migrate_bytes(struct btrfs_fs_info *fs_info,
 void btrfs_block_rsv_release(struct btrfs_fs_info *fs_info,
                             struct btrfs_block_rsv *block_rsv,
                             u64 num_bytes);
+void btrfs_delayed_refs_rsv_release(struct btrfs_fs_info *fs_info, int nr);
+void btrfs_update_delayed_refs_rsv(struct btrfs_trans_handle *trans);
+int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info,
+                                 enum btrfs_reserve_flush_enum flush);
+void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info,
+                                      struct btrfs_block_rsv *src,
+                                      u64 num_bytes);
 int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache);
 void btrfs_dec_block_group_ro(struct btrfs_block_group_cache *cache);
 void btrfs_put_block_group_cache(struct btrfs_fs_info *info);