Btrfs: allow balance to explicitly allocate chunks as it relocates
authorChris Mason <chris.mason@oracle.com>
Wed, 16 Feb 2011 18:57:04 +0000 (13:57 -0500)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Feb 2011 20:28:47 +0000 (15:28 -0500)
commitc87f08ca44e83b2c8d28f63f9c33f3a270a04bbe
tree05cebe37380861a89faaea50c1ccb360ffb0f975
parent91435650c233b93e0da389db74f4b2c11c5ad2d4
Btrfs: allow balance to explicitly allocate chunks as it relocates

Btrfs device shrinking and balancing ends up reallocating all the blocks
in order to allow COW to move them to new destinations.  It is somewhat
awkward in terms of ENOSPC because most of the enospc code is built
around the idea that some operation on a reference counted tree triggers
allocations in the non-reference counted trees.

This commit changes the balancing code to deal with enospc by trying to
allocate a new chunk.  If that allocation succeeds, we go ahead and
retry whatever failed due to enospc.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/relocation.c