root/include/trace/events/btrfs.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 #undef TRACE_SYSTEM
   3 #define TRACE_SYSTEM btrfs
   4 
   5 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
   6 #define _TRACE_BTRFS_H
   7 
   8 #include <linux/writeback.h>
   9 #include <linux/tracepoint.h>
  10 #include <trace/events/mmflags.h>
  11 
  12 struct btrfs_root;
  13 struct btrfs_fs_info;
  14 struct btrfs_inode;
  15 struct extent_map;
  16 struct btrfs_file_extent_item;
  17 struct btrfs_ordered_extent;
  18 struct btrfs_delayed_ref_node;
  19 struct btrfs_delayed_tree_ref;
  20 struct btrfs_delayed_data_ref;
  21 struct btrfs_delayed_ref_head;
  22 struct btrfs_block_group_cache;
  23 struct btrfs_free_cluster;
  24 struct map_lookup;
  25 struct extent_buffer;
  26 struct btrfs_work;
  27 struct __btrfs_workqueue;
  28 struct btrfs_qgroup_extent_record;
  29 struct btrfs_qgroup;
  30 struct extent_io_tree;
  31 struct prelim_ref;
  32 struct btrfs_space_info;
  33 
  34 TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS_NR);
  35 TRACE_DEFINE_ENUM(FLUSH_DELAYED_ITEMS);
  36 TRACE_DEFINE_ENUM(FLUSH_DELALLOC);
  37 TRACE_DEFINE_ENUM(FLUSH_DELALLOC_WAIT);
  38 TRACE_DEFINE_ENUM(ALLOC_CHUNK);
  39 TRACE_DEFINE_ENUM(COMMIT_TRANS);
  40 
  41 #define show_ref_type(type)                                             \
  42         __print_symbolic(type,                                          \
  43                 { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
  44                 { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
  45                 { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
  46                 { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
  47                 { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
  48 
  49 #define __show_root_type(obj)                                           \
  50         __print_symbolic_u64(obj,                                       \
  51                 { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
  52                 { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
  53                 { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
  54                 { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
  55                 { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
  56                 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
  57                 { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
  58                 { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
  59                 { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
  60                 { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
  61                 { BTRFS_UUID_TREE_OBJECTID,     "UUID_TREE"     },      \
  62                 { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },  \
  63                 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
  64 
  65 #define show_root_type(obj)                                             \
  66         obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
  67               (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
  68                obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
  69 
  70 #define show_fi_type(type)                                              \
  71         __print_symbolic(type,                                          \
  72                  { BTRFS_FILE_EXTENT_INLINE,    "INLINE" },             \
  73                  { BTRFS_FILE_EXTENT_REG,       "REG"    },             \
  74                  { BTRFS_FILE_EXTENT_PREALLOC,  "PREALLOC"})
  75 
  76 #define show_qgroup_rsv_type(type)                                      \
  77         __print_symbolic(type,                                          \
  78                 { BTRFS_QGROUP_RSV_DATA,          "DATA"        },      \
  79                 { BTRFS_QGROUP_RSV_META_PERTRANS, "META_PERTRANS" },    \
  80                 { BTRFS_QGROUP_RSV_META_PREALLOC, "META_PREALLOC" })
  81 
  82 #define show_extent_io_tree_owner(owner)                                       \
  83         __print_symbolic(owner,                                                \
  84                 { IO_TREE_FS_INFO_FREED_EXTENTS0, "FREED_EXTENTS0" },          \
  85                 { IO_TREE_FS_INFO_FREED_EXTENTS1, "FREED_EXTENTS1" },          \
  86                 { IO_TREE_INODE_IO,               "INODE_IO" },                \
  87                 { IO_TREE_INODE_IO_FAILURE,       "INODE_IO_FAILURE" },        \
  88                 { IO_TREE_RELOC_BLOCKS,           "RELOC_BLOCKS" },            \
  89                 { IO_TREE_TRANS_DIRTY_PAGES,      "TRANS_DIRTY_PAGES" },       \
  90                 { IO_TREE_ROOT_DIRTY_LOG_PAGES,   "ROOT_DIRTY_LOG_PAGES" },    \
  91                 { IO_TREE_SELFTEST,               "SELFTEST" })
  92 
  93 #define BTRFS_GROUP_FLAGS       \
  94         { BTRFS_BLOCK_GROUP_DATA,       "DATA"},        \
  95         { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
  96         { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
  97         { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"},       \
  98         { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"},       \
  99         { BTRFS_BLOCK_GROUP_DUP,        "DUP"},         \
 100         { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
 101         { BTRFS_BLOCK_GROUP_RAID5,      "RAID5"},       \
 102         { BTRFS_BLOCK_GROUP_RAID6,      "RAID6"}
 103 
 104 #define EXTENT_FLAGS                                            \
 105         { EXTENT_DIRTY,                 "DIRTY"},               \
 106         { EXTENT_UPTODATE,              "UPTODATE"},            \
 107         { EXTENT_LOCKED,                "LOCKED"},              \
 108         { EXTENT_NEW,                   "NEW"},                 \
 109         { EXTENT_DELALLOC,              "DELALLOC"},            \
 110         { EXTENT_DEFRAG,                "DEFRAG"},              \
 111         { EXTENT_BOUNDARY,              "BOUNDARY"},            \
 112         { EXTENT_NODATASUM,             "NODATASUM"},           \
 113         { EXTENT_CLEAR_META_RESV,       "CLEAR_META_RESV"},     \
 114         { EXTENT_NEED_WAIT,             "NEED_WAIT"},           \
 115         { EXTENT_DAMAGED,               "DAMAGED"},             \
 116         { EXTENT_NORESERVE,             "NORESERVE"},           \
 117         { EXTENT_QGROUP_RESERVED,       "QGROUP_RESERVED"},     \
 118         { EXTENT_CLEAR_DATA_RESV,       "CLEAR_DATA_RESV"},     \
 119         { EXTENT_DELALLOC_NEW,          "DELALLOC_NEW"}
 120 
 121 #define BTRFS_FSID_SIZE 16
 122 #define TP_STRUCT__entry_fsid __array(u8, fsid, BTRFS_FSID_SIZE)
 123 
 124 #define TP_fast_assign_fsid(fs_info)                                    \
 125 ({                                                                      \
 126         if (fs_info)                                                    \
 127                 memcpy(__entry->fsid, fs_info->fs_devices->fsid,        \
 128                        BTRFS_FSID_SIZE);                                \
 129         else                                                            \
 130                 memset(__entry->fsid, 0, BTRFS_FSID_SIZE);              \
 131 })
 132 
 133 #define TP_STRUCT__entry_btrfs(args...)                                 \
 134         TP_STRUCT__entry(                                               \
 135                 TP_STRUCT__entry_fsid                                   \
 136                 args)
 137 #define TP_fast_assign_btrfs(fs_info, args...)                          \
 138         TP_fast_assign(                                                 \
 139                 TP_fast_assign_fsid(fs_info);                           \
 140                 args)
 141 #define TP_printk_btrfs(fmt, args...) \
 142         TP_printk("%pU: " fmt, __entry->fsid, args)
 143 
 144 TRACE_EVENT(btrfs_transaction_commit,
 145 
 146         TP_PROTO(const struct btrfs_root *root),
 147 
 148         TP_ARGS(root),
 149 
 150         TP_STRUCT__entry_btrfs(
 151                 __field(        u64,  generation                )
 152                 __field(        u64,  root_objectid             )
 153         ),
 154 
 155         TP_fast_assign_btrfs(root->fs_info,
 156                 __entry->generation     = root->fs_info->generation;
 157                 __entry->root_objectid  = root->root_key.objectid;
 158         ),
 159 
 160         TP_printk_btrfs("root=%llu(%s) gen=%llu",
 161                   show_root_type(__entry->root_objectid),
 162                   __entry->generation)
 163 );
 164 
 165 DECLARE_EVENT_CLASS(btrfs__inode,
 166 
 167         TP_PROTO(const struct inode *inode),
 168 
 169         TP_ARGS(inode),
 170 
 171         TP_STRUCT__entry_btrfs(
 172                 __field(        u64,  ino                       )
 173                 __field(        blkcnt_t,  blocks               )
 174                 __field(        u64,  disk_i_size               )
 175                 __field(        u64,  generation                )
 176                 __field(        u64,  last_trans                )
 177                 __field(        u64,  logged_trans              )
 178                 __field(        u64,  root_objectid             )
 179         ),
 180 
 181         TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
 182                 __entry->ino    = btrfs_ino(BTRFS_I(inode));
 183                 __entry->blocks = inode->i_blocks;
 184                 __entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
 185                 __entry->generation = BTRFS_I(inode)->generation;
 186                 __entry->last_trans = BTRFS_I(inode)->last_trans;
 187                 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
 188                 __entry->root_objectid =
 189                                 BTRFS_I(inode)->root->root_key.objectid;
 190         ),
 191 
 192         TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu "
 193                   "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
 194                   show_root_type(__entry->root_objectid),
 195                   __entry->generation,
 196                   __entry->ino,
 197                   (unsigned long long)__entry->blocks,
 198                   __entry->disk_i_size,
 199                   __entry->last_trans,
 200                   __entry->logged_trans)
 201 );
 202 
 203 DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
 204 
 205         TP_PROTO(const struct inode *inode),
 206 
 207         TP_ARGS(inode)
 208 );
 209 
 210 DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
 211 
 212         TP_PROTO(const struct inode *inode),
 213 
 214         TP_ARGS(inode)
 215 );
 216 
 217 DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
 218 
 219         TP_PROTO(const struct inode *inode),
 220 
 221         TP_ARGS(inode)
 222 );
 223 
 224 #define __show_map_type(type)                                           \
 225         __print_symbolic_u64(type,                                      \
 226                 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
 227                 { EXTENT_MAP_HOLE,      "HOLE"          },              \
 228                 { EXTENT_MAP_INLINE,    "INLINE"        },              \
 229                 { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
 230 
 231 #define show_map_type(type)                     \
 232         type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
 233 
 234 #define show_map_flags(flag)                                            \
 235         __print_flags(flag, "|",                                        \
 236                 { (1 << EXTENT_FLAG_PINNED),            "PINNED"        },\
 237                 { (1 << EXTENT_FLAG_COMPRESSED),        "COMPRESSED"    },\
 238                 { (1 << EXTENT_FLAG_PREALLOC),          "PREALLOC"      },\
 239                 { (1 << EXTENT_FLAG_LOGGING),           "LOGGING"       },\
 240                 { (1 << EXTENT_FLAG_FILLING),           "FILLING"       },\
 241                 { (1 << EXTENT_FLAG_FS_MAPPING),        "FS_MAPPING"    })
 242 
 243 TRACE_EVENT_CONDITION(btrfs_get_extent,
 244 
 245         TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
 246                  const struct extent_map *map),
 247 
 248         TP_ARGS(root, inode, map),
 249 
 250         TP_CONDITION(map),
 251 
 252         TP_STRUCT__entry_btrfs(
 253                 __field(        u64,  root_objectid     )
 254                 __field(        u64,  ino               )
 255                 __field(        u64,  start             )
 256                 __field(        u64,  len               )
 257                 __field(        u64,  orig_start        )
 258                 __field(        u64,  block_start       )
 259                 __field(        u64,  block_len         )
 260                 __field(        unsigned long,  flags   )
 261                 __field(        int,  refs              )
 262                 __field(        unsigned int,  compress_type    )
 263         ),
 264 
 265         TP_fast_assign_btrfs(root->fs_info,
 266                 __entry->root_objectid  = root->root_key.objectid;
 267                 __entry->ino            = btrfs_ino(inode);
 268                 __entry->start          = map->start;
 269                 __entry->len            = map->len;
 270                 __entry->orig_start     = map->orig_start;
 271                 __entry->block_start    = map->block_start;
 272                 __entry->block_len      = map->block_len;
 273                 __entry->flags          = map->flags;
 274                 __entry->refs           = refcount_read(&map->refs);
 275                 __entry->compress_type  = map->compress_type;
 276         ),
 277 
 278         TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
 279                   "orig_start=%llu block_start=%llu(%s) "
 280                   "block_len=%llu flags=%s refs=%u "
 281                   "compress_type=%u",
 282                   show_root_type(__entry->root_objectid),
 283                   __entry->ino,
 284                   __entry->start,
 285                   __entry->len,
 286                   __entry->orig_start,
 287                   show_map_type(__entry->block_start),
 288                   __entry->block_len,
 289                   show_map_flags(__entry->flags),
 290                   __entry->refs, __entry->compress_type)
 291 );
 292 
 293 TRACE_EVENT(btrfs_handle_em_exist,
 294 
 295         TP_PROTO(struct btrfs_fs_info *fs_info,
 296                 const struct extent_map *existing, const struct extent_map *map,
 297                 u64 start, u64 len),
 298 
 299         TP_ARGS(fs_info, existing, map, start, len),
 300 
 301         TP_STRUCT__entry_btrfs(
 302                 __field(        u64,  e_start           )
 303                 __field(        u64,  e_len             )
 304                 __field(        u64,  map_start         )
 305                 __field(        u64,  map_len           )
 306                 __field(        u64,  start             )
 307                 __field(        u64,  len               )
 308         ),
 309 
 310         TP_fast_assign_btrfs(fs_info,
 311                 __entry->e_start        = existing->start;
 312                 __entry->e_len          = existing->len;
 313                 __entry->map_start      = map->start;
 314                 __entry->map_len        = map->len;
 315                 __entry->start          = start;
 316                 __entry->len            = len;
 317         ),
 318 
 319         TP_printk_btrfs("start=%llu len=%llu "
 320                   "existing(start=%llu len=%llu) "
 321                   "em(start=%llu len=%llu)",
 322                   __entry->start,
 323                   __entry->len,
 324                   __entry->e_start,
 325                   __entry->e_len,
 326                   __entry->map_start,
 327                   __entry->map_len)
 328 );
 329 
 330 /* file extent item */
 331 DECLARE_EVENT_CLASS(btrfs__file_extent_item_regular,
 332 
 333         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 334                  struct btrfs_file_extent_item *fi, u64 start),
 335 
 336         TP_ARGS(bi, l, fi, start),
 337 
 338         TP_STRUCT__entry_btrfs(
 339                 __field(        u64,    root_obj        )
 340                 __field(        u64,    ino             )
 341                 __field(        loff_t, isize           )
 342                 __field(        u64,    disk_isize      )
 343                 __field(        u64,    num_bytes       )
 344                 __field(        u64,    ram_bytes       )
 345                 __field(        u64,    disk_bytenr     )
 346                 __field(        u64,    disk_num_bytes  )
 347                 __field(        u64,    extent_offset   )
 348                 __field(        u8,     extent_type     )
 349                 __field(        u8,     compression     )
 350                 __field(        u64,    extent_start    )
 351                 __field(        u64,    extent_end      )
 352         ),
 353 
 354         TP_fast_assign_btrfs(bi->root->fs_info,
 355                 __entry->root_obj       = bi->root->root_key.objectid;
 356                 __entry->ino            = btrfs_ino(bi);
 357                 __entry->isize          = bi->vfs_inode.i_size;
 358                 __entry->disk_isize     = bi->disk_i_size;
 359                 __entry->num_bytes      = btrfs_file_extent_num_bytes(l, fi);
 360                 __entry->ram_bytes      = btrfs_file_extent_ram_bytes(l, fi);
 361                 __entry->disk_bytenr    = btrfs_file_extent_disk_bytenr(l, fi);
 362                 __entry->disk_num_bytes = btrfs_file_extent_disk_num_bytes(l, fi);
 363                 __entry->extent_offset  = btrfs_file_extent_offset(l, fi);
 364                 __entry->extent_type    = btrfs_file_extent_type(l, fi);
 365                 __entry->compression    = btrfs_file_extent_compression(l, fi);
 366                 __entry->extent_start   = start;
 367                 __entry->extent_end     = (start + __entry->num_bytes);
 368         ),
 369 
 370         TP_printk_btrfs(
 371                 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
 372                 "file extent range=[%llu %llu] "
 373                 "(num_bytes=%llu ram_bytes=%llu disk_bytenr=%llu "
 374                 "disk_num_bytes=%llu extent_offset=%llu type=%s "
 375                 "compression=%u",
 376                 show_root_type(__entry->root_obj), __entry->ino,
 377                 __entry->isize,
 378                 __entry->disk_isize, __entry->extent_start,
 379                 __entry->extent_end, __entry->num_bytes, __entry->ram_bytes,
 380                 __entry->disk_bytenr, __entry->disk_num_bytes,
 381                 __entry->extent_offset, show_fi_type(__entry->extent_type),
 382                 __entry->compression)
 383 );
 384 
 385 DECLARE_EVENT_CLASS(
 386         btrfs__file_extent_item_inline,
 387 
 388         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 389                  struct btrfs_file_extent_item *fi, int slot, u64 start),
 390 
 391         TP_ARGS(bi, l, fi, slot,  start),
 392 
 393         TP_STRUCT__entry_btrfs(
 394                 __field(        u64,    root_obj        )
 395                 __field(        u64,    ino             )
 396                 __field(        loff_t, isize           )
 397                 __field(        u64,    disk_isize      )
 398                 __field(        u8,     extent_type     )
 399                 __field(        u8,     compression     )
 400                 __field(        u64,    extent_start    )
 401                 __field(        u64,    extent_end      )
 402         ),
 403 
 404         TP_fast_assign_btrfs(
 405                 bi->root->fs_info,
 406                 __entry->root_obj       = bi->root->root_key.objectid;
 407                 __entry->ino            = btrfs_ino(bi);
 408                 __entry->isize          = bi->vfs_inode.i_size;
 409                 __entry->disk_isize     = bi->disk_i_size;
 410                 __entry->extent_type    = btrfs_file_extent_type(l, fi);
 411                 __entry->compression    = btrfs_file_extent_compression(l, fi);
 412                 __entry->extent_start   = start;
 413                 __entry->extent_end     = (start + btrfs_file_extent_ram_bytes(l, fi));
 414         ),
 415 
 416         TP_printk_btrfs(
 417                 "root=%llu(%s) inode=%llu size=%llu disk_isize=%llu "
 418                 "file extent range=[%llu %llu] "
 419                 "extent_type=%s compression=%u",
 420                 show_root_type(__entry->root_obj), __entry->ino, __entry->isize,
 421                 __entry->disk_isize, __entry->extent_start,
 422                 __entry->extent_end, show_fi_type(__entry->extent_type),
 423                 __entry->compression)
 424 );
 425 
 426 DEFINE_EVENT(
 427         btrfs__file_extent_item_regular, btrfs_get_extent_show_fi_regular,
 428 
 429         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 430                  struct btrfs_file_extent_item *fi, u64 start),
 431 
 432         TP_ARGS(bi, l, fi, start)
 433 );
 434 
 435 DEFINE_EVENT(
 436         btrfs__file_extent_item_regular, btrfs_truncate_show_fi_regular,
 437 
 438         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 439                  struct btrfs_file_extent_item *fi, u64 start),
 440 
 441         TP_ARGS(bi, l, fi, start)
 442 );
 443 
 444 DEFINE_EVENT(
 445         btrfs__file_extent_item_inline, btrfs_get_extent_show_fi_inline,
 446 
 447         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 448                  struct btrfs_file_extent_item *fi, int slot, u64 start),
 449 
 450         TP_ARGS(bi, l, fi, slot, start)
 451 );
 452 
 453 DEFINE_EVENT(
 454         btrfs__file_extent_item_inline, btrfs_truncate_show_fi_inline,
 455 
 456         TP_PROTO(struct btrfs_inode *bi, struct extent_buffer *l,
 457                  struct btrfs_file_extent_item *fi, int slot, u64 start),
 458 
 459         TP_ARGS(bi, l, fi, slot, start)
 460 );
 461 
 462 #define show_ordered_flags(flags)                                          \
 463         __print_flags(flags, "|",                                          \
 464                 { (1 << BTRFS_ORDERED_IO_DONE),         "IO_DONE"       }, \
 465                 { (1 << BTRFS_ORDERED_COMPLETE),        "COMPLETE"      }, \
 466                 { (1 << BTRFS_ORDERED_NOCOW),           "NOCOW"         }, \
 467                 { (1 << BTRFS_ORDERED_COMPRESSED),      "COMPRESSED"    }, \
 468                 { (1 << BTRFS_ORDERED_PREALLOC),        "PREALLOC"      }, \
 469                 { (1 << BTRFS_ORDERED_DIRECT),          "DIRECT"        }, \
 470                 { (1 << BTRFS_ORDERED_IOERR),           "IOERR"         }, \
 471                 { (1 << BTRFS_ORDERED_UPDATED_ISIZE),   "UPDATED_ISIZE" }, \
 472                 { (1 << BTRFS_ORDERED_TRUNCATED),       "TRUNCATED"     })
 473 
 474 
 475 DECLARE_EVENT_CLASS(btrfs__ordered_extent,
 476 
 477         TP_PROTO(const struct inode *inode,
 478                  const struct btrfs_ordered_extent *ordered),
 479 
 480         TP_ARGS(inode, ordered),
 481 
 482         TP_STRUCT__entry_btrfs(
 483                 __field(        u64,  ino               )
 484                 __field(        u64,  file_offset       )
 485                 __field(        u64,  start             )
 486                 __field(        u64,  len               )
 487                 __field(        u64,  disk_len          )
 488                 __field(        u64,  bytes_left        )
 489                 __field(        unsigned long,  flags   )
 490                 __field(        int,  compress_type     )
 491                 __field(        int,  refs              )
 492                 __field(        u64,  root_objectid     )
 493                 __field(        u64,  truncated_len     )
 494         ),
 495 
 496         TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
 497                 __entry->ino            = btrfs_ino(BTRFS_I(inode));
 498                 __entry->file_offset    = ordered->file_offset;
 499                 __entry->start          = ordered->start;
 500                 __entry->len            = ordered->len;
 501                 __entry->disk_len       = ordered->disk_len;
 502                 __entry->bytes_left     = ordered->bytes_left;
 503                 __entry->flags          = ordered->flags;
 504                 __entry->compress_type  = ordered->compress_type;
 505                 __entry->refs           = refcount_read(&ordered->refs);
 506                 __entry->root_objectid  =
 507                                 BTRFS_I(inode)->root->root_key.objectid;
 508                 __entry->truncated_len  = ordered->truncated_len;
 509         ),
 510 
 511         TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
 512                   "start=%llu len=%llu disk_len=%llu "
 513                   "truncated_len=%llu "
 514                   "bytes_left=%llu flags=%s compress_type=%d "
 515                   "refs=%d",
 516                   show_root_type(__entry->root_objectid),
 517                   __entry->ino,
 518                   __entry->file_offset,
 519                   __entry->start,
 520                   __entry->len,
 521                   __entry->disk_len,
 522                   __entry->truncated_len,
 523                   __entry->bytes_left,
 524                   show_ordered_flags(__entry->flags),
 525                   __entry->compress_type, __entry->refs)
 526 );
 527 
 528 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
 529 
 530         TP_PROTO(const struct inode *inode,
 531                  const struct btrfs_ordered_extent *ordered),
 532 
 533         TP_ARGS(inode, ordered)
 534 );
 535 
 536 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
 537 
 538         TP_PROTO(const struct inode *inode,
 539                  const struct btrfs_ordered_extent *ordered),
 540 
 541         TP_ARGS(inode, ordered)
 542 );
 543 
 544 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
 545 
 546         TP_PROTO(const struct inode *inode,
 547                  const struct btrfs_ordered_extent *ordered),
 548 
 549         TP_ARGS(inode, ordered)
 550 );
 551 
 552 DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
 553 
 554         TP_PROTO(const struct inode *inode,
 555                  const struct btrfs_ordered_extent *ordered),
 556 
 557         TP_ARGS(inode, ordered)
 558 );
 559 
 560 DECLARE_EVENT_CLASS(btrfs__writepage,
 561 
 562         TP_PROTO(const struct page *page, const struct inode *inode,
 563                  const struct writeback_control *wbc),
 564 
 565         TP_ARGS(page, inode, wbc),
 566 
 567         TP_STRUCT__entry_btrfs(
 568                 __field(        u64,    ino                     )
 569                 __field(        pgoff_t,  index                 )
 570                 __field(        long,   nr_to_write             )
 571                 __field(        long,   pages_skipped           )
 572                 __field(        loff_t, range_start             )
 573                 __field(        loff_t, range_end               )
 574                 __field(        char,   for_kupdate             )
 575                 __field(        char,   for_reclaim             )
 576                 __field(        char,   range_cyclic            )
 577                 __field(        pgoff_t,  writeback_index       )
 578                 __field(        u64,    root_objectid           )
 579         ),
 580 
 581         TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
 582                 __entry->ino            = btrfs_ino(BTRFS_I(inode));
 583                 __entry->index          = page->index;
 584                 __entry->nr_to_write    = wbc->nr_to_write;
 585                 __entry->pages_skipped  = wbc->pages_skipped;
 586                 __entry->range_start    = wbc->range_start;
 587                 __entry->range_end      = wbc->range_end;
 588                 __entry->for_kupdate    = wbc->for_kupdate;
 589                 __entry->for_reclaim    = wbc->for_reclaim;
 590                 __entry->range_cyclic   = wbc->range_cyclic;
 591                 __entry->writeback_index = inode->i_mapping->writeback_index;
 592                 __entry->root_objectid  =
 593                                  BTRFS_I(inode)->root->root_key.objectid;
 594         ),
 595 
 596         TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu "
 597                   "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
 598                   "range_end=%llu for_kupdate=%d "
 599                   "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
 600                   show_root_type(__entry->root_objectid),
 601                   __entry->ino, __entry->index,
 602                   __entry->nr_to_write, __entry->pages_skipped,
 603                   __entry->range_start, __entry->range_end,
 604                   __entry->for_kupdate,
 605                   __entry->for_reclaim, __entry->range_cyclic,
 606                   (unsigned long)__entry->writeback_index)
 607 );
 608 
 609 DEFINE_EVENT(btrfs__writepage, __extent_writepage,
 610 
 611         TP_PROTO(const struct page *page, const struct inode *inode,
 612                  const struct writeback_control *wbc),
 613 
 614         TP_ARGS(page, inode, wbc)
 615 );
 616 
 617 TRACE_EVENT(btrfs_writepage_end_io_hook,
 618 
 619         TP_PROTO(const struct page *page, u64 start, u64 end, int uptodate),
 620 
 621         TP_ARGS(page, start, end, uptodate),
 622 
 623         TP_STRUCT__entry_btrfs(
 624                 __field(        u64,     ino            )
 625                 __field(        pgoff_t, index          )
 626                 __field(        u64,     start          )
 627                 __field(        u64,     end            )
 628                 __field(        int,     uptodate       )
 629                 __field(        u64,    root_objectid   )
 630         ),
 631 
 632         TP_fast_assign_btrfs(btrfs_sb(page->mapping->host->i_sb),
 633                 __entry->ino    = btrfs_ino(BTRFS_I(page->mapping->host));
 634                 __entry->index  = page->index;
 635                 __entry->start  = start;
 636                 __entry->end    = end;
 637                 __entry->uptodate = uptodate;
 638                 __entry->root_objectid  =
 639                          BTRFS_I(page->mapping->host)->root->root_key.objectid;
 640         ),
 641 
 642         TP_printk_btrfs("root=%llu(%s) ino=%llu page_index=%lu start=%llu "
 643                   "end=%llu uptodate=%d",
 644                   show_root_type(__entry->root_objectid),
 645                   __entry->ino, (unsigned long)__entry->index,
 646                   __entry->start,
 647                   __entry->end, __entry->uptodate)
 648 );
 649 
 650 TRACE_EVENT(btrfs_sync_file,
 651 
 652         TP_PROTO(const struct file *file, int datasync),
 653 
 654         TP_ARGS(file, datasync),
 655 
 656         TP_STRUCT__entry_btrfs(
 657                 __field(        u64,    ino             )
 658                 __field(        u64,    parent          )
 659                 __field(        int,    datasync        )
 660                 __field(        u64,    root_objectid   )
 661         ),
 662 
 663         TP_fast_assign(
 664                 const struct dentry *dentry = file->f_path.dentry;
 665                 const struct inode *inode = d_inode(dentry);
 666 
 667                 TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb));
 668                 __entry->ino            = btrfs_ino(BTRFS_I(inode));
 669                 __entry->parent         = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent)));
 670                 __entry->datasync       = datasync;
 671                 __entry->root_objectid  =
 672                                  BTRFS_I(inode)->root->root_key.objectid;
 673         ),
 674 
 675         TP_printk_btrfs("root=%llu(%s) ino=%llu parent=%llu datasync=%d",
 676                   show_root_type(__entry->root_objectid),
 677                   __entry->ino,
 678                   __entry->parent,
 679                   __entry->datasync)
 680 );
 681 
 682 TRACE_EVENT(btrfs_sync_fs,
 683 
 684         TP_PROTO(const struct btrfs_fs_info *fs_info, int wait),
 685 
 686         TP_ARGS(fs_info, wait),
 687 
 688         TP_STRUCT__entry_btrfs(
 689                 __field(        int,  wait              )
 690         ),
 691 
 692         TP_fast_assign_btrfs(fs_info,
 693                 __entry->wait   = wait;
 694         ),
 695 
 696         TP_printk_btrfs("wait=%d", __entry->wait)
 697 );
 698 
 699 TRACE_EVENT(btrfs_add_block_group,
 700 
 701         TP_PROTO(const struct btrfs_fs_info *fs_info,
 702                  const struct btrfs_block_group_cache *block_group, int create),
 703 
 704         TP_ARGS(fs_info, block_group, create),
 705 
 706         TP_STRUCT__entry_btrfs(
 707                 __field(        u64,    offset                  )
 708                 __field(        u64,    size                    )
 709                 __field(        u64,    flags                   )
 710                 __field(        u64,    bytes_used              )
 711                 __field(        u64,    bytes_super             )
 712                 __field(        int,    create                  )
 713         ),
 714 
 715         TP_fast_assign_btrfs(fs_info,
 716                 __entry->offset         = block_group->key.objectid;
 717                 __entry->size           = block_group->key.offset;
 718                 __entry->flags          = block_group->flags;
 719                 __entry->bytes_used     =
 720                         btrfs_block_group_used(&block_group->item);
 721                 __entry->bytes_super    = block_group->bytes_super;
 722                 __entry->create         = create;
 723         ),
 724 
 725         TP_printk_btrfs("block_group offset=%llu size=%llu "
 726                   "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
 727                   "create=%d",
 728                   __entry->offset,
 729                   __entry->size,
 730                   __entry->flags,
 731                   __print_flags((unsigned long)__entry->flags, "|",
 732                                 BTRFS_GROUP_FLAGS),
 733                   __entry->bytes_used,
 734                   __entry->bytes_super, __entry->create)
 735 );
 736 
 737 #define show_ref_action(action)                                         \
 738         __print_symbolic(action,                                        \
 739                 { BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },        \
 740                 { BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },       \
 741                 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" },     \
 742                 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
 743                         
 744 
 745 DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
 746 
 747         TP_PROTO(const struct btrfs_fs_info *fs_info,
 748                  const struct btrfs_delayed_ref_node *ref,
 749                  const struct btrfs_delayed_tree_ref *full_ref,
 750                  int action),
 751 
 752         TP_ARGS(fs_info, ref, full_ref, action),
 753 
 754         TP_STRUCT__entry_btrfs(
 755                 __field(        u64,  bytenr            )
 756                 __field(        u64,  num_bytes         )
 757                 __field(        int,  action            ) 
 758                 __field(        u64,  parent            )
 759                 __field(        u64,  ref_root          )
 760                 __field(        int,  level             )
 761                 __field(        int,  type              )
 762                 __field(        u64,  seq               )
 763         ),
 764 
 765         TP_fast_assign_btrfs(fs_info,
 766                 __entry->bytenr         = ref->bytenr;
 767                 __entry->num_bytes      = ref->num_bytes;
 768                 __entry->action         = action;
 769                 __entry->parent         = full_ref->parent;
 770                 __entry->ref_root       = full_ref->root;
 771                 __entry->level          = full_ref->level;
 772                 __entry->type           = ref->type;
 773                 __entry->seq            = ref->seq;
 774         ),
 775 
 776         TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
 777                   "parent=%llu(%s) ref_root=%llu(%s) level=%d "
 778                   "type=%s seq=%llu",
 779                   __entry->bytenr,
 780                   __entry->num_bytes,
 781                   show_ref_action(__entry->action),
 782                   show_root_type(__entry->parent),
 783                   show_root_type(__entry->ref_root),
 784                   __entry->level, show_ref_type(__entry->type),
 785                   __entry->seq)
 786 );
 787 
 788 DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
 789 
 790         TP_PROTO(const struct btrfs_fs_info *fs_info,
 791                  const struct btrfs_delayed_ref_node *ref,
 792                  const struct btrfs_delayed_tree_ref *full_ref,
 793                  int action),
 794 
 795         TP_ARGS(fs_info, ref, full_ref, action)
 796 );
 797 
 798 DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
 799 
 800         TP_PROTO(const struct btrfs_fs_info *fs_info,
 801                  const struct btrfs_delayed_ref_node *ref,
 802                  const struct btrfs_delayed_tree_ref *full_ref,
 803                  int action),
 804 
 805         TP_ARGS(fs_info, ref, full_ref, action)
 806 );
 807 
 808 DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
 809 
 810         TP_PROTO(const struct btrfs_fs_info *fs_info,
 811                  const struct btrfs_delayed_ref_node *ref,
 812                  const struct btrfs_delayed_data_ref *full_ref,
 813                  int action),
 814 
 815         TP_ARGS(fs_info, ref, full_ref, action),
 816 
 817         TP_STRUCT__entry_btrfs(
 818                 __field(        u64,  bytenr            )
 819                 __field(        u64,  num_bytes         )
 820                 __field(        int,  action            ) 
 821                 __field(        u64,  parent            )
 822                 __field(        u64,  ref_root          )
 823                 __field(        u64,  owner             )
 824                 __field(        u64,  offset            )
 825                 __field(        int,  type              )
 826                 __field(        u64,  seq               )
 827         ),
 828 
 829         TP_fast_assign_btrfs(fs_info,
 830                 __entry->bytenr         = ref->bytenr;
 831                 __entry->num_bytes      = ref->num_bytes;
 832                 __entry->action         = action;
 833                 __entry->parent         = full_ref->parent;
 834                 __entry->ref_root       = full_ref->root;
 835                 __entry->owner          = full_ref->objectid;
 836                 __entry->offset         = full_ref->offset;
 837                 __entry->type           = ref->type;
 838                 __entry->seq            = ref->seq;
 839         ),
 840 
 841         TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
 842                   "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
 843                   "offset=%llu type=%s seq=%llu",
 844                   __entry->bytenr,
 845                   __entry->num_bytes,
 846                   show_ref_action(__entry->action),
 847                   show_root_type(__entry->parent),
 848                   show_root_type(__entry->ref_root),
 849                   __entry->owner,
 850                   __entry->offset,
 851                   show_ref_type(__entry->type),
 852                   __entry->seq)
 853 );
 854 
 855 DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
 856 
 857         TP_PROTO(const struct btrfs_fs_info *fs_info,
 858                  const struct btrfs_delayed_ref_node *ref,
 859                  const struct btrfs_delayed_data_ref *full_ref,
 860                  int action),
 861 
 862         TP_ARGS(fs_info, ref, full_ref, action)
 863 );
 864 
 865 DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
 866 
 867         TP_PROTO(const struct btrfs_fs_info *fs_info,
 868                  const struct btrfs_delayed_ref_node *ref,
 869                  const struct btrfs_delayed_data_ref *full_ref,
 870                  int action),
 871 
 872         TP_ARGS(fs_info, ref, full_ref, action)
 873 );
 874 
 875 DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
 876 
 877         TP_PROTO(const struct btrfs_fs_info *fs_info,
 878                  const struct btrfs_delayed_ref_head *head_ref,
 879                  int action),
 880 
 881         TP_ARGS(fs_info, head_ref, action),
 882 
 883         TP_STRUCT__entry_btrfs(
 884                 __field(        u64,  bytenr            )
 885                 __field(        u64,  num_bytes         )
 886                 __field(        int,  action            ) 
 887                 __field(        int,  is_data           )
 888         ),
 889 
 890         TP_fast_assign_btrfs(fs_info,
 891                 __entry->bytenr         = head_ref->bytenr;
 892                 __entry->num_bytes      = head_ref->num_bytes;
 893                 __entry->action         = action;
 894                 __entry->is_data        = head_ref->is_data;
 895         ),
 896 
 897         TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
 898                   __entry->bytenr,
 899                   __entry->num_bytes,
 900                   show_ref_action(__entry->action),
 901                   __entry->is_data)
 902 );
 903 
 904 DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
 905 
 906         TP_PROTO(const struct btrfs_fs_info *fs_info,
 907                  const struct btrfs_delayed_ref_head *head_ref,
 908                  int action),
 909 
 910         TP_ARGS(fs_info, head_ref, action)
 911 );
 912 
 913 DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
 914 
 915         TP_PROTO(const struct btrfs_fs_info *fs_info,
 916                  const struct btrfs_delayed_ref_head *head_ref,
 917                  int action),
 918 
 919         TP_ARGS(fs_info, head_ref, action)
 920 );
 921 
 922 #define show_chunk_type(type)                                   \
 923         __print_flags(type, "|",                                \
 924                 { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
 925                 { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
 926                 { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
 927                 { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
 928                 { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
 929                 { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
 930                 { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
 931                 { BTRFS_BLOCK_GROUP_RAID5,      "RAID5" },      \
 932                 { BTRFS_BLOCK_GROUP_RAID6,      "RAID6" })
 933 
 934 DECLARE_EVENT_CLASS(btrfs__chunk,
 935 
 936         TP_PROTO(const struct btrfs_fs_info *fs_info,
 937                  const struct map_lookup *map, u64 offset, u64 size),
 938 
 939         TP_ARGS(fs_info, map, offset, size),
 940 
 941         TP_STRUCT__entry_btrfs(
 942                 __field(        int,  num_stripes               )
 943                 __field(        u64,  type                      )
 944                 __field(        int,  sub_stripes               )
 945                 __field(        u64,  offset                    )
 946                 __field(        u64,  size                      )
 947                 __field(        u64,  root_objectid             )
 948         ),
 949 
 950         TP_fast_assign_btrfs(fs_info,
 951                 __entry->num_stripes    = map->num_stripes;
 952                 __entry->type           = map->type;
 953                 __entry->sub_stripes    = map->sub_stripes;
 954                 __entry->offset         = offset;
 955                 __entry->size           = size;
 956                 __entry->root_objectid  = fs_info->chunk_root->root_key.objectid;
 957         ),
 958 
 959         TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
 960                   "num_stripes=%d sub_stripes=%d type=%s",
 961                   show_root_type(__entry->root_objectid),
 962                   __entry->offset,
 963                   __entry->size,
 964                   __entry->num_stripes, __entry->sub_stripes,
 965                   show_chunk_type(__entry->type))
 966 );
 967 
 968 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
 969 
 970         TP_PROTO(const struct btrfs_fs_info *fs_info,
 971                  const struct map_lookup *map, u64 offset, u64 size),
 972 
 973         TP_ARGS(fs_info, map, offset, size)
 974 );
 975 
 976 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
 977 
 978         TP_PROTO(const struct btrfs_fs_info *fs_info,
 979                  const struct map_lookup *map, u64 offset, u64 size),
 980 
 981         TP_ARGS(fs_info, map, offset, size)
 982 );
 983 
 984 TRACE_EVENT(btrfs_cow_block,
 985 
 986         TP_PROTO(const struct btrfs_root *root, const struct extent_buffer *buf,
 987                  const struct extent_buffer *cow),
 988 
 989         TP_ARGS(root, buf, cow),
 990 
 991         TP_STRUCT__entry_btrfs(
 992                 __field(        u64,  root_objectid             )
 993                 __field(        u64,  buf_start                 )
 994                 __field(        int,  refs                      )
 995                 __field(        u64,  cow_start                 )
 996                 __field(        int,  buf_level                 )
 997                 __field(        int,  cow_level                 )
 998         ),
 999 
1000         TP_fast_assign_btrfs(root->fs_info,
1001                 __entry->root_objectid  = root->root_key.objectid;
1002                 __entry->buf_start      = buf->start;
1003                 __entry->refs           = atomic_read(&buf->refs);
1004                 __entry->cow_start      = cow->start;
1005                 __entry->buf_level      = btrfs_header_level(buf);
1006                 __entry->cow_level      = btrfs_header_level(cow);
1007         ),
1008 
1009         TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
1010                   "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
1011                   show_root_type(__entry->root_objectid),
1012                   __entry->refs,
1013                   __entry->buf_start,
1014                   __entry->buf_level,
1015                   __entry->cow_start,
1016                   __entry->cow_level)
1017 );
1018 
1019 TRACE_EVENT(btrfs_space_reservation,
1020 
1021         TP_PROTO(const struct btrfs_fs_info *fs_info, char *type, u64 val,
1022                  u64 bytes, int reserve),
1023 
1024         TP_ARGS(fs_info, type, val, bytes, reserve),
1025 
1026         TP_STRUCT__entry_btrfs(
1027                 __string(       type,   type                    )
1028                 __field(        u64,    val                     )
1029                 __field(        u64,    bytes                   )
1030                 __field(        int,    reserve                 )
1031         ),
1032 
1033         TP_fast_assign_btrfs(fs_info,
1034                 __assign_str(type, type);
1035                 __entry->val            = val;
1036                 __entry->bytes          = bytes;
1037                 __entry->reserve        = reserve;
1038         ),
1039 
1040         TP_printk_btrfs("%s: %llu %s %llu", __get_str(type), __entry->val,
1041                         __entry->reserve ? "reserve" : "release",
1042                         __entry->bytes)
1043 );
1044 
1045 #define show_flush_action(action)                                               \
1046         __print_symbolic(action,                                                \
1047                 { BTRFS_RESERVE_NO_FLUSH,       "BTRFS_RESERVE_NO_FLUSH"},      \
1048                 { BTRFS_RESERVE_FLUSH_LIMIT,    "BTRFS_RESERVE_FLUSH_LIMIT"},   \
1049                 { BTRFS_RESERVE_FLUSH_ALL,      "BTRFS_RESERVE_FLUSH_ALL"})
1050 
1051 TRACE_EVENT(btrfs_trigger_flush,
1052 
1053         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 bytes,
1054                  int flush, char *reason),
1055 
1056         TP_ARGS(fs_info, flags, bytes, flush, reason),
1057 
1058         TP_STRUCT__entry_btrfs(
1059                 __field(        u64,    flags                   )
1060                 __field(        u64,    bytes                   )
1061                 __field(        int,    flush                   )
1062                 __string(       reason, reason                  )
1063         ),
1064 
1065         TP_fast_assign_btrfs(fs_info,
1066                 __entry->flags  = flags;
1067                 __entry->bytes  = bytes;
1068                 __entry->flush  = flush;
1069                 __assign_str(reason, reason)
1070         ),
1071 
1072         TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
1073                   __get_str(reason), __entry->flush,
1074                   show_flush_action(__entry->flush),
1075                   __entry->flags,
1076                   __print_flags((unsigned long)__entry->flags, "|",
1077                                 BTRFS_GROUP_FLAGS),
1078                   __entry->bytes)
1079 );
1080 
1081 #define show_flush_state(state)                                                 \
1082         __print_symbolic(state,                                                 \
1083                 { FLUSH_DELAYED_ITEMS_NR,       "FLUSH_DELAYED_ITEMS_NR"},      \
1084                 { FLUSH_DELAYED_ITEMS,          "FLUSH_DELAYED_ITEMS"},         \
1085                 { FLUSH_DELALLOC,               "FLUSH_DELALLOC"},              \
1086                 { FLUSH_DELALLOC_WAIT,          "FLUSH_DELALLOC_WAIT"},         \
1087                 { FLUSH_DELAYED_REFS_NR,        "FLUSH_DELAYED_REFS_NR"},       \
1088                 { FLUSH_DELAYED_REFS,           "FLUSH_ELAYED_REFS"},           \
1089                 { ALLOC_CHUNK,                  "ALLOC_CHUNK"},                 \
1090                 { ALLOC_CHUNK_FORCE,            "ALLOC_CHUNK_FORCE"},           \
1091                 { RUN_DELAYED_IPUTS,            "RUN_DELAYED_IPUTS"},           \
1092                 { COMMIT_TRANS,                 "COMMIT_TRANS"})
1093 
1094 TRACE_EVENT(btrfs_flush_space,
1095 
1096         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes,
1097                  int state, int ret),
1098 
1099         TP_ARGS(fs_info, flags, num_bytes, state, ret),
1100 
1101         TP_STRUCT__entry_btrfs(
1102                 __field(        u64,    flags                   )
1103                 __field(        u64,    num_bytes               )
1104                 __field(        int,    state                   )
1105                 __field(        int,    ret                     )
1106         ),
1107 
1108         TP_fast_assign_btrfs(fs_info,
1109                 __entry->flags          =       flags;
1110                 __entry->num_bytes      =       num_bytes;
1111                 __entry->state          =       state;
1112                 __entry->ret            =       ret;
1113         ),
1114 
1115         TP_printk_btrfs("state=%d(%s) flags=%llu(%s) num_bytes=%llu ret=%d",
1116                   __entry->state,
1117                   show_flush_state(__entry->state),
1118                   __entry->flags,
1119                   __print_flags((unsigned long)__entry->flags, "|",
1120                                 BTRFS_GROUP_FLAGS),
1121                   __entry->num_bytes, __entry->ret)
1122 );
1123 
1124 DECLARE_EVENT_CLASS(btrfs__reserved_extent,
1125 
1126         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1127 
1128         TP_ARGS(fs_info, start, len),
1129 
1130         TP_STRUCT__entry_btrfs(
1131                 __field(        u64,  start                     )
1132                 __field(        u64,  len                       )
1133         ),
1134 
1135         TP_fast_assign_btrfs(fs_info,
1136                 __entry->start          = start;
1137                 __entry->len            = len;
1138         ),
1139 
1140         TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
1141                   show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1142                   __entry->start,
1143                   __entry->len)
1144 );
1145 
1146 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
1147 
1148         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1149 
1150         TP_ARGS(fs_info, start, len)
1151 );
1152 
1153 DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
1154 
1155         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len),
1156 
1157         TP_ARGS(fs_info, start, len)
1158 );
1159 
1160 TRACE_EVENT(find_free_extent,
1161 
1162         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes,
1163                  u64 empty_size, u64 data),
1164 
1165         TP_ARGS(fs_info, num_bytes, empty_size, data),
1166 
1167         TP_STRUCT__entry_btrfs(
1168                 __field(        u64,    num_bytes               )
1169                 __field(        u64,    empty_size              )
1170                 __field(        u64,    data                    )
1171         ),
1172 
1173         TP_fast_assign_btrfs(fs_info,
1174                 __entry->num_bytes      = num_bytes;
1175                 __entry->empty_size     = empty_size;
1176                 __entry->data           = data;
1177         ),
1178 
1179         TP_printk_btrfs("root=%llu(%s) len=%llu empty_size=%llu flags=%llu(%s)",
1180                   show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1181                   __entry->num_bytes, __entry->empty_size, __entry->data,
1182                   __print_flags((unsigned long)__entry->data, "|",
1183                                  BTRFS_GROUP_FLAGS))
1184 );
1185 
1186 DECLARE_EVENT_CLASS(btrfs__reserve_extent,
1187 
1188         TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
1189                  u64 len),
1190 
1191         TP_ARGS(block_group, start, len),
1192 
1193         TP_STRUCT__entry_btrfs(
1194                 __field(        u64,    bg_objectid             )
1195                 __field(        u64,    flags                   )
1196                 __field(        u64,    start                   )
1197                 __field(        u64,    len                     )
1198         ),
1199 
1200         TP_fast_assign_btrfs(block_group->fs_info,
1201                 __entry->bg_objectid    = block_group->key.objectid;
1202                 __entry->flags          = block_group->flags;
1203                 __entry->start          = start;
1204                 __entry->len            = len;
1205         ),
1206 
1207         TP_printk_btrfs("root=%llu(%s) block_group=%llu flags=%llu(%s) "
1208                   "start=%llu len=%llu",
1209                   show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
1210                   __entry->bg_objectid,
1211                   __entry->flags, __print_flags((unsigned long)__entry->flags,
1212                                                 "|", BTRFS_GROUP_FLAGS),
1213                   __entry->start, __entry->len)
1214 );
1215 
1216 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
1217 
1218         TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
1219                  u64 len),
1220 
1221         TP_ARGS(block_group, start, len)
1222 );
1223 
1224 DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
1225 
1226         TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
1227                  u64 len),
1228 
1229         TP_ARGS(block_group, start, len)
1230 );
1231 
1232 TRACE_EVENT(btrfs_find_cluster,
1233 
1234         TP_PROTO(const struct btrfs_block_group_cache *block_group, u64 start,
1235                  u64 bytes, u64 empty_size, u64 min_bytes),
1236 
1237         TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
1238 
1239         TP_STRUCT__entry_btrfs(
1240                 __field(        u64,    bg_objectid             )
1241                 __field(        u64,    flags                   )
1242                 __field(        u64,    start                   )
1243                 __field(        u64,    bytes                   )
1244                 __field(        u64,    empty_size              )
1245                 __field(        u64,    min_bytes               )
1246         ),
1247 
1248         TP_fast_assign_btrfs(block_group->fs_info,
1249                 __entry->bg_objectid    = block_group->key.objectid;
1250                 __entry->flags          = block_group->flags;
1251                 __entry->start          = start;
1252                 __entry->bytes          = bytes;
1253                 __entry->empty_size     = empty_size;
1254                 __entry->min_bytes      = min_bytes;
1255         ),
1256 
1257         TP_printk_btrfs("block_group=%llu flags=%llu(%s) start=%llu len=%llu "
1258                   "empty_size=%llu min_bytes=%llu", __entry->bg_objectid,
1259                   __entry->flags,
1260                   __print_flags((unsigned long)__entry->flags, "|",
1261                                 BTRFS_GROUP_FLAGS), __entry->start,
1262                   __entry->bytes, __entry->empty_size,  __entry->min_bytes)
1263 );
1264 
1265 TRACE_EVENT(btrfs_failed_cluster_setup,
1266 
1267         TP_PROTO(const struct btrfs_block_group_cache *block_group),
1268 
1269         TP_ARGS(block_group),
1270 
1271         TP_STRUCT__entry_btrfs(
1272                 __field(        u64,    bg_objectid             )
1273         ),
1274 
1275         TP_fast_assign_btrfs(block_group->fs_info,
1276                 __entry->bg_objectid    = block_group->key.objectid;
1277         ),
1278 
1279         TP_printk_btrfs("block_group=%llu", __entry->bg_objectid)
1280 );
1281 
1282 TRACE_EVENT(btrfs_setup_cluster,
1283 
1284         TP_PROTO(const struct btrfs_block_group_cache *block_group,
1285                  const struct btrfs_free_cluster *cluster,
1286                  u64 size, int bitmap),
1287 
1288         TP_ARGS(block_group, cluster, size, bitmap),
1289 
1290         TP_STRUCT__entry_btrfs(
1291                 __field(        u64,    bg_objectid             )
1292                 __field(        u64,    flags                   )
1293                 __field(        u64,    start                   )
1294                 __field(        u64,    max_size                )
1295                 __field(        u64,    size                    )
1296                 __field(        int,    bitmap                  )
1297         ),
1298 
1299         TP_fast_assign_btrfs(block_group->fs_info,
1300                 __entry->bg_objectid    = block_group->key.objectid;
1301                 __entry->flags          = block_group->flags;
1302                 __entry->start          = cluster->window_start;
1303                 __entry->max_size       = cluster->max_size;
1304                 __entry->size           = size;
1305                 __entry->bitmap         = bitmap;
1306         ),
1307 
1308         TP_printk_btrfs("block_group=%llu flags=%llu(%s) window_start=%llu "
1309                   "size=%llu max_size=%llu bitmap=%d",
1310                   __entry->bg_objectid,
1311                   __entry->flags,
1312                   __print_flags((unsigned long)__entry->flags, "|",
1313                                 BTRFS_GROUP_FLAGS), __entry->start,
1314                   __entry->size, __entry->max_size, __entry->bitmap)
1315 );
1316 
1317 struct extent_state;
1318 TRACE_EVENT(alloc_extent_state,
1319 
1320         TP_PROTO(const struct extent_state *state,
1321                  gfp_t mask, unsigned long IP),
1322 
1323         TP_ARGS(state, mask, IP),
1324 
1325         TP_STRUCT__entry(
1326                 __field(const struct extent_state *, state)
1327                 __field(gfp_t, mask)
1328                 __field(unsigned long, ip)
1329         ),
1330 
1331         TP_fast_assign(
1332                 __entry->state  = state,
1333                 __entry->mask   = mask,
1334                 __entry->ip     = IP
1335         ),
1336 
1337         TP_printk("state=%p mask=%s caller=%pS", __entry->state,
1338                   show_gfp_flags(__entry->mask), (const void *)__entry->ip)
1339 );
1340 
1341 TRACE_EVENT(free_extent_state,
1342 
1343         TP_PROTO(const struct extent_state *state, unsigned long IP),
1344 
1345         TP_ARGS(state, IP),
1346 
1347         TP_STRUCT__entry(
1348                 __field(const struct extent_state *, state)
1349                 __field(unsigned long, ip)
1350         ),
1351 
1352         TP_fast_assign(
1353                 __entry->state  = state,
1354                 __entry->ip = IP
1355         ),
1356 
1357         TP_printk("state=%p caller=%pS", __entry->state,
1358                   (const void *)__entry->ip)
1359 );
1360 
1361 DECLARE_EVENT_CLASS(btrfs__work,
1362 
1363         TP_PROTO(const struct btrfs_work *work),
1364 
1365         TP_ARGS(work),
1366 
1367         TP_STRUCT__entry_btrfs(
1368                 __field(        const void *,   work                    )
1369                 __field(        const void *,   wq                      )
1370                 __field(        const void *,   func                    )
1371                 __field(        const void *,   ordered_func            )
1372                 __field(        const void *,   ordered_free            )
1373                 __field(        const void *,   normal_work             )
1374         ),
1375 
1376         TP_fast_assign_btrfs(btrfs_work_owner(work),
1377                 __entry->work           = work;
1378                 __entry->wq             = work->wq;
1379                 __entry->func           = work->func;
1380                 __entry->ordered_func   = work->ordered_func;
1381                 __entry->ordered_free   = work->ordered_free;
1382                 __entry->normal_work    = &work->normal_work;
1383         ),
1384 
1385         TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%ps ordered_func=%p "
1386                   "ordered_free=%p",
1387                   __entry->work, __entry->normal_work, __entry->wq,
1388                    __entry->func, __entry->ordered_func, __entry->ordered_free)
1389 );
1390 
1391 /*
1392  * For situiations when the work is freed, we pass fs_info and a tag that that
1393  * matches address of the work structure so it can be paired with the
1394  * scheduling event.
1395  */
1396 DECLARE_EVENT_CLASS(btrfs__work__done,
1397 
1398         TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1399 
1400         TP_ARGS(fs_info, wtag),
1401 
1402         TP_STRUCT__entry_btrfs(
1403                 __field(        const void *,   wtag                    )
1404         ),
1405 
1406         TP_fast_assign_btrfs(fs_info,
1407                 __entry->wtag           = wtag;
1408         ),
1409 
1410         TP_printk_btrfs("work->%p", __entry->wtag)
1411 );
1412 
1413 DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1414 
1415         TP_PROTO(const struct btrfs_work *work),
1416 
1417         TP_ARGS(work)
1418 );
1419 
1420 DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1421 
1422         TP_PROTO(const struct btrfs_work *work),
1423 
1424         TP_ARGS(work)
1425 );
1426 
1427 DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1428 
1429         TP_PROTO(const struct btrfs_fs_info *fs_info, const void *wtag),
1430 
1431         TP_ARGS(fs_info, wtag)
1432 );
1433 
1434 DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1435 
1436         TP_PROTO(const struct btrfs_work *work),
1437 
1438         TP_ARGS(work)
1439 );
1440 
1441 DECLARE_EVENT_CLASS(btrfs__workqueue,
1442 
1443         TP_PROTO(const struct __btrfs_workqueue *wq,
1444                  const char *name, int high),
1445 
1446         TP_ARGS(wq, name, high),
1447 
1448         TP_STRUCT__entry_btrfs(
1449                 __field(        const void *,   wq                      )
1450                 __string(       name,   name                    )
1451                 __field(        int ,   high                    )
1452         ),
1453 
1454         TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1455                 __entry->wq             = wq;
1456                 __assign_str(name, name);
1457                 __entry->high           = high;
1458         ),
1459 
1460         TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1461                   __print_flags(__entry->high, "",
1462                                 {(WQ_HIGHPRI),  "-high"}),
1463                   __entry->wq)
1464 );
1465 
1466 DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1467 
1468         TP_PROTO(const struct __btrfs_workqueue *wq,
1469                  const char *name, int high),
1470 
1471         TP_ARGS(wq, name, high)
1472 );
1473 
1474 DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1475 
1476         TP_PROTO(const struct __btrfs_workqueue *wq),
1477 
1478         TP_ARGS(wq),
1479 
1480         TP_STRUCT__entry_btrfs(
1481                 __field(        const void *,   wq              )
1482         ),
1483 
1484         TP_fast_assign_btrfs(btrfs_workqueue_owner(wq),
1485                 __entry->wq             = wq;
1486         ),
1487 
1488         TP_printk_btrfs("wq=%p", __entry->wq)
1489 );
1490 
1491 DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1492 
1493         TP_PROTO(const struct __btrfs_workqueue *wq),
1494 
1495         TP_ARGS(wq)
1496 );
1497 
1498 #define BTRFS_QGROUP_OPERATIONS                         \
1499         { QGROUP_RESERVE,       "reserve"       },      \
1500         { QGROUP_RELEASE,       "release"       },      \
1501         { QGROUP_FREE,          "free"          }
1502 
1503 DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1504 
1505         TP_PROTO(const struct inode *inode, u64 start, u64 len,
1506                  u64 reserved, int op),
1507 
1508         TP_ARGS(inode, start, len, reserved, op),
1509 
1510         TP_STRUCT__entry_btrfs(
1511                 __field(        u64,            rootid          )
1512                 __field(        u64,            ino             )
1513                 __field(        u64,            start           )
1514                 __field(        u64,            len             )
1515                 __field(        u64,            reserved        )
1516                 __field(        int,            op              )
1517         ),
1518 
1519         TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
1520                 __entry->rootid         =
1521                         BTRFS_I(inode)->root->root_key.objectid;
1522                 __entry->ino            = btrfs_ino(BTRFS_I(inode));
1523                 __entry->start          = start;
1524                 __entry->len            = len;
1525                 __entry->reserved       = reserved;
1526                 __entry->op             = op;
1527         ),
1528 
1529         TP_printk_btrfs("root=%llu ino=%llu start=%llu len=%llu reserved=%llu op=%s",
1530                   __entry->rootid, __entry->ino, __entry->start, __entry->len,
1531                   __entry->reserved,
1532                   __print_flags((unsigned long)__entry->op, "",
1533                                 BTRFS_QGROUP_OPERATIONS)
1534         )
1535 );
1536 
1537 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1538 
1539         TP_PROTO(const struct inode *inode, u64 start, u64 len,
1540                  u64 reserved, int op),
1541 
1542         TP_ARGS(inode, start, len, reserved, op)
1543 );
1544 
1545 DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1546 
1547         TP_PROTO(const struct inode *inode, u64 start, u64 len,
1548                  u64 reserved, int op),
1549 
1550         TP_ARGS(inode, start, len, reserved, op)
1551 );
1552 
1553 DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1554         TP_PROTO(const struct btrfs_fs_info *fs_info,
1555                  const struct btrfs_qgroup_extent_record *rec),
1556 
1557         TP_ARGS(fs_info, rec),
1558 
1559         TP_STRUCT__entry_btrfs(
1560                 __field(        u64,  bytenr            )
1561                 __field(        u64,  num_bytes         )
1562         ),
1563 
1564         TP_fast_assign_btrfs(fs_info,
1565                 __entry->bytenr         = rec->bytenr,
1566                 __entry->num_bytes      = rec->num_bytes;
1567         ),
1568 
1569         TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
1570                   (unsigned long long)__entry->bytenr,
1571                   (unsigned long long)__entry->num_bytes)
1572 );
1573 
1574 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1575 
1576         TP_PROTO(const struct btrfs_fs_info *fs_info,
1577                  const struct btrfs_qgroup_extent_record *rec),
1578 
1579         TP_ARGS(fs_info, rec)
1580 );
1581 
1582 DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
1583 
1584         TP_PROTO(const struct btrfs_fs_info *fs_info,
1585                  const struct btrfs_qgroup_extent_record *rec),
1586 
1587         TP_ARGS(fs_info, rec)
1588 );
1589 
1590 TRACE_EVENT(qgroup_num_dirty_extents,
1591 
1592         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
1593                  u64 num_dirty_extents),
1594 
1595         TP_ARGS(fs_info, transid, num_dirty_extents),
1596 
1597         TP_STRUCT__entry_btrfs(
1598                 __field(        u64, transid                    )
1599                 __field(        u64, num_dirty_extents          )
1600         ),
1601 
1602         TP_fast_assign_btrfs(fs_info,
1603                 __entry->transid           = transid;
1604                 __entry->num_dirty_extents = num_dirty_extents;
1605         ),
1606 
1607         TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
1608                 __entry->transid, __entry->num_dirty_extents)
1609 );
1610 
1611 TRACE_EVENT(btrfs_qgroup_account_extent,
1612 
1613         TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,
1614                  u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
1615 
1616         TP_ARGS(fs_info, transid, bytenr, num_bytes, nr_old_roots,
1617                 nr_new_roots),
1618 
1619         TP_STRUCT__entry_btrfs(
1620                 __field(        u64,  transid                   )
1621                 __field(        u64,  bytenr                    )
1622                 __field(        u64,  num_bytes                 )
1623                 __field(        u64,  nr_old_roots              )
1624                 __field(        u64,  nr_new_roots              )
1625         ),
1626 
1627         TP_fast_assign_btrfs(fs_info,
1628                 __entry->transid        = transid;
1629                 __entry->bytenr         = bytenr;
1630                 __entry->num_bytes      = num_bytes;
1631                 __entry->nr_old_roots   = nr_old_roots;
1632                 __entry->nr_new_roots   = nr_new_roots;
1633         ),
1634 
1635         TP_printk_btrfs(
1636 "transid=%llu bytenr=%llu num_bytes=%llu nr_old_roots=%llu nr_new_roots=%llu",
1637                 __entry->transid,
1638                 __entry->bytenr,
1639                 __entry->num_bytes,
1640                 __entry->nr_old_roots,
1641                 __entry->nr_new_roots)
1642 );
1643 
1644 TRACE_EVENT(qgroup_update_counters,
1645 
1646         TP_PROTO(const struct btrfs_fs_info *fs_info,
1647                  struct btrfs_qgroup *qgroup,
1648                  u64 cur_old_count, u64 cur_new_count),
1649 
1650         TP_ARGS(fs_info, qgroup, cur_old_count, cur_new_count),
1651 
1652         TP_STRUCT__entry_btrfs(
1653                 __field(        u64,  qgid                      )
1654                 __field(        u64,  old_rfer                  )
1655                 __field(        u64,  old_excl                  )
1656                 __field(        u64,  cur_old_count             )
1657                 __field(        u64,  cur_new_count             )
1658         ),
1659 
1660         TP_fast_assign_btrfs(fs_info,
1661                 __entry->qgid           = qgroup->qgroupid;
1662                 __entry->old_rfer       = qgroup->rfer;
1663                 __entry->old_excl       = qgroup->excl;
1664                 __entry->cur_old_count  = cur_old_count;
1665                 __entry->cur_new_count  = cur_new_count;
1666         ),
1667 
1668         TP_printk_btrfs("qgid=%llu old_rfer=%llu old_excl=%llu cur_old_count=%llu cur_new_count=%llu",
1669                   __entry->qgid, __entry->old_rfer, __entry->old_excl,
1670                   __entry->cur_old_count, __entry->cur_new_count)
1671 );
1672 
1673 TRACE_EVENT(qgroup_update_reserve,
1674 
1675         TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup,
1676                  s64 diff, int type),
1677 
1678         TP_ARGS(fs_info, qgroup, diff, type),
1679 
1680         TP_STRUCT__entry_btrfs(
1681                 __field(        u64,    qgid                    )
1682                 __field(        u64,    cur_reserved            )
1683                 __field(        s64,    diff                    )
1684                 __field(        int,    type                    )
1685         ),
1686 
1687         TP_fast_assign_btrfs(fs_info,
1688                 __entry->qgid           = qgroup->qgroupid;
1689                 __entry->cur_reserved   = qgroup->rsv.values[type];
1690                 __entry->diff           = diff;
1691                 __entry->type           = type;
1692         ),
1693 
1694         TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
1695                 __entry->qgid, show_qgroup_rsv_type(__entry->type),
1696                 __entry->cur_reserved, __entry->diff)
1697 );
1698 
1699 TRACE_EVENT(qgroup_meta_reserve,
1700 
1701         TP_PROTO(struct btrfs_root *root, s64 diff, int type),
1702 
1703         TP_ARGS(root, diff, type),
1704 
1705         TP_STRUCT__entry_btrfs(
1706                 __field(        u64,    refroot                 )
1707                 __field(        s64,    diff                    )
1708                 __field(        int,    type                    )
1709         ),
1710 
1711         TP_fast_assign_btrfs(root->fs_info,
1712                 __entry->refroot        = root->root_key.objectid;
1713                 __entry->diff           = diff;
1714                 __entry->type           = type;
1715         ),
1716 
1717         TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1718                 show_root_type(__entry->refroot),
1719                 show_qgroup_rsv_type(__entry->type), __entry->diff)
1720 );
1721 
1722 TRACE_EVENT(qgroup_meta_convert,
1723 
1724         TP_PROTO(struct btrfs_root *root, s64 diff),
1725 
1726         TP_ARGS(root, diff),
1727 
1728         TP_STRUCT__entry_btrfs(
1729                 __field(        u64,    refroot                 )
1730                 __field(        s64,    diff                    )
1731         ),
1732 
1733         TP_fast_assign_btrfs(root->fs_info,
1734                 __entry->refroot        = root->root_key.objectid;
1735                 __entry->diff           = diff;
1736         ),
1737 
1738         TP_printk_btrfs("refroot=%llu(%s) type=%s->%s diff=%lld",
1739                 show_root_type(__entry->refroot),
1740                 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PREALLOC),
1741                 show_qgroup_rsv_type(BTRFS_QGROUP_RSV_META_PERTRANS),
1742                 __entry->diff)
1743 );
1744 
1745 TRACE_EVENT(qgroup_meta_free_all_pertrans,
1746 
1747         TP_PROTO(struct btrfs_root *root),
1748 
1749         TP_ARGS(root),
1750 
1751         TP_STRUCT__entry_btrfs(
1752                 __field(        u64,    refroot                 )
1753                 __field(        s64,    diff                    )
1754                 __field(        int,    type                    )
1755         ),
1756 
1757         TP_fast_assign_btrfs(root->fs_info,
1758                 __entry->refroot        = root->root_key.objectid;
1759                 spin_lock(&root->qgroup_meta_rsv_lock);
1760                 __entry->diff           = -(s64)root->qgroup_meta_rsv_pertrans;
1761                 spin_unlock(&root->qgroup_meta_rsv_lock);
1762                 __entry->type           = BTRFS_QGROUP_RSV_META_PERTRANS;
1763         ),
1764 
1765         TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
1766                 show_root_type(__entry->refroot),
1767                 show_qgroup_rsv_type(__entry->type), __entry->diff)
1768 );
1769 
1770 DECLARE_EVENT_CLASS(btrfs__prelim_ref,
1771         TP_PROTO(const struct btrfs_fs_info *fs_info,
1772                  const struct prelim_ref *oldref,
1773                  const struct prelim_ref *newref, u64 tree_size),
1774         TP_ARGS(fs_info, newref, oldref, tree_size),
1775 
1776         TP_STRUCT__entry_btrfs(
1777                 __field(        u64,  root_id           )
1778                 __field(        u64,  objectid          )
1779                 __field(         u8,  type              )
1780                 __field(        u64,  offset            )
1781                 __field(        int,  level             )
1782                 __field(        int,  old_count         )
1783                 __field(        u64,  parent            )
1784                 __field(        u64,  bytenr            )
1785                 __field(        int,  mod_count         )
1786                 __field(        u64,  tree_size         )
1787         ),
1788 
1789         TP_fast_assign_btrfs(fs_info,
1790                 __entry->root_id        = oldref->root_id;
1791                 __entry->objectid       = oldref->key_for_search.objectid;
1792                 __entry->type           = oldref->key_for_search.type;
1793                 __entry->offset         = oldref->key_for_search.offset;
1794                 __entry->level          = oldref->level;
1795                 __entry->old_count      = oldref->count;
1796                 __entry->parent         = oldref->parent;
1797                 __entry->bytenr         = oldref->wanted_disk_byte;
1798                 __entry->mod_count      = newref ? newref->count : 0;
1799                 __entry->tree_size      = tree_size;
1800         ),
1801 
1802         TP_printk_btrfs("root_id=%llu key=[%llu,%u,%llu] level=%d count=[%d+%d=%d] parent=%llu wanted_disk_byte=%llu nodes=%llu",
1803                         __entry->root_id,
1804                         __entry->objectid, __entry->type,
1805                         __entry->offset, __entry->level,
1806                         __entry->old_count, __entry->mod_count,
1807                         __entry->old_count + __entry->mod_count,
1808                         __entry->parent,
1809                         __entry->bytenr,
1810                         __entry->tree_size)
1811 );
1812 
1813 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_merge,
1814         TP_PROTO(const struct btrfs_fs_info *fs_info,
1815                  const struct prelim_ref *oldref,
1816                  const struct prelim_ref *newref, u64 tree_size),
1817         TP_ARGS(fs_info, oldref, newref, tree_size)
1818 );
1819 
1820 DEFINE_EVENT(btrfs__prelim_ref, btrfs_prelim_ref_insert,
1821         TP_PROTO(const struct btrfs_fs_info *fs_info,
1822                  const struct prelim_ref *oldref,
1823                  const struct prelim_ref *newref, u64 tree_size),
1824         TP_ARGS(fs_info, oldref, newref, tree_size)
1825 );
1826 
1827 TRACE_EVENT(btrfs_inode_mod_outstanding_extents,
1828         TP_PROTO(struct btrfs_root *root, u64 ino, int mod),
1829 
1830         TP_ARGS(root, ino, mod),
1831 
1832         TP_STRUCT__entry_btrfs(
1833                 __field(        u64, root_objectid      )
1834                 __field(        u64, ino                )
1835                 __field(        int, mod                )
1836         ),
1837 
1838         TP_fast_assign_btrfs(root->fs_info,
1839                 __entry->root_objectid  = root->root_key.objectid;
1840                 __entry->ino            = ino;
1841                 __entry->mod            = mod;
1842         ),
1843 
1844         TP_printk_btrfs("root=%llu(%s) ino=%llu mod=%d",
1845                         show_root_type(__entry->root_objectid),
1846                         __entry->ino, __entry->mod)
1847 );
1848 
1849 DECLARE_EVENT_CLASS(btrfs__block_group,
1850         TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
1851 
1852         TP_ARGS(bg_cache),
1853 
1854         TP_STRUCT__entry_btrfs(
1855                 __field(        u64,    bytenr          )
1856                 __field(        u64,    len             )
1857                 __field(        u64,    used            )
1858                 __field(        u64,    flags           )
1859         ),
1860 
1861         TP_fast_assign_btrfs(bg_cache->fs_info,
1862                 __entry->bytenr = bg_cache->key.objectid,
1863                 __entry->len    = bg_cache->key.offset,
1864                 __entry->used   = btrfs_block_group_used(&bg_cache->item);
1865                 __entry->flags  = bg_cache->flags;
1866         ),
1867 
1868         TP_printk_btrfs("bg bytenr=%llu len=%llu used=%llu flags=%llu(%s)",
1869                 __entry->bytenr, __entry->len, __entry->used, __entry->flags,
1870                 __print_flags(__entry->flags, "|", BTRFS_GROUP_FLAGS))
1871 );
1872 
1873 DEFINE_EVENT(btrfs__block_group, btrfs_remove_block_group,
1874         TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
1875 
1876         TP_ARGS(bg_cache)
1877 );
1878 
1879 DEFINE_EVENT(btrfs__block_group, btrfs_add_unused_block_group,
1880         TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
1881 
1882         TP_ARGS(bg_cache)
1883 );
1884 
1885 DEFINE_EVENT(btrfs__block_group, btrfs_skip_unused_block_group,
1886         TP_PROTO(const struct btrfs_block_group_cache *bg_cache),
1887 
1888         TP_ARGS(bg_cache)
1889 );
1890 
1891 TRACE_EVENT(btrfs_set_extent_bit,
1892         TP_PROTO(const struct extent_io_tree *tree,
1893                  u64 start, u64 len, unsigned set_bits),
1894 
1895         TP_ARGS(tree, start, len, set_bits),
1896 
1897         TP_STRUCT__entry_btrfs(
1898                 __field(        unsigned,       owner   )
1899                 __field(        u64,            ino     )
1900                 __field(        u64,            rootid  )
1901                 __field(        u64,            start   )
1902                 __field(        u64,            len     )
1903                 __field(        unsigned,       set_bits)
1904         ),
1905 
1906         TP_fast_assign_btrfs(tree->fs_info,
1907                 __entry->owner = tree->owner;
1908                 if (tree->private_data) {
1909                         struct inode *inode = tree->private_data;
1910 
1911                         __entry->ino    = btrfs_ino(BTRFS_I(inode));
1912                         __entry->rootid =
1913                                 BTRFS_I(inode)->root->root_key.objectid;
1914                 } else {
1915                         __entry->ino    = 0;
1916                         __entry->rootid = 0;
1917                 }
1918                 __entry->start          = start;
1919                 __entry->len            = len;
1920                 __entry->set_bits       = set_bits;
1921         ),
1922 
1923         TP_printk_btrfs(
1924                 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s",
1925                 show_extent_io_tree_owner(__entry->owner), __entry->ino,
1926                 __entry->rootid, __entry->start, __entry->len,
1927                 __print_flags(__entry->set_bits, "|", EXTENT_FLAGS))
1928 );
1929 
1930 TRACE_EVENT(btrfs_clear_extent_bit,
1931         TP_PROTO(const struct extent_io_tree *tree,
1932                  u64 start, u64 len, unsigned clear_bits),
1933 
1934         TP_ARGS(tree, start, len, clear_bits),
1935 
1936         TP_STRUCT__entry_btrfs(
1937                 __field(        unsigned,       owner   )
1938                 __field(        u64,            ino     )
1939                 __field(        u64,            rootid  )
1940                 __field(        u64,            start   )
1941                 __field(        u64,            len     )
1942                 __field(        unsigned,       clear_bits)
1943         ),
1944 
1945         TP_fast_assign_btrfs(tree->fs_info,
1946                 __entry->owner = tree->owner;
1947                 if (tree->private_data) {
1948                         struct inode *inode = tree->private_data;
1949 
1950                         __entry->ino    = btrfs_ino(BTRFS_I(inode));
1951                         __entry->rootid =
1952                                 BTRFS_I(inode)->root->root_key.objectid;
1953                 } else {
1954                         __entry->ino    = 0;
1955                         __entry->rootid = 0;
1956                 }
1957                 __entry->start          = start;
1958                 __entry->len            = len;
1959                 __entry->clear_bits     = clear_bits;
1960         ),
1961 
1962         TP_printk_btrfs(
1963                 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu clear_bits=%s",
1964                 show_extent_io_tree_owner(__entry->owner), __entry->ino,
1965                 __entry->rootid, __entry->start, __entry->len,
1966                 __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
1967 );
1968 
1969 TRACE_EVENT(btrfs_convert_extent_bit,
1970         TP_PROTO(const struct extent_io_tree *tree,
1971                  u64 start, u64 len, unsigned set_bits, unsigned clear_bits),
1972 
1973         TP_ARGS(tree, start, len, set_bits, clear_bits),
1974 
1975         TP_STRUCT__entry_btrfs(
1976                 __field(        unsigned,       owner   )
1977                 __field(        u64,            ino     )
1978                 __field(        u64,            rootid  )
1979                 __field(        u64,            start   )
1980                 __field(        u64,            len     )
1981                 __field(        unsigned,       set_bits)
1982                 __field(        unsigned,       clear_bits)
1983         ),
1984 
1985         TP_fast_assign_btrfs(tree->fs_info,
1986                 __entry->owner = tree->owner;
1987                 if (tree->private_data) {
1988                         struct inode *inode = tree->private_data;
1989 
1990                         __entry->ino    = btrfs_ino(BTRFS_I(inode));
1991                         __entry->rootid =
1992                                 BTRFS_I(inode)->root->root_key.objectid;
1993                 } else {
1994                         __entry->ino    = 0;
1995                         __entry->rootid = 0;
1996                 }
1997                 __entry->start          = start;
1998                 __entry->len            = len;
1999                 __entry->set_bits       = set_bits;
2000                 __entry->clear_bits     = clear_bits;
2001         ),
2002 
2003         TP_printk_btrfs(
2004 "io_tree=%s ino=%llu root=%llu start=%llu len=%llu set_bits=%s clear_bits=%s",
2005                   show_extent_io_tree_owner(__entry->owner), __entry->ino,
2006                   __entry->rootid, __entry->start, __entry->len,
2007                   __print_flags(__entry->set_bits , "|", EXTENT_FLAGS),
2008                   __print_flags(__entry->clear_bits, "|", EXTENT_FLAGS))
2009 );
2010 
2011 DECLARE_EVENT_CLASS(btrfs_sleep_tree_lock,
2012         TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2013 
2014         TP_ARGS(eb, start_ns),
2015 
2016         TP_STRUCT__entry_btrfs(
2017                 __field(        u64,    block           )
2018                 __field(        u64,    generation      )
2019                 __field(        u64,    start_ns        )
2020                 __field(        u64,    end_ns          )
2021                 __field(        u64,    diff_ns         )
2022                 __field(        u64,    owner           )
2023                 __field(        int,    is_log_tree     )
2024         ),
2025 
2026         TP_fast_assign_btrfs(eb->fs_info,
2027                 __entry->block          = eb->start;
2028                 __entry->generation     = btrfs_header_generation(eb);
2029                 __entry->start_ns       = start_ns;
2030                 __entry->end_ns         = ktime_get_ns();
2031                 __entry->diff_ns        = __entry->end_ns - start_ns;
2032                 __entry->owner          = btrfs_header_owner(eb);
2033                 __entry->is_log_tree    = (eb->log_index >= 0);
2034         ),
2035 
2036         TP_printk_btrfs(
2037 "block=%llu generation=%llu start_ns=%llu end_ns=%llu diff_ns=%llu owner=%llu is_log_tree=%d",
2038                 __entry->block, __entry->generation,
2039                 __entry->start_ns, __entry->end_ns, __entry->diff_ns,
2040                 __entry->owner, __entry->is_log_tree)
2041 );
2042 
2043 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_read_lock,
2044         TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2045 
2046         TP_ARGS(eb, start_ns)
2047 );
2048 
2049 DEFINE_EVENT(btrfs_sleep_tree_lock, btrfs_tree_lock,
2050         TP_PROTO(const struct extent_buffer *eb, u64 start_ns),
2051 
2052         TP_ARGS(eb, start_ns)
2053 );
2054 
2055 DECLARE_EVENT_CLASS(btrfs_locking_events,
2056         TP_PROTO(const struct extent_buffer *eb),
2057 
2058         TP_ARGS(eb),
2059 
2060         TP_STRUCT__entry_btrfs(
2061                 __field(        u64,    block           )
2062                 __field(        u64,    generation      )
2063                 __field(        u64,    owner           )
2064                 __field(        int,    is_log_tree     )
2065         ),
2066 
2067         TP_fast_assign_btrfs(eb->fs_info,
2068                 __entry->block          = eb->start;
2069                 __entry->generation     = btrfs_header_generation(eb);
2070                 __entry->owner          = btrfs_header_owner(eb);
2071                 __entry->is_log_tree    = (eb->log_index >= 0);
2072         ),
2073 
2074         TP_printk_btrfs("block=%llu generation=%llu owner=%llu is_log_tree=%d",
2075                 __entry->block, __entry->generation,
2076                 __entry->owner, __entry->is_log_tree)
2077 );
2078 
2079 #define DEFINE_BTRFS_LOCK_EVENT(name)                           \
2080 DEFINE_EVENT(btrfs_locking_events, name,                        \
2081                 TP_PROTO(const struct extent_buffer *eb),       \
2082                                                                 \
2083                 TP_ARGS(eb)                                     \
2084 )
2085 
2086 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_unlock);
2087 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock);
2088 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_unlock_blocking);
2089 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_read);
2090 DEFINE_BTRFS_LOCK_EVENT(btrfs_set_lock_blocking_write);
2091 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_read_lock);
2092 DEFINE_BTRFS_LOCK_EVENT(btrfs_try_tree_write_lock);
2093 DEFINE_BTRFS_LOCK_EVENT(btrfs_tree_read_lock_atomic);
2094 
2095 DECLARE_EVENT_CLASS(btrfs__space_info_update,
2096 
2097         TP_PROTO(struct btrfs_fs_info *fs_info,
2098                  struct btrfs_space_info *sinfo, u64 old, s64 diff),
2099 
2100         TP_ARGS(fs_info, sinfo, old, diff),
2101 
2102         TP_STRUCT__entry_btrfs(
2103                 __field(        u64,    type            )
2104                 __field(        u64,    old             )
2105                 __field(        s64,    diff            )
2106         ),
2107 
2108         TP_fast_assign_btrfs(fs_info,
2109                 __entry->type   = sinfo->flags;
2110                 __entry->old    = old;
2111                 __entry->diff   = diff;
2112         ),
2113         TP_printk_btrfs("type=%s old=%llu diff=%lld",
2114                 __print_flags(__entry->type, "|", BTRFS_GROUP_FLAGS),
2115                 __entry->old, __entry->diff)
2116 );
2117 
2118 DEFINE_EVENT(btrfs__space_info_update, update_bytes_may_use,
2119 
2120         TP_PROTO(struct btrfs_fs_info *fs_info,
2121                  struct btrfs_space_info *sinfo, u64 old, s64 diff),
2122 
2123         TP_ARGS(fs_info, sinfo, old, diff)
2124 );
2125 
2126 DEFINE_EVENT(btrfs__space_info_update, update_bytes_pinned,
2127 
2128         TP_PROTO(struct btrfs_fs_info *fs_info,
2129                  struct btrfs_space_info *sinfo, u64 old, s64 diff),
2130 
2131         TP_ARGS(fs_info, sinfo, old, diff)
2132 );
2133 
2134 #endif /* _TRACE_BTRFS_H */
2135 
2136 /* This part must be outside protection */
2137 #include <trace/define_trace.h>

/* [<][>][^][v][top][bottom][index][help] */