diff options
author | liubo <liubo2009@cn.fujitsu.com> | 2011-03-24 07:18:59 -0400 |
---|---|---|
committer | root <Chris Mason chris.mason@oracle.com> | 2011-03-28 05:37:33 -0400 |
commit | 1abe9b8a138c9988ba8f7bfded6453649a31541f (patch) | |
tree | 9fe0c181e78b075b65f6b1802f0a5092e7afbc6a | |
parent | 240f62c8756df285da11469259b3900f32883168 (diff) |
Btrfs: add initial tracepoint support for btrfs
Tracepoints can provide insight into why btrfs hits bugs and be greatly
helpful for debugging, e.g
dd-7822 [000] 2121.641088: btrfs_inode_request: root = 5(FS_TREE), gen = 4, ino = 256, blocks = 8, disk_i_size = 0, last_trans = 8, logged_trans = 0
dd-7822 [000] 2121.641100: btrfs_inode_new: root = 5(FS_TREE), gen = 8, ino = 257, blocks = 0, disk_i_size = 0, last_trans = 0, logged_trans = 0
btrfs-transacti-7804 [001] 2146.935420: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29368320 (orig_level = 0), cow_buf = 29388800 (cow_level = 0)
btrfs-transacti-7804 [001] 2146.935473: btrfs_cow_block: root = 1(ROOT_TREE), refs = 2, orig_buf = 29364224 (orig_level = 0), cow_buf = 29392896 (cow_level = 0)
btrfs-transacti-7804 [001] 2146.972221: btrfs_transaction_commit: root = 1(ROOT_TREE), gen = 8
flush-btrfs-2-7821 [001] 2155.824210: btrfs_chunk_alloc: root = 3(CHUNK_TREE), offset = 1103101952, size = 1073741824, num_stripes = 1, sub_stripes = 0, type = DATA
flush-btrfs-2-7821 [001] 2155.824241: btrfs_cow_block: root = 2(EXTENT_TREE), refs = 2, orig_buf = 29388800 (orig_level = 0), cow_buf = 29396992 (cow_level = 0)
flush-btrfs-2-7821 [001] 2155.824255: btrfs_cow_block: root = 4(DEV_TREE), refs = 2, orig_buf = 29372416 (orig_level = 0), cow_buf = 29401088 (cow_level = 0)
flush-btrfs-2-7821 [000] 2155.824329: btrfs_cow_block: root = 3(CHUNK_TREE), refs = 2, orig_buf = 20971520 (orig_level = 0), cow_buf = 20975616 (cow_level = 0)
btrfs-endio-wri-7800 [001] 2155.898019: btrfs_cow_block: root = 5(FS_TREE), refs = 2, orig_buf = 29384704 (orig_level = 0), cow_buf = 29405184 (cow_level = 0)
btrfs-endio-wri-7800 [001] 2155.898043: btrfs_cow_block: root = 7(CSUM_TREE), refs = 2, orig_buf = 29376512 (orig_level = 0), cow_buf = 29409280 (cow_level = 0)
Here is what I have added:
1) ordere_extent:
btrfs_ordered_extent_add
btrfs_ordered_extent_remove
btrfs_ordered_extent_start
btrfs_ordered_extent_put
These provide critical information to understand how ordered_extents are
updated.
2) extent_map:
btrfs_get_extent
extent_map is used in both read and write cases, and it is useful for tracking
how btrfs specific IO is running.
3) writepage:
__extent_writepage
btrfs_writepage_end_io_hook
Pages are cirtical resourses and produce a lot of corner cases during writeback,
so it is valuable to know how page is written to disk.
4) inode:
btrfs_inode_new
btrfs_inode_request
btrfs_inode_evict
These can show where and when a inode is created, when a inode is evicted.
5) sync:
btrfs_sync_file
btrfs_sync_fs
These show sync arguments.
6) transaction:
btrfs_transaction_commit
In transaction based filesystem, it will be useful to know the generation and
who does commit.
7) back reference and cow:
btrfs_delayed_tree_ref
btrfs_delayed_data_ref
btrfs_delayed_ref_head
btrfs_cow_block
Btrfs natively supports back references, these tracepoints are helpful on
understanding btrfs's COW mechanism.
8) chunk:
btrfs_chunk_alloc
btrfs_chunk_free
Chunk is a link between physical offset and logical offset, and stands for space
infomation in btrfs, and these are helpful on tracing space things.
9) reserved_extent:
btrfs_reserved_extent_alloc
btrfs_reserved_extent_free
These can show how btrfs uses its space.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r-- | fs/btrfs/ctree.c | 3 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.c | 6 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 4 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 2 | ||||
-rw-r--r-- | fs/btrfs/file.c | 1 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 12 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.c | 8 | ||||
-rw-r--r-- | fs/btrfs/super.c | 5 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 2 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 16 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 11 | ||||
-rw-r--r-- | include/trace/events/btrfs.h | 667 |
13 files changed, 727 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 8680110f0a5a..465b5d7d6b48 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -535,6 +535,9 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
535 | 535 | ||
536 | ret = __btrfs_cow_block(trans, root, buf, parent, | 536 | ret = __btrfs_cow_block(trans, root, buf, parent, |
537 | parent_slot, cow_ret, search_start, 0); | 537 | parent_slot, cow_ret, search_start, 0); |
538 | |||
539 | trace_btrfs_cow_block(root, buf, *cow_ret); | ||
540 | |||
538 | return ret; | 541 | return ret; |
539 | } | 542 | } |
540 | 543 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0ee679b6c1b7..9d0f59142afa 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/wait.h> | 28 | #include <linux/wait.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/kobject.h> | 30 | #include <linux/kobject.h> |
31 | #include <trace/events/btrfs.h> | ||
31 | #include <asm/kmap_types.h> | 32 | #include <asm/kmap_types.h> |
32 | #include "extent_io.h" | 33 | #include "extent_io.h" |
33 | #include "extent_map.h" | 34 | #include "extent_map.h" |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index e807b143b857..bce28f653899 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
@@ -483,6 +483,8 @@ static noinline int add_delayed_ref_head(struct btrfs_trans_handle *trans, | |||
483 | INIT_LIST_HEAD(&head_ref->cluster); | 483 | INIT_LIST_HEAD(&head_ref->cluster); |
484 | mutex_init(&head_ref->mutex); | 484 | mutex_init(&head_ref->mutex); |
485 | 485 | ||
486 | trace_btrfs_delayed_ref_head(ref, head_ref, action); | ||
487 | |||
486 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); | 488 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); |
487 | 489 | ||
488 | if (existing) { | 490 | if (existing) { |
@@ -537,6 +539,8 @@ static noinline int add_delayed_tree_ref(struct btrfs_trans_handle *trans, | |||
537 | } | 539 | } |
538 | full_ref->level = level; | 540 | full_ref->level = level; |
539 | 541 | ||
542 | trace_btrfs_delayed_tree_ref(ref, full_ref, action); | ||
543 | |||
540 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); | 544 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); |
541 | 545 | ||
542 | if (existing) { | 546 | if (existing) { |
@@ -591,6 +595,8 @@ static noinline int add_delayed_data_ref(struct btrfs_trans_handle *trans, | |||
591 | full_ref->objectid = owner; | 595 | full_ref->objectid = owner; |
592 | full_ref->offset = offset; | 596 | full_ref->offset = offset; |
593 | 597 | ||
598 | trace_btrfs_delayed_data_ref(ref, full_ref, action); | ||
599 | |||
594 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); | 600 | existing = tree_insert(&delayed_refs->root, &ref->rb_node); |
595 | 601 | ||
596 | if (existing) { | 602 | if (existing) { |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index cd794c35a636..86ea471d3801 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -5412,6 +5412,8 @@ again: | |||
5412 | dump_space_info(sinfo, num_bytes, 1); | 5412 | dump_space_info(sinfo, num_bytes, 1); |
5413 | } | 5413 | } |
5414 | 5414 | ||
5415 | trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset); | ||
5416 | |||
5415 | return ret; | 5417 | return ret; |
5416 | } | 5418 | } |
5417 | 5419 | ||
@@ -5433,6 +5435,8 @@ int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len) | |||
5433 | update_reserved_bytes(cache, len, 0, 1); | 5435 | update_reserved_bytes(cache, len, 0, 1); |
5434 | btrfs_put_block_group(cache); | 5436 | btrfs_put_block_group(cache); |
5435 | 5437 | ||
5438 | trace_btrfs_reserved_extent_free(root, start, len); | ||
5439 | |||
5436 | return ret; | 5440 | return ret; |
5437 | } | 5441 | } |
5438 | 5442 | ||
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 1bbd26b4fc5c..77c65a0bea34 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2192,6 +2192,8 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, | |||
2192 | else | 2192 | else |
2193 | write_flags = WRITE; | 2193 | write_flags = WRITE; |
2194 | 2194 | ||
2195 | trace___extent_writepage(page, inode, wbc); | ||
2196 | |||
2195 | WARN_ON(!PageLocked(page)); | 2197 | WARN_ON(!PageLocked(page)); |
2196 | pg_offset = i_size & (PAGE_CACHE_SIZE - 1); | 2198 | pg_offset = i_size & (PAGE_CACHE_SIZE - 1); |
2197 | if (page->index > end_index || | 2199 | if (page->index > end_index || |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index a85b044cf39e..656bc0a892b1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1205,6 +1205,7 @@ int btrfs_sync_file(struct file *file, int datasync) | |||
1205 | int ret = 0; | 1205 | int ret = 0; |
1206 | struct btrfs_trans_handle *trans; | 1206 | struct btrfs_trans_handle *trans; |
1207 | 1207 | ||
1208 | trace_btrfs_sync_file(file, datasync); | ||
1208 | 1209 | ||
1209 | /* we wait first, since the writeback may change the inode */ | 1210 | /* we wait first, since the writeback may change the inode */ |
1210 | root->log_batch++; | 1211 | root->log_batch++; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e9813bd7d556..eaa271484199 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1787,6 +1787,8 @@ out: | |||
1787 | static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, | 1787 | static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, |
1788 | struct extent_state *state, int uptodate) | 1788 | struct extent_state *state, int uptodate) |
1789 | { | 1789 | { |
1790 | trace_btrfs_writepage_end_io_hook(page, start, end, uptodate); | ||
1791 | |||
1790 | ClearPagePrivate2(page); | 1792 | ClearPagePrivate2(page); |
1791 | return btrfs_finish_ordered_io(page->mapping->host, start, end); | 1793 | return btrfs_finish_ordered_io(page->mapping->host, start, end); |
1792 | } | 1794 | } |
@@ -3718,6 +3720,8 @@ void btrfs_evict_inode(struct inode *inode) | |||
3718 | unsigned long nr; | 3720 | unsigned long nr; |
3719 | int ret; | 3721 | int ret; |
3720 | 3722 | ||
3723 | trace_btrfs_inode_evict(inode); | ||
3724 | |||
3721 | truncate_inode_pages(&inode->i_data, 0); | 3725 | truncate_inode_pages(&inode->i_data, 0); |
3722 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || | 3726 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || |
3723 | root == root->fs_info->tree_root)) | 3727 | root == root->fs_info->tree_root)) |
@@ -4510,6 +4514,8 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
4510 | return ERR_PTR(-ENOMEM); | 4514 | return ERR_PTR(-ENOMEM); |
4511 | 4515 | ||
4512 | if (dir) { | 4516 | if (dir) { |
4517 | trace_btrfs_inode_request(dir); | ||
4518 | |||
4513 | ret = btrfs_set_inode_index(dir, index); | 4519 | ret = btrfs_set_inode_index(dir, index); |
4514 | if (ret) { | 4520 | if (ret) { |
4515 | iput(inode); | 4521 | iput(inode); |
@@ -4584,6 +4590,9 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
4584 | 4590 | ||
4585 | insert_inode_hash(inode); | 4591 | insert_inode_hash(inode); |
4586 | inode_tree_add(inode); | 4592 | inode_tree_add(inode); |
4593 | |||
4594 | trace_btrfs_inode_new(inode); | ||
4595 | |||
4587 | return inode; | 4596 | return inode; |
4588 | fail: | 4597 | fail: |
4589 | if (dir) | 4598 | if (dir) |
@@ -5261,6 +5270,9 @@ insert: | |||
5261 | } | 5270 | } |
5262 | write_unlock(&em_tree->lock); | 5271 | write_unlock(&em_tree->lock); |
5263 | out: | 5272 | out: |
5273 | |||
5274 | trace_btrfs_get_extent(root, em); | ||
5275 | |||
5264 | if (path) | 5276 | if (path) |
5265 | btrfs_free_path(path); | 5277 | btrfs_free_path(path); |
5266 | if (trans) { | 5278 | if (trans) { |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 083a55477375..a1c940425307 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -202,6 +202,8 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, | |||
202 | INIT_LIST_HEAD(&entry->list); | 202 | INIT_LIST_HEAD(&entry->list); |
203 | INIT_LIST_HEAD(&entry->root_extent_list); | 203 | INIT_LIST_HEAD(&entry->root_extent_list); |
204 | 204 | ||
205 | trace_btrfs_ordered_extent_add(inode, entry); | ||
206 | |||
205 | spin_lock(&tree->lock); | 207 | spin_lock(&tree->lock); |
206 | node = tree_insert(&tree->tree, file_offset, | 208 | node = tree_insert(&tree->tree, file_offset, |
207 | &entry->rb_node); | 209 | &entry->rb_node); |
@@ -387,6 +389,8 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) | |||
387 | struct list_head *cur; | 389 | struct list_head *cur; |
388 | struct btrfs_ordered_sum *sum; | 390 | struct btrfs_ordered_sum *sum; |
389 | 391 | ||
392 | trace_btrfs_ordered_extent_put(entry->inode, entry); | ||
393 | |||
390 | if (atomic_dec_and_test(&entry->refs)) { | 394 | if (atomic_dec_and_test(&entry->refs)) { |
391 | while (!list_empty(&entry->list)) { | 395 | while (!list_empty(&entry->list)) { |
392 | cur = entry->list.next; | 396 | cur = entry->list.next; |
@@ -420,6 +424,8 @@ static int __btrfs_remove_ordered_extent(struct inode *inode, | |||
420 | spin_lock(&root->fs_info->ordered_extent_lock); | 424 | spin_lock(&root->fs_info->ordered_extent_lock); |
421 | list_del_init(&entry->root_extent_list); | 425 | list_del_init(&entry->root_extent_list); |
422 | 426 | ||
427 | trace_btrfs_ordered_extent_remove(inode, entry); | ||
428 | |||
423 | /* | 429 | /* |
424 | * we have no more ordered extents for this inode and | 430 | * we have no more ordered extents for this inode and |
425 | * no dirty pages. We can safely remove it from the | 431 | * no dirty pages. We can safely remove it from the |
@@ -585,6 +591,8 @@ void btrfs_start_ordered_extent(struct inode *inode, | |||
585 | u64 start = entry->file_offset; | 591 | u64 start = entry->file_offset; |
586 | u64 end = start + entry->len - 1; | 592 | u64 end = start + entry->len - 1; |
587 | 593 | ||
594 | trace_btrfs_ordered_extent_start(inode, entry); | ||
595 | |||
588 | /* | 596 | /* |
589 | * pages in the range can be dirty, clean or writeback. We | 597 | * pages in the range can be dirty, clean or writeback. We |
590 | * start IO on any dirty ones so the wait doesn't stall waiting | 598 | * start IO on any dirty ones so the wait doesn't stall waiting |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d39a9895d932..2edfc039f098 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -52,6 +52,9 @@ | |||
52 | #include "export.h" | 52 | #include "export.h" |
53 | #include "compression.h" | 53 | #include "compression.h" |
54 | 54 | ||
55 | #define CREATE_TRACE_POINTS | ||
56 | #include <trace/events/btrfs.h> | ||
57 | |||
55 | static const struct super_operations btrfs_super_ops; | 58 | static const struct super_operations btrfs_super_ops; |
56 | 59 | ||
57 | static const char *btrfs_decode_error(struct btrfs_fs_info *fs_info, int errno, | 60 | static const char *btrfs_decode_error(struct btrfs_fs_info *fs_info, int errno, |
@@ -620,6 +623,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait) | |||
620 | struct btrfs_root *root = btrfs_sb(sb); | 623 | struct btrfs_root *root = btrfs_sb(sb); |
621 | int ret; | 624 | int ret; |
622 | 625 | ||
626 | trace_btrfs_sync_fs(wait); | ||
627 | |||
623 | if (!wait) { | 628 | if (!wait) { |
624 | filemap_flush(root->fs_info->btree_inode->i_mapping); | 629 | filemap_flush(root->fs_info->btree_inode->i_mapping); |
625 | return 0; | 630 | return 0; |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 3d73c8d93bbb..5b4bc685bb0e 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -1389,6 +1389,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1389 | put_transaction(cur_trans); | 1389 | put_transaction(cur_trans); |
1390 | put_transaction(cur_trans); | 1390 | put_transaction(cur_trans); |
1391 | 1391 | ||
1392 | trace_btrfs_transaction_commit(root); | ||
1393 | |||
1392 | mutex_unlock(&root->fs_info->trans_mutex); | 1394 | mutex_unlock(&root->fs_info->trans_mutex); |
1393 | 1395 | ||
1394 | if (current->journal_info == trans) | 1396 | if (current->journal_info == trans) |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index dd13eb81ee40..8ba3c9ebff93 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -33,17 +33,6 @@ | |||
33 | #include "volumes.h" | 33 | #include "volumes.h" |
34 | #include "async-thread.h" | 34 | #include "async-thread.h" |
35 | 35 | ||
36 | struct map_lookup { | ||
37 | u64 type; | ||
38 | int io_align; | ||
39 | int io_width; | ||
40 | int stripe_len; | ||
41 | int sector_size; | ||
42 | int num_stripes; | ||
43 | int sub_stripes; | ||
44 | struct btrfs_bio_stripe stripes[]; | ||
45 | }; | ||
46 | |||
47 | static int init_first_rw_device(struct btrfs_trans_handle *trans, | 36 | static int init_first_rw_device(struct btrfs_trans_handle *trans, |
48 | struct btrfs_root *root, | 37 | struct btrfs_root *root, |
49 | struct btrfs_device *device); | 38 | struct btrfs_device *device); |
@@ -1923,6 +1912,8 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, | |||
1923 | 1912 | ||
1924 | BUG_ON(ret); | 1913 | BUG_ON(ret); |
1925 | 1914 | ||
1915 | trace_btrfs_chunk_free(root, map, chunk_offset, em->len); | ||
1916 | |||
1926 | if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { | 1917 | if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { |
1927 | ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); | 1918 | ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); |
1928 | BUG_ON(ret); | 1919 | BUG_ON(ret); |
@@ -2650,6 +2641,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
2650 | *num_bytes = chunk_bytes_by_type(type, calc_size, | 2641 | *num_bytes = chunk_bytes_by_type(type, calc_size, |
2651 | map->num_stripes, sub_stripes); | 2642 | map->num_stripes, sub_stripes); |
2652 | 2643 | ||
2644 | trace_btrfs_chunk_alloc(info->chunk_root, map, start, *num_bytes); | ||
2645 | |||
2653 | em = alloc_extent_map(GFP_NOFS); | 2646 | em = alloc_extent_map(GFP_NOFS); |
2654 | if (!em) { | 2647 | if (!em) { |
2655 | ret = -ENOMEM; | 2648 | ret = -ENOMEM; |
@@ -2758,6 +2751,7 @@ static int __finish_chunk_alloc(struct btrfs_trans_handle *trans, | |||
2758 | item_size); | 2751 | item_size); |
2759 | BUG_ON(ret); | 2752 | BUG_ON(ret); |
2760 | } | 2753 | } |
2754 | |||
2761 | kfree(chunk); | 2755 | kfree(chunk); |
2762 | return 0; | 2756 | return 0; |
2763 | } | 2757 | } |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 7fb59d45fe8c..7b38d0668b51 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -145,6 +145,17 @@ struct btrfs_device_info { | |||
145 | u64 max_avail; | 145 | u64 max_avail; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | struct map_lookup { | ||
149 | u64 type; | ||
150 | int io_align; | ||
151 | int io_width; | ||
152 | int stripe_len; | ||
153 | int sector_size; | ||
154 | int num_stripes; | ||
155 | int sub_stripes; | ||
156 | struct btrfs_bio_stripe stripes[]; | ||
157 | }; | ||
158 | |||
148 | /* Used to sort the devices by max_avail(descending sort) */ | 159 | /* Used to sort the devices by max_avail(descending sort) */ |
149 | int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2); | 160 | int btrfs_cmp_device_free_bytes(const void *dev_info1, const void *dev_info2); |
150 | 161 | ||
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h new file mode 100644 index 000000000000..f445cff66ab7 --- /dev/null +++ b/include/trace/events/btrfs.h | |||
@@ -0,0 +1,667 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM btrfs | ||
3 | |||
4 | #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_BTRFS_H | ||
6 | |||
7 | #include <linux/writeback.h> | ||
8 | #include <linux/tracepoint.h> | ||
9 | |||
10 | struct btrfs_root; | ||
11 | struct btrfs_fs_info; | ||
12 | struct btrfs_inode; | ||
13 | struct extent_map; | ||
14 | struct btrfs_ordered_extent; | ||
15 | struct btrfs_delayed_ref_node; | ||
16 | struct btrfs_delayed_tree_ref; | ||
17 | struct btrfs_delayed_data_ref; | ||
18 | struct btrfs_delayed_ref_head; | ||
19 | struct map_lookup; | ||
20 | struct extent_buffer; | ||
21 | |||
22 | #define show_ref_type(type) \ | ||
23 | __print_symbolic(type, \ | ||
24 | { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \ | ||
25 | { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \ | ||
26 | { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \ | ||
27 | { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \ | ||
28 | { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" }) | ||
29 | |||
30 | #define __show_root_type(obj) \ | ||
31 | __print_symbolic(obj, \ | ||
32 | { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \ | ||
33 | { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \ | ||
34 | { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \ | ||
35 | { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \ | ||
36 | { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \ | ||
37 | { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \ | ||
38 | { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \ | ||
39 | { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \ | ||
40 | { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \ | ||
41 | { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" }) | ||
42 | |||
43 | #define show_root_type(obj) \ | ||
44 | obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \ | ||
45 | (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-" | ||
46 | |||
47 | TRACE_EVENT(btrfs_transaction_commit, | ||
48 | |||
49 | TP_PROTO(struct btrfs_root *root), | ||
50 | |||
51 | TP_ARGS(root), | ||
52 | |||
53 | TP_STRUCT__entry( | ||
54 | __field( u64, generation ) | ||
55 | __field( u64, root_objectid ) | ||
56 | ), | ||
57 | |||
58 | TP_fast_assign( | ||
59 | __entry->generation = root->fs_info->generation; | ||
60 | __entry->root_objectid = root->root_key.objectid; | ||
61 | ), | ||
62 | |||
63 | TP_printk("root = %llu(%s), gen = %llu", | ||
64 | show_root_type(__entry->root_objectid), | ||
65 | (unsigned long long)__entry->generation) | ||
66 | ); | ||
67 | |||
68 | DECLARE_EVENT_CLASS(btrfs__inode, | ||
69 | |||
70 | TP_PROTO(struct inode *inode), | ||
71 | |||
72 | TP_ARGS(inode), | ||
73 | |||
74 | TP_STRUCT__entry( | ||
75 | __field( ino_t, ino ) | ||
76 | __field( blkcnt_t, blocks ) | ||
77 | __field( u64, disk_i_size ) | ||
78 | __field( u64, generation ) | ||
79 | __field( u64, last_trans ) | ||
80 | __field( u64, logged_trans ) | ||
81 | __field( u64, root_objectid ) | ||
82 | ), | ||
83 | |||
84 | TP_fast_assign( | ||
85 | __entry->ino = inode->i_ino; | ||
86 | __entry->blocks = inode->i_blocks; | ||
87 | __entry->disk_i_size = BTRFS_I(inode)->disk_i_size; | ||
88 | __entry->generation = BTRFS_I(inode)->generation; | ||
89 | __entry->last_trans = BTRFS_I(inode)->last_trans; | ||
90 | __entry->logged_trans = BTRFS_I(inode)->logged_trans; | ||
91 | __entry->root_objectid = | ||
92 | BTRFS_I(inode)->root->root_key.objectid; | ||
93 | ), | ||
94 | |||
95 | TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, " | ||
96 | "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu", | ||
97 | show_root_type(__entry->root_objectid), | ||
98 | (unsigned long long)__entry->generation, | ||
99 | (unsigned long)__entry->ino, | ||
100 | (unsigned long long)__entry->blocks, | ||
101 | (unsigned long long)__entry->disk_i_size, | ||
102 | (unsigned long long)__entry->last_trans, | ||
103 | (unsigned long long)__entry->logged_trans) | ||
104 | ); | ||
105 | |||
106 | DEFINE_EVENT(btrfs__inode, btrfs_inode_new, | ||
107 | |||
108 | TP_PROTO(struct inode *inode), | ||
109 | |||
110 | TP_ARGS(inode) | ||
111 | ); | ||
112 | |||
113 | DEFINE_EVENT(btrfs__inode, btrfs_inode_request, | ||
114 | |||
115 | TP_PROTO(struct inode *inode), | ||
116 | |||
117 | TP_ARGS(inode) | ||
118 | ); | ||
119 | |||
120 | DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, | ||
121 | |||
122 | TP_PROTO(struct inode *inode), | ||
123 | |||
124 | TP_ARGS(inode) | ||
125 | ); | ||
126 | |||
127 | #define __show_map_type(type) \ | ||
128 | __print_symbolic(type, \ | ||
129 | { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \ | ||
130 | { EXTENT_MAP_HOLE, "HOLE" }, \ | ||
131 | { EXTENT_MAP_INLINE, "INLINE" }, \ | ||
132 | { EXTENT_MAP_DELALLOC, "DELALLOC" }) | ||
133 | |||
134 | #define show_map_type(type) \ | ||
135 | type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type) | ||
136 | |||
137 | #define show_map_flags(flag) \ | ||
138 | __print_flags(flag, "|", \ | ||
139 | { EXTENT_FLAG_PINNED, "PINNED" }, \ | ||
140 | { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \ | ||
141 | { EXTENT_FLAG_VACANCY, "VACANCY" }, \ | ||
142 | { EXTENT_FLAG_PREALLOC, "PREALLOC" }) | ||
143 | |||
144 | TRACE_EVENT(btrfs_get_extent, | ||
145 | |||
146 | TP_PROTO(struct btrfs_root *root, struct extent_map *map), | ||
147 | |||
148 | TP_ARGS(root, map), | ||
149 | |||
150 | TP_STRUCT__entry( | ||
151 | __field( u64, root_objectid ) | ||
152 | __field( u64, start ) | ||
153 | __field( u64, len ) | ||
154 | __field( u64, orig_start ) | ||
155 | __field( u64, block_start ) | ||
156 | __field( u64, block_len ) | ||
157 | __field( unsigned long, flags ) | ||
158 | __field( int, refs ) | ||
159 | __field( unsigned int, compress_type ) | ||
160 | ), | ||
161 | |||
162 | TP_fast_assign( | ||
163 | __entry->root_objectid = root->root_key.objectid; | ||
164 | __entry->start = map->start; | ||
165 | __entry->len = map->len; | ||
166 | __entry->orig_start = map->orig_start; | ||
167 | __entry->block_start = map->block_start; | ||
168 | __entry->block_len = map->block_len; | ||
169 | __entry->flags = map->flags; | ||
170 | __entry->refs = atomic_read(&map->refs); | ||
171 | __entry->compress_type = map->compress_type; | ||
172 | ), | ||
173 | |||
174 | TP_printk("root = %llu(%s), start = %llu, len = %llu, " | ||
175 | "orig_start = %llu, block_start = %llu(%s), " | ||
176 | "block_len = %llu, flags = %s, refs = %u, " | ||
177 | "compress_type = %u", | ||
178 | show_root_type(__entry->root_objectid), | ||
179 | (unsigned long long)__entry->start, | ||
180 | (unsigned long long)__entry->len, | ||
181 | (unsigned long long)__entry->orig_start, | ||
182 | show_map_type(__entry->block_start), | ||
183 | (unsigned long long)__entry->block_len, | ||
184 | show_map_flags(__entry->flags), | ||
185 | __entry->refs, __entry->compress_type) | ||
186 | ); | ||
187 | |||
188 | #define show_ordered_flags(flags) \ | ||
189 | __print_symbolic(flags, \ | ||
190 | { BTRFS_ORDERED_IO_DONE, "IO_DONE" }, \ | ||
191 | { BTRFS_ORDERED_COMPLETE, "COMPLETE" }, \ | ||
192 | { BTRFS_ORDERED_NOCOW, "NOCOW" }, \ | ||
193 | { BTRFS_ORDERED_COMPRESSED, "COMPRESSED" }, \ | ||
194 | { BTRFS_ORDERED_PREALLOC, "PREALLOC" }, \ | ||
195 | { BTRFS_ORDERED_DIRECT, "DIRECT" }) | ||
196 | |||
197 | DECLARE_EVENT_CLASS(btrfs__ordered_extent, | ||
198 | |||
199 | TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), | ||
200 | |||
201 | TP_ARGS(inode, ordered), | ||
202 | |||
203 | TP_STRUCT__entry( | ||
204 | __field( ino_t, ino ) | ||
205 | __field( u64, file_offset ) | ||
206 | __field( u64, start ) | ||
207 | __field( u64, len ) | ||
208 | __field( u64, disk_len ) | ||
209 | __field( u64, bytes_left ) | ||
210 | __field( unsigned long, flags ) | ||
211 | __field( int, compress_type ) | ||
212 | __field( int, refs ) | ||
213 | __field( u64, root_objectid ) | ||
214 | ), | ||
215 | |||
216 | TP_fast_assign( | ||
217 | __entry->ino = inode->i_ino; | ||
218 | __entry->file_offset = ordered->file_offset; | ||
219 | __entry->start = ordered->start; | ||
220 | __entry->len = ordered->len; | ||
221 | __entry->disk_len = ordered->disk_len; | ||
222 | __entry->bytes_left = ordered->bytes_left; | ||
223 | __entry->flags = ordered->flags; | ||
224 | __entry->compress_type = ordered->compress_type; | ||
225 | __entry->refs = atomic_read(&ordered->refs); | ||
226 | __entry->root_objectid = | ||
227 | BTRFS_I(inode)->root->root_key.objectid; | ||
228 | ), | ||
229 | |||
230 | TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, " | ||
231 | "start = %llu, len = %llu, disk_len = %llu, " | ||
232 | "bytes_left = %llu, flags = %s, compress_type = %d, " | ||
233 | "refs = %d", | ||
234 | show_root_type(__entry->root_objectid), | ||
235 | (unsigned long long)__entry->ino, | ||
236 | (unsigned long long)__entry->file_offset, | ||
237 | (unsigned long long)__entry->start, | ||
238 | (unsigned long long)__entry->len, | ||
239 | (unsigned long long)__entry->disk_len, | ||
240 | (unsigned long long)__entry->bytes_left, | ||
241 | show_ordered_flags(__entry->flags), | ||
242 | __entry->compress_type, __entry->refs) | ||
243 | ); | ||
244 | |||
245 | DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add, | ||
246 | |||
247 | TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), | ||
248 | |||
249 | TP_ARGS(inode, ordered) | ||
250 | ); | ||
251 | |||
252 | DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove, | ||
253 | |||
254 | TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), | ||
255 | |||
256 | TP_ARGS(inode, ordered) | ||
257 | ); | ||
258 | |||
259 | DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start, | ||
260 | |||
261 | TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), | ||
262 | |||
263 | TP_ARGS(inode, ordered) | ||
264 | ); | ||
265 | |||
266 | DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put, | ||
267 | |||
268 | TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered), | ||
269 | |||
270 | TP_ARGS(inode, ordered) | ||
271 | ); | ||
272 | |||
273 | DECLARE_EVENT_CLASS(btrfs__writepage, | ||
274 | |||
275 | TP_PROTO(struct page *page, struct inode *inode, | ||
276 | struct writeback_control *wbc), | ||
277 | |||
278 | TP_ARGS(page, inode, wbc), | ||
279 | |||
280 | TP_STRUCT__entry( | ||
281 | __field( ino_t, ino ) | ||
282 | __field( pgoff_t, index ) | ||
283 | __field( long, nr_to_write ) | ||
284 | __field( long, pages_skipped ) | ||
285 | __field( loff_t, range_start ) | ||
286 | __field( loff_t, range_end ) | ||
287 | __field( char, nonblocking ) | ||
288 | __field( char, for_kupdate ) | ||
289 | __field( char, for_reclaim ) | ||
290 | __field( char, range_cyclic ) | ||
291 | __field( pgoff_t, writeback_index ) | ||
292 | __field( u64, root_objectid ) | ||
293 | ), | ||
294 | |||
295 | TP_fast_assign( | ||
296 | __entry->ino = inode->i_ino; | ||
297 | __entry->index = page->index; | ||
298 | __entry->nr_to_write = wbc->nr_to_write; | ||
299 | __entry->pages_skipped = wbc->pages_skipped; | ||
300 | __entry->range_start = wbc->range_start; | ||
301 | __entry->range_end = wbc->range_end; | ||
302 | __entry->nonblocking = wbc->nonblocking; | ||
303 | __entry->for_kupdate = wbc->for_kupdate; | ||
304 | __entry->for_reclaim = wbc->for_reclaim; | ||
305 | __entry->range_cyclic = wbc->range_cyclic; | ||
306 | __entry->writeback_index = inode->i_mapping->writeback_index; | ||
307 | __entry->root_objectid = | ||
308 | BTRFS_I(inode)->root->root_key.objectid; | ||
309 | ), | ||
310 | |||
311 | TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, " | ||
312 | "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, " | ||
313 | "range_end = %llu, nonblocking = %d, for_kupdate = %d, " | ||
314 | "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu", | ||
315 | show_root_type(__entry->root_objectid), | ||
316 | (unsigned long)__entry->ino, __entry->index, | ||
317 | __entry->nr_to_write, __entry->pages_skipped, | ||
318 | __entry->range_start, __entry->range_end, | ||
319 | __entry->nonblocking, __entry->for_kupdate, | ||
320 | __entry->for_reclaim, __entry->range_cyclic, | ||
321 | (unsigned long)__entry->writeback_index) | ||
322 | ); | ||
323 | |||
324 | DEFINE_EVENT(btrfs__writepage, __extent_writepage, | ||
325 | |||
326 | TP_PROTO(struct page *page, struct inode *inode, | ||
327 | struct writeback_control *wbc), | ||
328 | |||
329 | TP_ARGS(page, inode, wbc) | ||
330 | ); | ||
331 | |||
332 | TRACE_EVENT(btrfs_writepage_end_io_hook, | ||
333 | |||
334 | TP_PROTO(struct page *page, u64 start, u64 end, int uptodate), | ||
335 | |||
336 | TP_ARGS(page, start, end, uptodate), | ||
337 | |||
338 | TP_STRUCT__entry( | ||
339 | __field( ino_t, ino ) | ||
340 | __field( pgoff_t, index ) | ||
341 | __field( u64, start ) | ||
342 | __field( u64, end ) | ||
343 | __field( int, uptodate ) | ||
344 | __field( u64, root_objectid ) | ||
345 | ), | ||
346 | |||
347 | TP_fast_assign( | ||
348 | __entry->ino = page->mapping->host->i_ino; | ||
349 | __entry->index = page->index; | ||
350 | __entry->start = start; | ||
351 | __entry->end = end; | ||
352 | __entry->uptodate = uptodate; | ||
353 | __entry->root_objectid = | ||
354 | BTRFS_I(page->mapping->host)->root->root_key.objectid; | ||
355 | ), | ||
356 | |||
357 | TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, " | ||
358 | "end = %llu, uptodate = %d", | ||
359 | show_root_type(__entry->root_objectid), | ||
360 | (unsigned long)__entry->ino, (unsigned long)__entry->index, | ||
361 | (unsigned long long)__entry->start, | ||
362 | (unsigned long long)__entry->end, __entry->uptodate) | ||
363 | ); | ||
364 | |||
365 | TRACE_EVENT(btrfs_sync_file, | ||
366 | |||
367 | TP_PROTO(struct file *file, int datasync), | ||
368 | |||
369 | TP_ARGS(file, datasync), | ||
370 | |||
371 | TP_STRUCT__entry( | ||
372 | __field( ino_t, ino ) | ||
373 | __field( ino_t, parent ) | ||
374 | __field( int, datasync ) | ||
375 | __field( u64, root_objectid ) | ||
376 | ), | ||
377 | |||
378 | TP_fast_assign( | ||
379 | struct dentry *dentry = file->f_path.dentry; | ||
380 | struct inode *inode = dentry->d_inode; | ||
381 | |||
382 | __entry->ino = inode->i_ino; | ||
383 | __entry->parent = dentry->d_parent->d_inode->i_ino; | ||
384 | __entry->datasync = datasync; | ||
385 | __entry->root_objectid = | ||
386 | BTRFS_I(inode)->root->root_key.objectid; | ||
387 | ), | ||
388 | |||
389 | TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d", | ||
390 | show_root_type(__entry->root_objectid), | ||
391 | (unsigned long)__entry->ino, (unsigned long)__entry->parent, | ||
392 | __entry->datasync) | ||
393 | ); | ||
394 | |||
395 | TRACE_EVENT(btrfs_sync_fs, | ||
396 | |||
397 | TP_PROTO(int wait), | ||
398 | |||
399 | TP_ARGS(wait), | ||
400 | |||
401 | TP_STRUCT__entry( | ||
402 | __field( int, wait ) | ||
403 | ), | ||
404 | |||
405 | TP_fast_assign( | ||
406 | __entry->wait = wait; | ||
407 | ), | ||
408 | |||
409 | TP_printk("wait = %d", __entry->wait) | ||
410 | ); | ||
411 | |||
412 | #define show_ref_action(action) \ | ||
413 | __print_symbolic(action, \ | ||
414 | { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \ | ||
415 | { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \ | ||
416 | { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \ | ||
417 | { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" }) | ||
418 | |||
419 | |||
420 | TRACE_EVENT(btrfs_delayed_tree_ref, | ||
421 | |||
422 | TP_PROTO(struct btrfs_delayed_ref_node *ref, | ||
423 | struct btrfs_delayed_tree_ref *full_ref, | ||
424 | int action), | ||
425 | |||
426 | TP_ARGS(ref, full_ref, action), | ||
427 | |||
428 | TP_STRUCT__entry( | ||
429 | __field( u64, bytenr ) | ||
430 | __field( u64, num_bytes ) | ||
431 | __field( int, action ) | ||
432 | __field( u64, parent ) | ||
433 | __field( u64, ref_root ) | ||
434 | __field( int, level ) | ||
435 | __field( int, type ) | ||
436 | ), | ||
437 | |||
438 | TP_fast_assign( | ||
439 | __entry->bytenr = ref->bytenr; | ||
440 | __entry->num_bytes = ref->num_bytes; | ||
441 | __entry->action = action; | ||
442 | __entry->parent = full_ref->parent; | ||
443 | __entry->ref_root = full_ref->root; | ||
444 | __entry->level = full_ref->level; | ||
445 | __entry->type = ref->type; | ||
446 | ), | ||
447 | |||
448 | TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, " | ||
449 | "parent = %llu(%s), ref_root = %llu(%s), level = %d, " | ||
450 | "type = %s", | ||
451 | (unsigned long long)__entry->bytenr, | ||
452 | (unsigned long long)__entry->num_bytes, | ||
453 | show_ref_action(__entry->action), | ||
454 | show_root_type(__entry->parent), | ||
455 | show_root_type(__entry->ref_root), | ||
456 | __entry->level, show_ref_type(__entry->type)) | ||
457 | ); | ||
458 | |||
459 | TRACE_EVENT(btrfs_delayed_data_ref, | ||
460 | |||
461 | TP_PROTO(struct btrfs_delayed_ref_node *ref, | ||
462 | struct btrfs_delayed_data_ref *full_ref, | ||
463 | int action), | ||
464 | |||
465 | TP_ARGS(ref, full_ref, action), | ||
466 | |||
467 | TP_STRUCT__entry( | ||
468 | __field( u64, bytenr ) | ||
469 | __field( u64, num_bytes ) | ||
470 | __field( int, action ) | ||
471 | __field( u64, parent ) | ||
472 | __field( u64, ref_root ) | ||
473 | __field( u64, owner ) | ||
474 | __field( u64, offset ) | ||
475 | __field( int, type ) | ||
476 | ), | ||
477 | |||
478 | TP_fast_assign( | ||
479 | __entry->bytenr = ref->bytenr; | ||
480 | __entry->num_bytes = ref->num_bytes; | ||
481 | __entry->action = action; | ||
482 | __entry->parent = full_ref->parent; | ||
483 | __entry->ref_root = full_ref->root; | ||
484 | __entry->owner = full_ref->objectid; | ||
485 | __entry->offset = full_ref->offset; | ||
486 | __entry->type = ref->type; | ||
487 | ), | ||
488 | |||
489 | TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, " | ||
490 | "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, " | ||
491 | "offset = %llu, type = %s", | ||
492 | (unsigned long long)__entry->bytenr, | ||
493 | (unsigned long long)__entry->num_bytes, | ||
494 | show_ref_action(__entry->action), | ||
495 | show_root_type(__entry->parent), | ||
496 | show_root_type(__entry->ref_root), | ||
497 | (unsigned long long)__entry->owner, | ||
498 | (unsigned long long)__entry->offset, | ||
499 | show_ref_type(__entry->type)) | ||
500 | ); | ||
501 | |||
502 | TRACE_EVENT(btrfs_delayed_ref_head, | ||
503 | |||
504 | TP_PROTO(struct btrfs_delayed_ref_node *ref, | ||
505 | struct btrfs_delayed_ref_head *head_ref, | ||
506 | int action), | ||
507 | |||
508 | TP_ARGS(ref, head_ref, action), | ||
509 | |||
510 | TP_STRUCT__entry( | ||
511 | __field( u64, bytenr ) | ||
512 | __field( u64, num_bytes ) | ||
513 | __field( int, action ) | ||
514 | __field( int, is_data ) | ||
515 | ), | ||
516 | |||
517 | TP_fast_assign( | ||
518 | __entry->bytenr = ref->bytenr; | ||
519 | __entry->num_bytes = ref->num_bytes; | ||
520 | __entry->action = action; | ||
521 | __entry->is_data = head_ref->is_data; | ||
522 | ), | ||
523 | |||
524 | TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d", | ||
525 | (unsigned long long)__entry->bytenr, | ||
526 | (unsigned long long)__entry->num_bytes, | ||
527 | show_ref_action(__entry->action), | ||
528 | __entry->is_data) | ||
529 | ); | ||
530 | |||
531 | #define show_chunk_type(type) \ | ||
532 | __print_flags(type, "|", \ | ||
533 | { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \ | ||
534 | { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \ | ||
535 | { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \ | ||
536 | { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \ | ||
537 | { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ | ||
538 | { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ | ||
539 | { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}) | ||
540 | |||
541 | DECLARE_EVENT_CLASS(btrfs__chunk, | ||
542 | |||
543 | TP_PROTO(struct btrfs_root *root, struct map_lookup *map, | ||
544 | u64 offset, u64 size), | ||
545 | |||
546 | TP_ARGS(root, map, offset, size), | ||
547 | |||
548 | TP_STRUCT__entry( | ||
549 | __field( int, num_stripes ) | ||
550 | __field( u64, type ) | ||
551 | __field( int, sub_stripes ) | ||
552 | __field( u64, offset ) | ||
553 | __field( u64, size ) | ||
554 | __field( u64, root_objectid ) | ||
555 | ), | ||
556 | |||
557 | TP_fast_assign( | ||
558 | __entry->num_stripes = map->num_stripes; | ||
559 | __entry->type = map->type; | ||
560 | __entry->sub_stripes = map->sub_stripes; | ||
561 | __entry->offset = offset; | ||
562 | __entry->size = size; | ||
563 | __entry->root_objectid = root->root_key.objectid; | ||
564 | ), | ||
565 | |||
566 | TP_printk("root = %llu(%s), offset = %llu, size = %llu, " | ||
567 | "num_stripes = %d, sub_stripes = %d, type = %s", | ||
568 | show_root_type(__entry->root_objectid), | ||
569 | (unsigned long long)__entry->offset, | ||
570 | (unsigned long long)__entry->size, | ||
571 | __entry->num_stripes, __entry->sub_stripes, | ||
572 | show_chunk_type(__entry->type)) | ||
573 | ); | ||
574 | |||
575 | DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc, | ||
576 | |||
577 | TP_PROTO(struct btrfs_root *root, struct map_lookup *map, | ||
578 | u64 offset, u64 size), | ||
579 | |||
580 | TP_ARGS(root, map, offset, size) | ||
581 | ); | ||
582 | |||
583 | DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free, | ||
584 | |||
585 | TP_PROTO(struct btrfs_root *root, struct map_lookup *map, | ||
586 | u64 offset, u64 size), | ||
587 | |||
588 | TP_ARGS(root, map, offset, size) | ||
589 | ); | ||
590 | |||
591 | TRACE_EVENT(btrfs_cow_block, | ||
592 | |||
593 | TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf, | ||
594 | struct extent_buffer *cow), | ||
595 | |||
596 | TP_ARGS(root, buf, cow), | ||
597 | |||
598 | TP_STRUCT__entry( | ||
599 | __field( u64, root_objectid ) | ||
600 | __field( u64, buf_start ) | ||
601 | __field( int, refs ) | ||
602 | __field( u64, cow_start ) | ||
603 | __field( int, buf_level ) | ||
604 | __field( int, cow_level ) | ||
605 | ), | ||
606 | |||
607 | TP_fast_assign( | ||
608 | __entry->root_objectid = root->root_key.objectid; | ||
609 | __entry->buf_start = buf->start; | ||
610 | __entry->refs = atomic_read(&buf->refs); | ||
611 | __entry->cow_start = cow->start; | ||
612 | __entry->buf_level = btrfs_header_level(buf); | ||
613 | __entry->cow_level = btrfs_header_level(cow); | ||
614 | ), | ||
615 | |||
616 | TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu " | ||
617 | "(orig_level = %d), cow_buf = %llu (cow_level = %d)", | ||
618 | show_root_type(__entry->root_objectid), | ||
619 | __entry->refs, | ||
620 | (unsigned long long)__entry->buf_start, | ||
621 | __entry->buf_level, | ||
622 | (unsigned long long)__entry->cow_start, | ||
623 | __entry->cow_level) | ||
624 | ); | ||
625 | |||
626 | DECLARE_EVENT_CLASS(btrfs__reserved_extent, | ||
627 | |||
628 | TP_PROTO(struct btrfs_root *root, u64 start, u64 len), | ||
629 | |||
630 | TP_ARGS(root, start, len), | ||
631 | |||
632 | TP_STRUCT__entry( | ||
633 | __field( u64, root_objectid ) | ||
634 | __field( u64, start ) | ||
635 | __field( u64, len ) | ||
636 | ), | ||
637 | |||
638 | TP_fast_assign( | ||
639 | __entry->root_objectid = root->root_key.objectid; | ||
640 | __entry->start = start; | ||
641 | __entry->len = len; | ||
642 | ), | ||
643 | |||
644 | TP_printk("root = %llu(%s), start = %llu, len = %llu", | ||
645 | show_root_type(__entry->root_objectid), | ||
646 | (unsigned long long)__entry->start, | ||
647 | (unsigned long long)__entry->len) | ||
648 | ); | ||
649 | |||
650 | DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc, | ||
651 | |||
652 | TP_PROTO(struct btrfs_root *root, u64 start, u64 len), | ||
653 | |||
654 | TP_ARGS(root, start, len) | ||
655 | ); | ||
656 | |||
657 | DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free, | ||
658 | |||
659 | TP_PROTO(struct btrfs_root *root, u64 start, u64 len), | ||
660 | |||
661 | TP_ARGS(root, start, len) | ||
662 | ); | ||
663 | |||
664 | #endif /* _TRACE_BTRFS_H */ | ||
665 | |||
666 | /* This part must be outside protection */ | ||
667 | #include <trace/define_trace.h> | ||