block-rsv.c (2e608bd1dd51ee962bded788caee4aa812729e87) block-rsv.c (29cbcf401793f4e2c871c846edc2191731df2c41)
1// SPDX-License-Identifier: GPL-2.0
2
3#include "misc.h"
4#include "ctree.h"
5#include "block-rsv.h"
6#include "space-info.h"
7#include "transaction.h"
8#include "block-group.h"
1// SPDX-License-Identifier: GPL-2.0
2
3#include "misc.h"
4#include "ctree.h"
5#include "block-rsv.h"
6#include "space-info.h"
7#include "transaction.h"
8#include "block-group.h"
9#include "disk-io.h"
9
10/*
11 * HOW DO BLOCK RESERVES WORK
12 *
13 * Think of block_rsv's as buckets for logically grouped metadata
14 * reservations. Each block_rsv has a ->size and a ->reserved. ->size is
15 * how large we want our block rsv to be, ->reserved is how much space is
16 * currently reserved for this block reserve.

--- 329 unchanged lines hidden (view full) ---

346 btrfs_block_rsv_add_bytes(dest, num_bytes, true);
347 return 0;
348}
349
350void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
351{
352 struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv;
353 struct btrfs_space_info *sinfo = block_rsv->space_info;
10
11/*
12 * HOW DO BLOCK RESERVES WORK
13 *
14 * Think of block_rsv's as buckets for logically grouped metadata
15 * reservations. Each block_rsv has a ->size and a ->reserved. ->size is
16 * how large we want our block rsv to be, ->reserved is how much space is
17 * currently reserved for this block reserve.

--- 329 unchanged lines hidden (view full) ---

347 btrfs_block_rsv_add_bytes(dest, num_bytes, true);
348 return 0;
349}
350
351void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
352{
353 struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv;
354 struct btrfs_space_info *sinfo = block_rsv->space_info;
355 struct btrfs_root *extent_root = btrfs_extent_root(fs_info, 0);
354 u64 num_bytes;
355 unsigned min_items;
356
357 /*
358 * The global block rsv is based on the size of the extent tree, the
359 * checksum tree and the root tree. If the fs is empty we want to set
360 * it to a minimal amount for safety.
361 */
356 u64 num_bytes;
357 unsigned min_items;
358
359 /*
360 * The global block rsv is based on the size of the extent tree, the
361 * checksum tree and the root tree. If the fs is empty we want to set
362 * it to a minimal amount for safety.
363 */
362 num_bytes = btrfs_root_used(&fs_info->extent_root->root_item) +
364 num_bytes = btrfs_root_used(&extent_root->root_item) +
363 btrfs_root_used(&fs_info->csum_root->root_item) +
364 btrfs_root_used(&fs_info->tree_root->root_item);
365
366 /*
367 * We at a minimum are going to modify the csum root, the tree root, and
368 * the extent root.
369 */
370 min_items = 3;

--- 179 unchanged lines hidden ---
365 btrfs_root_used(&fs_info->csum_root->root_item) +
366 btrfs_root_used(&fs_info->tree_root->root_item);
367
368 /*
369 * We at a minimum are going to modify the csum root, the tree root, and
370 * the extent root.
371 */
372 min_items = 3;

--- 179 unchanged lines hidden ---