]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix necessary chunk tree space calculation when allocating a chunk
authorFilipe Manana <fdmanana@suse.com>
Tue, 9 Jun 2015 16:48:21 +0000 (17:48 +0100)
committerChris Mason <clm@fb.com>
Wed, 10 Jun 2015 14:02:46 +0000 (07:02 -0700)
commit6e3a8cff403b243a5d73c13c082f7f8409690cb8
tree12f1391feee7674ed4d411ae71a0bd1c4ffb20c6
parent727c33ed7239a117c2c1a8cbf94d2d31a8ce0feb
Btrfs: fix necessary chunk tree space calculation when allocating a chunk

When allocating a new chunk or removing one we need to update num_devs
device items and insert or remove a chunk item in the chunk tree, so
in the worst case the space needed in the chunk space_info is:

  btrfs_calc_trunc_metadata_size(chunk_root, num_devs) +
     btrfs_calc_trans_metadata_size(chunk_root, 1)

That is, in the worst case we need to cow num_devs paths and cow 1 other
path that can result in splitting every node and leaf, and each path
consisting of BTRFS_MAX_LEVEL - 1 nodes and 1 leaf. We were requiring
some additional chunk_root->nodesize * BTRFS_MAX_LEVEL * num_devs bytes,
which were unnecessary since updating the existing device items does
not result in splitting the nodes and leaf since after updating them
they remain with the same size.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/volumes.c