Skip to content

Commit 0be5dc6

Browse files
Josef BacikChris Mason
authored andcommitted
Btrfs: fixup reserved trace points
In trying to track down where we were leaking reserved space I noticed our reserve extent tracepoints are a little off. First we were saying that the reserved space had been alloced in btrfs_reserve_extent, which isn't the case, this needs to be triggered when we actually allocate the space when we run the delayed ref. We were also missing a few places where we should have been tracing the btrfs_reserve_extent_free tracepoint. With these in place I was able to put together where we were leaking reserved space. Thanks, Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 2b1360d commit 0be5dc6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/btrfs/extent-tree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5262,6 +5262,8 @@ static int pin_down_extent(struct btrfs_root *root,
52625262

52635263
set_extent_dirty(root->fs_info->pinned_extents, bytenr,
52645264
bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
5265+
if (reserved)
5266+
trace_btrfs_reserved_extent_free(root, bytenr, num_bytes);
52655267
return 0;
52665268
}
52675269

@@ -5965,6 +5967,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
59655967

59665968
btrfs_add_free_space(cache, buf->start, buf->len);
59675969
btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE);
5970+
trace_btrfs_reserved_extent_free(root, buf->start, buf->len);
59685971
pin = 0;
59695972
}
59705973
out:
@@ -6592,8 +6595,6 @@ int btrfs_reserve_extent(struct btrfs_root *root,
65926595
}
65936596
}
65946597

6595-
trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset);
6596-
65976598
return ret;
65986599
}
65996600

@@ -6705,6 +6706,7 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
67056706
ins->objectid, ins->offset);
67066707
BUG();
67076708
}
6709+
trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset);
67086710
return ret;
67096711
}
67106712

@@ -6777,6 +6779,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
67776779
ins->objectid, ins->offset);
67786780
BUG();
67796781
}
6782+
6783+
trace_btrfs_reserved_extent_alloc(root, ins->objectid, root->leafsize);
67806784
return ret;
67816785
}
67826786

0 commit comments

Comments
 (0)