mbox series

[0/2] btrfs: move ordered extents cleanup to where they got allocated

Message ID cover.1736759698.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs: move ordered extents cleanup to where they got allocated | expand

Message

Qu Wenruo Jan. 13, 2025, 9:42 a.m. UTC
Currently ordered extents cleanup is delayed, e.g:

Cow_file_range() and run_delalloc_nocow() all can allocate ordered
extents by themselves.
But the ordered extents cleanup is not happending in those functions,
but at the caller, btrfs_run_delalloc_range().

This is not the common practice, and has already caused various ordered
extent double accounting (fixed by the recent error handling patchset).

So this series will address the problem by:

- Refactor run_delalloc_nocow() to extract the NOCOW ordered extents
  creation
  To make later error handling a little simpler.

- Move ordered extents cleanup to where they got created
  There are 3 call sites:
  - cow_file_range()
    This is the simplest one, as the recent fix makes it pretty straight
    forward.

  - nocow_one_range()
    The new helper introduced to created ordered extents and extent maps
    for NOCOW writes.
    This is also pretty straightforward

  - run_delalloc_nocow()
    There are 3 different error cases that needs to adjust the ordered
    extents cleanup range.

Qu Wenruo (2):
  btrfs: extract the nocow ordered extent and extent map generation into
    a helper
  btrfs: move ordered extent cleanup to where they are allocated

 fs/btrfs/inode.c | 188 +++++++++++++++++++++++++++--------------------
 1 file changed, 107 insertions(+), 81 deletions(-)