Commit 599c75ec authored by Liu Bo's avatar Liu Bo Committed by Chris Mason

Btrfs/tracepoint: update delayed ref tracepoints

This shows exactly how btrfs processes the delayed refs onto disks,
which is very helpful on understanding delayed ref mechanism and
debugging related bugs.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 1095cc0d
...@@ -600,7 +600,7 @@ static noinline void add_delayed_ref_head(struct btrfs_fs_info *fs_info, ...@@ -600,7 +600,7 @@ static noinline void add_delayed_ref_head(struct btrfs_fs_info *fs_info,
INIT_LIST_HEAD(&head_ref->cluster); INIT_LIST_HEAD(&head_ref->cluster);
mutex_init(&head_ref->mutex); mutex_init(&head_ref->mutex);
trace_btrfs_delayed_ref_head(ref, head_ref, action); trace_add_delayed_ref_head(ref, head_ref, action);
existing = tree_insert(&delayed_refs->root, &ref->rb_node); existing = tree_insert(&delayed_refs->root, &ref->rb_node);
...@@ -661,7 +661,7 @@ static noinline void add_delayed_tree_ref(struct btrfs_fs_info *fs_info, ...@@ -661,7 +661,7 @@ static noinline void add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
ref->type = BTRFS_TREE_BLOCK_REF_KEY; ref->type = BTRFS_TREE_BLOCK_REF_KEY;
full_ref->level = level; full_ref->level = level;
trace_btrfs_delayed_tree_ref(ref, full_ref, action); trace_add_delayed_tree_ref(ref, full_ref, action);
existing = tree_insert(&delayed_refs->root, &ref->rb_node); existing = tree_insert(&delayed_refs->root, &ref->rb_node);
...@@ -722,7 +722,7 @@ static noinline void add_delayed_data_ref(struct btrfs_fs_info *fs_info, ...@@ -722,7 +722,7 @@ static noinline void add_delayed_data_ref(struct btrfs_fs_info *fs_info,
full_ref->objectid = owner; full_ref->objectid = owner;
full_ref->offset = offset; full_ref->offset = offset;
trace_btrfs_delayed_data_ref(ref, full_ref, action); trace_add_delayed_data_ref(ref, full_ref, action);
existing = tree_insert(&delayed_refs->root, &ref->rb_node); existing = tree_insert(&delayed_refs->root, &ref->rb_node);
......
...@@ -2035,6 +2035,8 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, ...@@ -2035,6 +2035,8 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
ins.type = BTRFS_EXTENT_ITEM_KEY; ins.type = BTRFS_EXTENT_ITEM_KEY;
ref = btrfs_delayed_node_to_data_ref(node); ref = btrfs_delayed_node_to_data_ref(node);
trace_run_delayed_data_ref(node, ref, node->action);
if (node->type == BTRFS_SHARED_DATA_REF_KEY) if (node->type == BTRFS_SHARED_DATA_REF_KEY)
parent = ref->parent; parent = ref->parent;
else else
...@@ -2178,6 +2180,8 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -2178,6 +2180,8 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
SKINNY_METADATA); SKINNY_METADATA);
ref = btrfs_delayed_node_to_tree_ref(node); ref = btrfs_delayed_node_to_tree_ref(node);
trace_run_delayed_tree_ref(node, ref, node->action);
if (node->type == BTRFS_SHARED_BLOCK_REF_KEY) if (node->type == BTRFS_SHARED_BLOCK_REF_KEY)
parent = ref->parent; parent = ref->parent;
else else
...@@ -2236,6 +2240,8 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans, ...@@ -2236,6 +2240,8 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
*/ */
BUG_ON(extent_op); BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node); head = btrfs_delayed_node_to_head(node);
trace_run_delayed_ref_head(node, head, node->action);
if (insert_reserved) { if (insert_reserved) {
btrfs_pin_extent(root, node->bytenr, btrfs_pin_extent(root, node->bytenr,
node->num_bytes, 1); node->num_bytes, 1);
......
...@@ -439,7 +439,7 @@ TRACE_EVENT(btrfs_sync_fs, ...@@ -439,7 +439,7 @@ TRACE_EVENT(btrfs_sync_fs,
{ BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
TRACE_EVENT(btrfs_delayed_tree_ref, DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref, TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_tree_ref *full_ref, struct btrfs_delayed_tree_ref *full_ref,
...@@ -481,7 +481,25 @@ TRACE_EVENT(btrfs_delayed_tree_ref, ...@@ -481,7 +481,25 @@ TRACE_EVENT(btrfs_delayed_tree_ref,
(unsigned long long)__entry->seq) (unsigned long long)__entry->seq)
); );
TRACE_EVENT(btrfs_delayed_data_ref, DEFINE_EVENT(btrfs_delayed_tree_ref, add_delayed_tree_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_tree_ref *full_ref,
int action),
TP_ARGS(ref, full_ref, action)
);
DEFINE_EVENT(btrfs_delayed_tree_ref, run_delayed_tree_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_tree_ref *full_ref,
int action),
TP_ARGS(ref, full_ref, action)
);
DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref, TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_data_ref *full_ref, struct btrfs_delayed_data_ref *full_ref,
...@@ -527,7 +545,25 @@ TRACE_EVENT(btrfs_delayed_data_ref, ...@@ -527,7 +545,25 @@ TRACE_EVENT(btrfs_delayed_data_ref,
(unsigned long long)__entry->seq) (unsigned long long)__entry->seq)
); );
TRACE_EVENT(btrfs_delayed_ref_head, DEFINE_EVENT(btrfs_delayed_data_ref, add_delayed_data_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_data_ref *full_ref,
int action),
TP_ARGS(ref, full_ref, action)
);
DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_data_ref *full_ref,
int action),
TP_ARGS(ref, full_ref, action)
);
DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
TP_PROTO(struct btrfs_delayed_ref_node *ref, TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_ref_head *head_ref, struct btrfs_delayed_ref_head *head_ref,
...@@ -556,6 +592,24 @@ TRACE_EVENT(btrfs_delayed_ref_head, ...@@ -556,6 +592,24 @@ TRACE_EVENT(btrfs_delayed_ref_head,
__entry->is_data) __entry->is_data)
); );
DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_ref_head *head_ref,
int action),
TP_ARGS(ref, head_ref, action)
);
DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
TP_PROTO(struct btrfs_delayed_ref_node *ref,
struct btrfs_delayed_ref_head *head_ref,
int action),
TP_ARGS(ref, head_ref, action)
);
#define show_chunk_type(type) \ #define show_chunk_type(type) \
__print_flags(type, "|", \ __print_flags(type, "|", \
{ BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment