mbox series

[00/11] Make pinned extents tracking per-transaction

Message ID 20200120140918.15647-1-nborisov@suse.com (mailing list archive)
Headers show
Series Make pinned extents tracking per-transaction | expand

Message

Nikolay Borisov Jan. 20, 2020, 2:09 p.m. UTC
I've finally managed to finish and test the pinned extents rework. So here it is.

The idea is to move pinnex extents tracking from the global fs_info->pinned_extents,
which is just a pointer to fs_info->freed_extents[] array members to a per
transaction structure. This will allow to cleanup pinned extents information
during transaction abort.

The bulk of the changes are necessary to ensure a valid transaction handle
is passed to every function that utilizes fs_info->pinned_extents. Also it
was necessary to account for the peculiarities of excluded extents which are
also tracked in ->freed_extents array but with a different flag (yuck).

First 9 patches propagate btrfs_trans_handle where it's necessary. Patch 10
factors out pinned extent clean up to make Patch 11 more readable , alternatively
the changes in patch 10 had to be in patch 11 which would have made it messier
for review.

I believe this series doesn't bring any user facing changes it (hopefully)
streamlines the code and makes it apparent what the lifetime of pinned extents
is and paves the way for further cleanups of BUG_ON.

Nikolay Borisov (11):
  btrfs: Perform pinned cleanup directly in btrfs_destroy_delayed_refs
  btrfs: Make btrfs_pin_extent take trans handle
  btrfs: Introduce unaccount_log_buffer
  btrfs: Call btrfs_pin_reserved_extent only during active transaction
  btrfs: Make btrfs_pin_reserved_extent take transaction
  btrfs: Make btrfs_pin_extent_for_log_replay take transaction handle
  btrfs: Make pin_down_extent take btrfs_trans_handle
  btrfs: Pass trans handle to write_pinned_extent_entries
  btrfs: Mark pinned log extents as excluded
  btrfs: Factor out pinned extent clean up in btrfs_delete_unused_bgs
  btrfs: Use btrfs_transaction::pinned_extents

 fs/btrfs/block-group.c       | 85 +++++++++++++++++++++++-------------
 fs/btrfs/ctree.h             | 12 ++---
 fs/btrfs/disk-io.c           | 56 ++++++++++++------------
 fs/btrfs/extent-io-tree.h    |  3 +-
 fs/btrfs/extent-tree.c       | 70 +++++++++++++----------------
 fs/btrfs/free-space-cache.c  |  5 ++-
 fs/btrfs/tests/btrfs-tests.c |  7 +--
 fs/btrfs/transaction.c       |  1 +
 fs/btrfs/transaction.h       |  1 +
 fs/btrfs/tree-log.c          | 70 +++++++++++++++++++----------
 include/trace/events/btrfs.h |  3 +-
 11 files changed, 174 insertions(+), 139 deletions(-)

--
2.17.1

Comments

David Sterba Feb. 6, 2020, 7:59 p.m. UTC | #1
On Mon, Jan 20, 2020 at 04:09:07PM +0200, Nikolay Borisov wrote:
> I've finally managed to finish and test the pinned extents rework. So here it is.
> 
> The idea is to move pinnex extents tracking from the global fs_info->pinned_extents,
> which is just a pointer to fs_info->freed_extents[] array members to a per
> transaction structure. This will allow to cleanup pinned extents information
> during transaction abort.
> 
> The bulk of the changes are necessary to ensure a valid transaction handle
> is passed to every function that utilizes fs_info->pinned_extents. Also it
> was necessary to account for the peculiarities of excluded extents which are
> also tracked in ->freed_extents array but with a different flag (yuck).
> 
> First 9 patches propagate btrfs_trans_handle where it's necessary. Patch 10
> factors out pinned extent clean up to make Patch 11 more readable , alternatively
> the changes in patch 10 had to be in patch 11 which would have made it messier
> for review.
> 
> I believe this series doesn't bring any user facing changes it (hopefully)
> streamlines the code and makes it apparent what the lifetime of pinned extents
> is and paves the way for further cleanups of BUG_ON.
> 
> Nikolay Borisov (11):
>   btrfs: Perform pinned cleanup directly in btrfs_destroy_delayed_refs
>   btrfs: Make btrfs_pin_extent take trans handle
>   btrfs: Introduce unaccount_log_buffer
>   btrfs: Call btrfs_pin_reserved_extent only during active transaction
>   btrfs: Make btrfs_pin_reserved_extent take transaction
>   btrfs: Make btrfs_pin_extent_for_log_replay take transaction handle
>   btrfs: Make pin_down_extent take btrfs_trans_handle
>   btrfs: Pass trans handle to write_pinned_extent_entries
>   btrfs: Mark pinned log extents as excluded
>   btrfs: Factor out pinned extent clean up in btrfs_delete_unused_bgs
>   btrfs: Use btrfs_transaction::pinned_extents

So far I found test btrfs/139 to fail, nothing in the log, only the
golden output does not match.