While investigating the balance hang I came across various inconsistencies in the source. This series aims to fix those.
The first patch is (I believe) a fix to a longstanding bug that could cause balance to fail due to ENOSPC. The code no properly ensures that there is at least 1g of unallocated space on every device being balance. Patch 2 makes btrfs_can_relocate a bit more obvious and removes leftovers from previous cleanup Patches 3/4/5 remove some redundant code from various functions. This series has survived multiple xfstest runs. Nikolay Borisov (5): btrfs: Ensure at least 1g is free for balance btrfs: Refactor btrfs_can_relocate btrfs: Remove superfluous check form btrfs_remove_chunk btrfs: Sink find_lock_delalloc_range's 'max_bytes' argument btrfs: Replace BUG_ON with ASSERT in find_lock_delalloc_range fs/btrfs/ctree.h | 2 +- fs/btrfs/extent-tree.c | 39 ++++++++++++++------------------------- fs/btrfs/extent_io.c | 13 ++++++------- fs/btrfs/extent_io.h | 2 +- fs/btrfs/tests/extent-io-tests.c | 10 +++++----- fs/btrfs/volumes.c | 17 +++++++---------- 6 files changed, 34 insertions(+), 49 deletions(-) -- 2.7.4