btrfs: concentrate all tree block parentness check parameters into one structure
[sfrench/cifs-2.6.git] / fs / btrfs / block-group.c
index 5a743c4d4e97bc7375466633d9149bbad4679007..708d843daa72de424dff1b55990179574b400932 100644 (file)
@@ -299,7 +299,7 @@ struct btrfs_block_group *btrfs_next_block_group(
        return cache;
 }
 
-/**
+/*
  * Check if we can do a NOCOW write for a given extent.
  *
  * @fs_info:       The filesystem information object.
@@ -340,11 +340,9 @@ struct btrfs_block_group *btrfs_inc_nocow_writers(struct btrfs_fs_info *fs_info,
        return bg;
 }
 
-/**
+/*
  * Decrement the number of NOCOW writers in a block group.
  *
- * @bg:       The block group.
- *
  * This is meant to be called after a previous call to btrfs_inc_nocow_writers(),
  * and on the block group returned by that call. Typically this is called after
  * creating an ordered extent for a NOCOW write, to prevent races with scrub and
@@ -1553,7 +1551,7 @@ static bool should_reclaim_block_group(struct btrfs_block_group *bg, u64 bytes_f
        if (reclaim_thresh == 0)
                return false;
 
-       thresh = div_factor_fine(bg->length, reclaim_thresh);
+       thresh = mult_perc(bg->length, reclaim_thresh);
 
        /*
         * If we were below the threshold before don't reclaim, we are likely a
@@ -1813,8 +1811,8 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags)
        write_sequnlock(&fs_info->profiles_lock);
 }
 
-/**
- * Map a physical disk address to a list of logical addresses
+/*
+ * Map a physical disk address to a list of logical addresses.
  *
  * @fs_info:       the filesystem
  * @chunk_start:   logical address of block group
@@ -2555,7 +2553,7 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
        cache->global_root_id = calculate_global_root_id(fs_info, cache->start);
 
        if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
-               cache->needs_free_space = 1;
+               set_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &cache->runtime_flags);
 
        ret = btrfs_load_block_group_zone_info(cache, true);
        if (ret) {
@@ -3421,8 +3419,9 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
        return ret;
 }
 
-/**
- * btrfs_add_reserved_bytes - update the block_group and space info counters
+/*
+ * Update the block_group and space info counters.
+ *
  * @cache:     The cache we are manipulating
  * @ram_bytes:  The number of bytes of file content, and will be same to
  *              @num_bytes except for the compress path.
@@ -3465,8 +3464,9 @@ int btrfs_add_reserved_bytes(struct btrfs_block_group *cache,
        return ret;
 }
 
-/**
- * btrfs_free_reserved_bytes - update the block_group and space info counters
+/*
+ * Update the block_group and space info counters.
+ *
  * @cache:      The cache we are manipulating
  * @num_bytes:  The number of bytes in question
  * @delalloc:   The blocks are allocated for the delalloc write
@@ -3523,13 +3523,13 @@ static int should_alloc_chunk(struct btrfs_fs_info *fs_info,
         */
        if (force == CHUNK_ALLOC_LIMITED) {
                thresh = btrfs_super_total_bytes(fs_info->super_copy);
-               thresh = max_t(u64, SZ_64M, div_factor_fine(thresh, 1));
+               thresh = max_t(u64, SZ_64M, mult_perc(thresh, 1));
 
                if (sinfo->total_bytes - bytes_used < thresh)
                        return 1;
        }
 
-       if (bytes_used + SZ_2M < div_factor(sinfo->total_bytes, 8))
+       if (bytes_used + SZ_2M < mult_perc(sinfo->total_bytes, 80))
                return 0;
        return 1;
 }