Skip to content

btrfs: fix an on-stack path leak and migrate to auto-release for on-stack paths

Qu Wenruo linux-btrfs 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Add back an early btrfs_release_path() call in print_data_reloc_error()
This is to avoid holding the path (and its extent buffers locked) during time consuming iterate_extent_inodes() calls.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: fix a potential path leak in print_data_reloc_error()fs/btrfs/inode.c+1 -00 replies
2/2btrfs: introduce BTRFS_PATH_AUTO_RELEASE() helperfs/btrfs/ctree.h fs/btrfs/defrag.c fs/btrfs/inode.c +1 more+21 -192 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid Sterba
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] btrfs: fix an on-stack path leak and migrate to auto-release for on-stack paths

[CHANGELOG]
v2:
- Add back an early btrfs_release_path() call in print_data_reloc_error()
This is to avoid holding the path (and its extent buffers locked) during time consuming iterate_extent_inodes() calls.

And add a comment on that early release, with updated commit message.

I thought patch "btrfs: make sure extent and csum paths are always released in scrub_raid56_parity_stripe()" has already taught us that tag based manual cleanup is never reliable, now there is another similar bug in print_data_reloc_error().

This time it is harder to expose, as we always imply if the function returned an error, they should do the proper cleanup.
But extent_to_logical() does not follow that assumption.

The first patch is the minimal fix for backport, the second patch is going to solve the problem by using auto-release for all on-stack btrfs paths.

Qu Wenruo (2):
btrfs: fix a potential path leak in print_data_reloc_error()
btrfs: introduce BTRFS_PATH_AUTO_RELEASE() helper

 fs/btrfs/ctree.h  |  9 +++++++++
 fs/btrfs/defrag.c |  5 +----
 fs/btrfs/inode.c  |  7 +++++--
 fs/btrfs/scrub.c  | 18 ++++++------------
 4 files changed, 21 insertions(+), 18 deletions(-)
Signature · 1 line
2.52.0