Btrfs: add tracepoint for em's EEXIST case
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 5 Jan 2018 19:51:16 +0000 (12:51 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Mar 2018 13:09:38 +0000 (15:09 +0200)
This is adding a tracepoint 'btrfs_handle_em_exist' to help debug the
subtle bugs around merge_extent_mapping.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_map.c
include/trace/events/btrfs.h

index c80dea7c69af090ec67aacce60185f6f69b8a1d2..b8ead8dc2ebed9dc4aa3e74bad4d3e72aec909e8 100644 (file)
@@ -551,6 +551,9 @@ int btrfs_add_extent_mapping(struct extent_map_tree *em_tree,
                ret = 0;
 
                existing = search_extent_mapping(em_tree, start, len);
+
+               trace_btrfs_handle_em_exist(existing, em, start, len);
+
                /*
                 * existing will always be non-NULL, since there must be
                 * extent causing the -EEXIST.
index c3ac5ec865198e0dfbe5da979dbc32ca2c71bfe0..486771e3f4cb1819c8e912ddc03cf0082e9731b8 100644 (file)
@@ -248,6 +248,41 @@ TRACE_EVENT_CONDITION(btrfs_get_extent,
                  __entry->refs, __entry->compress_type)
 );
 
+TRACE_EVENT(btrfs_handle_em_exist,
+
+       TP_PROTO(const struct extent_map *existing, const struct extent_map *map, u64 start, u64 len),
+
+       TP_ARGS(existing, map, start, len),
+
+       TP_STRUCT__entry(
+               __field(        u64,  e_start           )
+               __field(        u64,  e_len             )
+               __field(        u64,  map_start         )
+               __field(        u64,  map_len           )
+               __field(        u64,  start             )
+               __field(        u64,  len               )
+       ),
+
+       TP_fast_assign(
+               __entry->e_start        = existing->start;
+               __entry->e_len          = existing->len;
+               __entry->map_start      = map->start;
+               __entry->map_len        = map->len;
+               __entry->start          = start;
+               __entry->len            = len;
+       ),
+
+       TP_printk("start=%llu len=%llu "
+                 "existing(start=%llu len=%llu) "
+                 "em(start=%llu len=%llu)",
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len,
+                 (unsigned long long)__entry->e_start,
+                 (unsigned long long)__entry->e_len,
+                 (unsigned long long)__entry->map_start,
+                 (unsigned long long)__entry->map_len)
+);
+
 /* file extent item */
 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,