Skip to content

->total_bytes_pinned fixes for early ENOSPC issues

Josef Bacik linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 1 replyIn review
  2. v22 patches 2 repliesSuperseded
  3. v12 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- Updated the changelog in patch 2 to refer to the patchset that inspired the change.
- Added Nik's reviewed-by for patch 2.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: handle ->total_bytes_pinned inside the delayed ref itselffs/btrfs/block-group.c fs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h +2 more+77 -1170 replies
2/2btrfs: account for new extents being deleted in total_bytes_pinnedfs/btrfs/delayed-ref.c fs/btrfs/extent-tree.c+27 -140 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchNikolay Borisov
1/2R-b
2/2R-b

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

Read the v3 thread

Cover letter [PATCH v3 0/2] ->total_bytes_pinned fixes for early ENOSPC issues

v2->v3:
- Updated the changelog in patch 2 to refer to the patchset that inspired the change.
- Added Nik's reviewed-by for patch 2.
v1->v2:
- Rebase onto latest misc-next.
- Added Nikolay's reviewed-by for the first patch.

--- Original email ---
Hello,

Nikolay discovered a regression with generic/371 with my delayed refs patches applied. This isn't actually a regression caused by those patches, but rather those patches uncovered a problem that has existed forever, we just have papered over it with our aggressive delayed ref flushing. Enter these two patches.

The first patch is more of a refactoring and a simplification. We've been passing in a &old_refs and a &new_refs into the delayed ref code, and duplicating the

if (old_refs >= 0 && new_refs < 0)

	->total_bytes_pinned += bytes;
else if (old_refs < 0 && new_refs >= 0)
	->total_bytes_pinned -= bytes;

logic for data and metadata. This was made even more confusing by the fact that we clean up this accounting when we drop the delayed ref, but also include it when we actually pin the extents down properly. It took me quite a while to realize that we weren't mis-counting ->total_bytes_pinned because of how weirdly complicated the accounting was.

I've refactored this code to make the handling distinct. We modify it in the delayed refs code itself, which allows us to clean up a bunch of function arguments and duplicated code. It also unifies how we handle the delayed ref side of the ->total_bytes_pinned modification. Now it's a little easier to see who is responsible for the modification and where.

The second patch is the actual fix for the problem. Previously we had simply been assuming that ->total_ref_mod < 0 meant that we were freeing stuff. However if we allocate and free in the same transaction, ->total_ref_mod == 0 also means we're freeing. Adding that case is what fixes the problem Nikolay was seeing. Thanks,

Josef

Josef Bacik (2):
btrfs: handle ->total_bytes_pinned inside the delayed ref itself
btrfs: account for new extents being deleted in total_bytes_pinned

 fs/btrfs/block-group.c |  11 ++--
 fs/btrfs/delayed-ref.c |  60 ++++++++++++-------
 fs/btrfs/delayed-ref.h |  16 +++--
 fs/btrfs/extent-tree.c | 129 ++++++++++-------------------------------
 fs/btrfs/space-info.h  |  17 ++++++
 5 files changed, 103 insertions(+), 130 deletions(-)
Signature · 1 line
2.26.2