Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
btrfs: prefix fsid to all trace events
Browse files Browse the repository at this point in the history
When using trace events to debug a problem, it's impossible to determine
which file system generated a particular event.  This patch adds a
macro to prefix standard information to the head of a trace event.

The extent_state alloc/free events are all that's left without an
fs_info available.

Signed-off-by: Jeff Mahoney <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
jeffmahoney authored and kdave committed Jul 26, 2016
1 parent cb00109 commit bc07452
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 158 deletions.
9 changes: 5 additions & 4 deletions fs/btrfs/delayed-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
qrecord->num_bytes = num_bytes;
qrecord->old_roots = NULL;

qexisting = btrfs_qgroup_insert_dirty_extent(delayed_refs,
qexisting = btrfs_qgroup_insert_dirty_extent(fs_info,
delayed_refs,
qrecord);
if (qexisting)
kfree(qrecord);
Expand All @@ -615,7 +616,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
spin_lock_init(&head_ref->lock);
mutex_init(&head_ref->mutex);

trace_add_delayed_ref_head(ref, head_ref, action);
trace_add_delayed_ref_head(fs_info, ref, head_ref, action);

existing = htree_insert(&delayed_refs->href_root,
&head_ref->href_node);
Expand Down Expand Up @@ -682,7 +683,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
ref->type = BTRFS_TREE_BLOCK_REF_KEY;
full_ref->level = level;

trace_add_delayed_tree_ref(ref, full_ref, action);
trace_add_delayed_tree_ref(fs_info, ref, full_ref, action);

ret = add_delayed_ref_tail_merge(trans, delayed_refs, head_ref, ref);

Expand Down Expand Up @@ -739,7 +740,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
full_ref->objectid = owner;
full_ref->offset = offset;

trace_add_delayed_data_ref(ref, full_ref, action);
trace_add_delayed_data_ref(fs_info, ref, full_ref, action);

ret = add_delayed_ref_tail_merge(trans, delayed_refs, head_ref, ref);

Expand Down
10 changes: 6 additions & 4 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
ins.type = BTRFS_EXTENT_ITEM_KEY;

ref = btrfs_delayed_node_to_data_ref(node);
trace_run_delayed_data_ref(node, ref, node->action);
trace_run_delayed_data_ref(root->fs_info, node, ref, node->action);

if (node->type == BTRFS_SHARED_DATA_REF_KEY)
parent = ref->parent;
Expand Down Expand Up @@ -2359,7 +2359,7 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
SKINNY_METADATA);

ref = btrfs_delayed_node_to_tree_ref(node);
trace_run_delayed_tree_ref(node, ref, node->action);
trace_run_delayed_tree_ref(root->fs_info, node, ref, node->action);

if (node->type == BTRFS_SHARED_BLOCK_REF_KEY)
parent = ref->parent;
Expand Down Expand Up @@ -2423,7 +2423,8 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
*/
BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node);
trace_run_delayed_ref_head(node, head, node->action);
trace_run_delayed_ref_head(root->fs_info, node, head,
node->action);

if (insert_reserved) {
btrfs_pin_extent(root, node->bytenr,
Expand Down Expand Up @@ -8542,7 +8543,8 @@ static int record_one_subtree_extent(struct btrfs_trans_handle *trans,

delayed_refs = &trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
if (btrfs_qgroup_insert_dirty_extent(delayed_refs, qrecord))
if (btrfs_qgroup_insert_dirty_extent(trans->root->fs_info,
delayed_refs, qrecord))
kfree(qrecord);
spin_unlock(&delayed_refs->lock);

Expand Down
19 changes: 10 additions & 9 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,17 +1453,18 @@ int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
return ret;
}

struct btrfs_qgroup_extent_record
*btrfs_qgroup_insert_dirty_extent(struct btrfs_delayed_ref_root *delayed_refs,
struct btrfs_qgroup_extent_record *record)
struct btrfs_qgroup_extent_record *
btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info,
struct btrfs_delayed_ref_root *delayed_refs,
struct btrfs_qgroup_extent_record *record)
{
struct rb_node **p = &delayed_refs->dirty_extent_root.rb_node;
struct rb_node *parent_node = NULL;
struct btrfs_qgroup_extent_record *entry;
u64 bytenr = record->bytenr;

assert_spin_locked(&delayed_refs->lock);
trace_btrfs_qgroup_insert_dirty_extent(record);
trace_btrfs_qgroup_insert_dirty_extent(fs_info, record);

while (*p) {
parent_node = *p;
Expand Down Expand Up @@ -1595,8 +1596,8 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq);
cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq);

trace_qgroup_update_counters(qg->qgroupid, cur_old_count,
cur_new_count);
trace_qgroup_update_counters(fs_info, qg->qgroupid,
cur_old_count, cur_new_count);

/* Rfer update part */
if (cur_old_count == 0 && cur_new_count > 0) {
Expand Down Expand Up @@ -1687,8 +1688,8 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
goto out_free;
BUG_ON(!fs_info->quota_root);

trace_btrfs_qgroup_account_extent(bytenr, num_bytes, nr_old_roots,
nr_new_roots);
trace_btrfs_qgroup_account_extent(fs_info, bytenr, num_bytes,
nr_old_roots, nr_new_roots);

qgroups = ulist_alloc(GFP_NOFS);
if (!qgroups) {
Expand Down Expand Up @@ -1759,7 +1760,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
record = rb_entry(node, struct btrfs_qgroup_extent_record,
node);

trace_btrfs_qgroup_account_extents(record);
trace_btrfs_qgroup_account_extents(fs_info, record);

if (!ret) {
/*
Expand Down
9 changes: 5 additions & 4 deletions fs/btrfs/qgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ void btrfs_free_qgroup_config(struct btrfs_fs_info *fs_info);
struct btrfs_delayed_extent_op;
int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info);
struct btrfs_qgroup_extent_record
*btrfs_qgroup_insert_dirty_extent(struct btrfs_delayed_ref_root *delayed_refs,
struct btrfs_qgroup_extent_record *record);
struct btrfs_qgroup_extent_record *
btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info,
struct btrfs_delayed_ref_root *delayed_refs,
struct btrfs_qgroup_extent_record *record);
int
btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
Expand All @@ -88,7 +89,7 @@ static inline void btrfs_qgroup_free_delayed_ref(struct btrfs_fs_info *fs_info,
u64 ref_root, u64 num_bytes)
{
btrfs_qgroup_free_refroot(fs_info, ref_root, num_bytes);
trace_btrfs_qgroup_free_delayed_ref(ref_root, num_bytes);
trace_btrfs_qgroup_free_delayed_ref(fs_info, ref_root, num_bytes);
}
void assert_qgroups_uptodate(struct btrfs_trans_handle *trans);

Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
struct btrfs_root *root = fs_info->tree_root;

trace_btrfs_sync_fs(wait);
trace_btrfs_sync_fs(fs_info, wait);

if (!wait) {
filemap_flush(fs_info->btree_inode->i_mapping);
Expand Down
Loading

0 comments on commit bc07452

Please sign in to comment.