Merge tag 'i2c-for-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[linux-block.git] / fs / btrfs / delayed-ref.h
index 2eb34abf700ff4730d576b7b85edaab4e5421f11..b54261fe509ba4914760c4f264d73d3843b6f428 100644 (file)
@@ -253,6 +253,27 @@ extern struct kmem_cache *btrfs_delayed_extent_op_cachep;
 int __init btrfs_delayed_ref_init(void);
 void __cold btrfs_delayed_ref_exit(void);
 
+static inline u64 btrfs_calc_delayed_ref_bytes(const struct btrfs_fs_info *fs_info,
+                                              int num_delayed_refs)
+{
+       u64 num_bytes;
+
+       num_bytes = btrfs_calc_insert_metadata_size(fs_info, num_delayed_refs);
+
+       /*
+        * We have to check the mount option here because we could be enabling
+        * the free space tree for the first time and don't have the compat_ro
+        * option set yet.
+        *
+        * We need extra reservations if we have the free space tree because
+        * we'll have to modify that tree as well.
+        */
+       if (btrfs_test_opt(fs_info, FREE_SPACE_TREE))
+               num_bytes *= 2;
+
+       return num_bytes;
+}
+
 static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref,
                                int action, u64 bytenr, u64 len, u64 parent)
 {
@@ -385,7 +406,6 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info,
 void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info,
                                       struct btrfs_block_rsv *src,
                                       u64 num_bytes);
-int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans);
 bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info);
 
 /*