Skip to content

Btrfs: fix total_bytes_pinned counter

Omar Sandoval linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7Btrfs: make add_pinned_bytes() take an s64 num_bytes instead of u64fs/btrfs/extent-tree.c+20 -212 replies
2/7Btrfs: make BUG_ON() in add_pinned_bytes() an ASSERT()fs/btrfs/extent-tree.c+1 -12 replies
3/7Btrfs: update total_bytes_pinned when pinning down extentsfs/btrfs/extent-tree.c+2 -11 reply
4/7Btrfs: always account pinned bytes when dropping a tree block reffs/btrfs/extent-tree.c+8 -91 reply
5/7Btrfs: return old and new total ref mods when adding delayed refsfs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h fs/btrfs/extent-tree.c+52 -341 reply
6/7Btrfs: rework delayed ref total_bytes_pinned accountingfs/btrfs/extent-tree.c+32 -92 replies
7/7Btrfs: warn if total_bytes_pinned is non-zero on unmountfs/btrfs/extent-tree.c+1 -04 replies

Reviews trailers per patch

5 of 7 patches have a Reviewed-by or Acked-by.

PatchHolger HoffstätteLiu BoDavid Sterba
SeriesT-b
1/7R-b R-b
2/7R-b
3/7R-b
4/7R-b
5/7
6/7R-b
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/7] Btrfs: fix total_bytes_pinned counter

From: Omar Sandoval <[email protected]>

This series fixes several problems with the total_bytes_pinned counter. Patches 1 and 2 are cleanups. Patches 3 and 4 are straightforward fixes. Patch 5 is prep for patch 6. Patch 6 is the most complicated fix. Patches 5 and 6 are ugly, I'd love any suggestions for a cleaner fix. Finally, patch 7 adds a warning to catch similar issues in the future.

Tested with this xfstests diff, which exposes a bunch of the issues without these fixes:

common/rc +6 -0
index 743df427..95e7517b 100644
@@ -484,6 +484,12 @@ _scratch_unmount()
 		_overlay_scratch_unmount
 		;;
 	btrfs)
+		if uuid="$(findmnt -n -o UUID "$SCRATCH_MNT")"; then
+			pushd "/sys/fs/btrfs/$uuid/allocation" >/dev/null
+			sync; sync; sync
+			grep -H -v '^0$' */total_bytes_pinned
+			popd >/dev/null
+		fi
 		$UMOUNT_PROG $SCRATCH_MNT
 		;;
 	*)

Omar Sandoval (7):
Btrfs: make add_pinned_bytes() take an s64 num_bytes instead of u64
Btrfs: make BUG_ON() in add_pinned_bytes() an ASSERT()
Btrfs: update total_bytes_pinned when pinning down extents
Btrfs: always account pinned bytes when dropping a tree block ref
Btrfs: return old and new total ref mods when adding delayed refs
Btrfs: rework delayed ref total_bytes_pinned accounting
Btrfs: warn if total_bytes_pinned is non-zero on unmount

 fs/btrfs/delayed-ref.c |  29 +++++++---
 fs/btrfs/delayed-ref.h |   6 ++-
 fs/btrfs/extent-tree.c | 142 +++++++++++++++++++++++++++++--------------------
 3 files changed, 109 insertions(+), 68 deletions(-)
Signature · 1 line
2.13.0