mbox series

[0/2] Refactor btrfs_ioctl_balance

Message ID 20220503083637.1051023-1-nborisov@suse.com (mailing list archive)
Headers show
Series Refactor btrfs_ioctl_balance | expand

Message

Nikolay Borisov May 3, 2022, 8:36 a.m. UTC
A recent bug report about a memleak as a result from my refactoring of
btrfs_ioctl_balance clearly demonstrated that the function has become quite
unwieldy and fragile. This stems from the fact that it involves some fairly
convoluted logic in order to acquire the necessary locks (balance_mutex and the
exclusive ops) and the requirement to handle in-progress or paused balance.

In order to simplify btrfs_ioctl_balance this series first factors out the locking
code as it's de-facto separate functionality. It then replaces the open-coded
locking logic with the newly introduced helper. This makes the code-flow in
btrfs_ioctl_balance more linear and simple to follow.

Nikolay Borisov (2):
  btrfs: Introduce btrfs_try_lock_balance
  btrfs: Use btrfs_try_lock_balance in btrfs_ioctl_balance

 fs/btrfs/ioctl.c | 118 +++++++++++++++++++++++++++++------------------
 1 file changed, 72 insertions(+), 46 deletions(-)

--
2.25.1