linux/include/trace/events/btrfs.h
<<
>>
Prefs
   1#undef TRACE_SYSTEM
   2#define TRACE_SYSTEM btrfs
   3
   4#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
   5#define _TRACE_BTRFS_H
   6
   7#include <linux/writeback.h>
   8#include <linux/tracepoint.h>
   9#include <trace/events/mmflags.h>
  10
  11struct btrfs_root;
  12struct btrfs_fs_info;
  13struct btrfs_inode;
  14struct extent_map;
  15struct btrfs_ordered_extent;
  16struct btrfs_delayed_ref_node;
  17struct btrfs_delayed_tree_ref;
  18struct btrfs_delayed_data_ref;
  19struct btrfs_delayed_ref_head;
  20struct btrfs_block_group_cache;
  21struct btrfs_free_cluster;
  22struct map_lookup;
  23struct extent_buffer;
  24struct btrfs_work;
  25struct __btrfs_workqueue;
  26struct btrfs_qgroup_extent_record;
  27
  28#define show_ref_type(type)                                             \
  29        __print_symbolic(type,                                          \
  30                { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
  31                { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
  32                { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
  33                { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
  34                { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
  35
  36#define __show_root_type(obj)                                           \
  37        __print_symbolic_u64(obj,                                       \
  38                { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
  39                { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
  40                { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
  41                { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
  42                { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
  43                { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
  44                { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
  45                { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
  46                { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
  47                { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
  48                { BTRFS_UUID_TREE_OBJECTID,     "UUID_TREE"     },      \
  49                { BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },  \
  50                { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
  51
  52#define show_root_type(obj)                                             \
  53        obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
  54              (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
  55               obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
  56
  57#define BTRFS_GROUP_FLAGS       \
  58        { BTRFS_BLOCK_GROUP_DATA,       "DATA"},        \
  59        { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
  60        { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
  61        { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"},       \
  62        { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"},       \
  63        { BTRFS_BLOCK_GROUP_DUP,        "DUP"},         \
  64        { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
  65        { BTRFS_BLOCK_GROUP_RAID5,      "RAID5"},       \
  66        { BTRFS_BLOCK_GROUP_RAID6,      "RAID6"}
  67
  68#define BTRFS_UUID_SIZE 16
  69
  70TRACE_EVENT(btrfs_transaction_commit,
  71
  72        TP_PROTO(struct btrfs_root *root),
  73
  74        TP_ARGS(root),
  75
  76        TP_STRUCT__entry(
  77                __field(        u64,  generation                )
  78                __field(        u64,  root_objectid             )
  79        ),
  80
  81        TP_fast_assign(
  82                __entry->generation     = root->fs_info->generation;
  83                __entry->root_objectid  = root->root_key.objectid;
  84        ),
  85
  86        TP_printk("root = %llu(%s), gen = %llu",
  87                  show_root_type(__entry->root_objectid),
  88                  (unsigned long long)__entry->generation)
  89);
  90
  91DECLARE_EVENT_CLASS(btrfs__inode,
  92
  93        TP_PROTO(struct inode *inode),
  94
  95        TP_ARGS(inode),
  96
  97        TP_STRUCT__entry(
  98                __field(        ino_t,  ino                     )
  99                __field(        blkcnt_t,  blocks               )
 100                __field(        u64,  disk_i_size               )
 101                __field(        u64,  generation                )
 102                __field(        u64,  last_trans                )
 103                __field(        u64,  logged_trans              )
 104                __field(        u64,  root_objectid             )
 105        ),
 106
 107        TP_fast_assign(
 108                __entry->ino    = inode->i_ino;
 109                __entry->blocks = inode->i_blocks;
 110                __entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
 111                __entry->generation = BTRFS_I(inode)->generation;
 112                __entry->last_trans = BTRFS_I(inode)->last_trans;
 113                __entry->logged_trans = BTRFS_I(inode)->logged_trans;
 114                __entry->root_objectid =
 115                                BTRFS_I(inode)->root->root_key.objectid;
 116        ),
 117
 118        TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
 119                  "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
 120                  show_root_type(__entry->root_objectid),
 121                  (unsigned long long)__entry->generation,
 122                  (unsigned long)__entry->ino,
 123                  (unsigned long long)__entry->blocks,
 124                  (unsigned long long)__entry->disk_i_size,
 125                  (unsigned long long)__entry->last_trans,
 126                  (unsigned long long)__entry->logged_trans)
 127);
 128
 129DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
 130
 131        TP_PROTO(struct inode *inode),
 132
 133        TP_ARGS(inode)
 134);
 135
 136DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
 137
 138        TP_PROTO(struct inode *inode),
 139
 140        TP_ARGS(inode)
 141);
 142
 143DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
 144
 145        TP_PROTO(struct inode *inode),
 146
 147        TP_ARGS(inode)
 148);
 149
 150#define __show_map_type(type)                                           \
 151        __print_symbolic_u64(type,                                      \
 152                { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
 153                { EXTENT_MAP_HOLE,      "HOLE"          },              \
 154                { EXTENT_MAP_INLINE,    "INLINE"        },              \
 155                { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
 156
 157#define show_map_type(type)                     \
 158        type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
 159
 160#define show_map_flags(flag)                                            \
 161        __print_flags(flag, "|",                                        \
 162                { (1 << EXTENT_FLAG_PINNED),            "PINNED"        },\
 163                { (1 << EXTENT_FLAG_COMPRESSED),        "COMPRESSED"    },\
 164                { (1 << EXTENT_FLAG_VACANCY),           "VACANCY"       },\
 165                { (1 << EXTENT_FLAG_PREALLOC),          "PREALLOC"      },\
 166                { (1 << EXTENT_FLAG_LOGGING),           "LOGGING"       },\
 167                { (1 << EXTENT_FLAG_FILLING),           "FILLING"       },\
 168                { (1 << EXTENT_FLAG_FS_MAPPING),        "FS_MAPPING"    })
 169
 170TRACE_EVENT_CONDITION(btrfs_get_extent,
 171
 172        TP_PROTO(struct btrfs_root *root, struct extent_map *map),
 173
 174        TP_ARGS(root, map),
 175
 176        TP_CONDITION(map),
 177
 178        TP_STRUCT__entry(
 179                __field(        u64,  root_objectid     )
 180                __field(        u64,  start             )
 181                __field(        u64,  len               )
 182                __field(        u64,  orig_start        )
 183                __field(        u64,  block_start       )
 184                __field(        u64,  block_len         )
 185                __field(        unsigned long,  flags   )
 186                __field(        int,  refs              )
 187                __field(        unsigned int,  compress_type    )
 188        ),
 189
 190        TP_fast_assign(
 191                __entry->root_objectid  = root->root_key.objectid;
 192                __entry->start          = map->start;
 193                __entry->len            = map->len;
 194                __entry->orig_start     = map->orig_start;
 195                __entry->block_start    = map->block_start;
 196                __entry->block_len      = map->block_len;
 197                __entry->flags          = map->flags;
 198                __entry->refs           = atomic_read(&map->refs);
 199                __entry->compress_type  = map->compress_type;
 200        ),
 201
 202        TP_printk("root = %llu(%s), start = %llu, len = %llu, "
 203                  "orig_start = %llu, block_start = %llu(%s), "
 204                  "block_len = %llu, flags = %s, refs = %u, "
 205                  "compress_type = %u",
 206                  show_root_type(__entry->root_objectid),
 207                  (unsigned long long)__entry->start,
 208                  (unsigned long long)__entry->len,
 209                  (unsigned long long)__entry->orig_start,
 210                  show_map_type(__entry->block_start),
 211                  (unsigned long long)__entry->block_len,
 212                  show_map_flags(__entry->flags),
 213                  __entry->refs, __entry->compress_type)
 214);
 215
 216#define show_ordered_flags(flags)                                          \
 217        __print_flags(flags, "|",                                          \
 218                { (1 << BTRFS_ORDERED_IO_DONE),         "IO_DONE"       }, \
 219                { (1 << BTRFS_ORDERED_COMPLETE),        "COMPLETE"      }, \
 220                { (1 << BTRFS_ORDERED_NOCOW),           "NOCOW"         }, \
 221                { (1 << BTRFS_ORDERED_COMPRESSED),      "COMPRESSED"    }, \
 222                { (1 << BTRFS_ORDERED_PREALLOC),        "PREALLOC"      }, \
 223                { (1 << BTRFS_ORDERED_DIRECT),          "DIRECT"        }, \
 224                { (1 << BTRFS_ORDERED_IOERR),           "IOERR"         }, \
 225                { (1 << BTRFS_ORDERED_UPDATED_ISIZE),   "UPDATED_ISIZE" }, \
 226                { (1 << BTRFS_ORDERED_LOGGED_CSUM),     "LOGGED_CSUM"   }, \
 227                { (1 << BTRFS_ORDERED_TRUNCATED),       "TRUNCATED"     })
 228
 229
 230DECLARE_EVENT_CLASS(btrfs__ordered_extent,
 231
 232        TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
 233
 234        TP_ARGS(inode, ordered),
 235
 236        TP_STRUCT__entry(
 237                __field(        ino_t,  ino             )
 238                __field(        u64,  file_offset       )
 239                __field(        u64,  start             )
 240                __field(        u64,  len               )
 241                __field(        u64,  disk_len          )
 242                __field(        u64,  bytes_left        )
 243                __field(        unsigned long,  flags   )
 244                __field(        int,  compress_type     )
 245                __field(        int,  refs              )
 246                __field(        u64,  root_objectid     )
 247        ),
 248
 249        TP_fast_assign(
 250                __entry->ino            = inode->i_ino;
 251                __entry->file_offset    = ordered->file_offset;
 252                __entry->start          = ordered->start;
 253                __entry->len            = ordered->len;
 254                __entry->disk_len       = ordered->disk_len;
 255                __entry->bytes_left     = ordered->bytes_left;
 256                __entry->flags          = ordered->flags;
 257                __entry->compress_type  = ordered->compress_type;
 258                __entry->refs           = atomic_read(&ordered->refs);
 259                __entry->root_objectid  =
 260                                BTRFS_I(inode)->root->root_key.objectid;
 261        ),
 262
 263        TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
 264                  "start = %llu, len = %llu, disk_len = %llu, "
 265                  "bytes_left = %llu, flags = %s, compress_type = %d, "
 266                  "refs = %d",
 267                  show_root_type(__entry->root_objectid),
 268                  (unsigned long long)__entry->ino,
 269                  (unsigned long long)__entry->file_offset,
 270                  (unsigned long long)__entry->start,
 271                  (unsigned long long)__entry->len,
 272                  (unsigned long long)__entry->disk_len,
 273                  (unsigned long long)__entry->bytes_left,
 274                  show_ordered_flags(__entry->flags),
 275                  __entry->compress_type, __entry->refs)
 276);
 277
 278DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
 279
 280        TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
 281
 282        TP_ARGS(inode, ordered)
 283);
 284
 285DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
 286
 287        TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
 288
 289        TP_ARGS(inode, ordered)
 290);
 291
 292DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
 293
 294        TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
 295
 296        TP_ARGS(inode, ordered)
 297);
 298
 299DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
 300
 301        TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
 302
 303        TP_ARGS(inode, ordered)
 304);
 305
 306DECLARE_EVENT_CLASS(btrfs__writepage,
 307
 308        TP_PROTO(struct page *page, struct inode *inode,
 309                 struct writeback_control *wbc),
 310
 311        TP_ARGS(page, inode, wbc),
 312
 313        TP_STRUCT__entry(
 314                __field(        ino_t,  ino                     )
 315                __field(        pgoff_t,  index                 )
 316                __field(        long,   nr_to_write             )
 317                __field(        long,   pages_skipped           )
 318                __field(        loff_t, range_start             )
 319                __field(        loff_t, range_end               )
 320                __field(        char,   for_kupdate             )
 321                __field(        char,   for_reclaim             )
 322                __field(        char,   range_cyclic            )
 323                __field(        pgoff_t,  writeback_index       )
 324                __field(        u64,    root_objectid           )
 325        ),
 326
 327        TP_fast_assign(
 328                __entry->ino            = inode->i_ino;
 329                __entry->index          = page->index;
 330                __entry->nr_to_write    = wbc->nr_to_write;
 331                __entry->pages_skipped  = wbc->pages_skipped;
 332                __entry->range_start    = wbc->range_start;
 333                __entry->range_end      = wbc->range_end;
 334                __entry->for_kupdate    = wbc->for_kupdate;
 335                __entry->for_reclaim    = wbc->for_reclaim;
 336                __entry->range_cyclic   = wbc->range_cyclic;
 337                __entry->writeback_index = inode->i_mapping->writeback_index;
 338                __entry->root_objectid  =
 339                                 BTRFS_I(inode)->root->root_key.objectid;
 340        ),
 341
 342        TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
 343                  "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
 344                  "range_end = %llu, for_kupdate = %d, "
 345                  "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
 346                  show_root_type(__entry->root_objectid),
 347                  (unsigned long)__entry->ino, __entry->index,
 348                  __entry->nr_to_write, __entry->pages_skipped,
 349                  __entry->range_start, __entry->range_end,
 350                  __entry->for_kupdate,
 351                  __entry->for_reclaim, __entry->range_cyclic,
 352                  (unsigned long)__entry->writeback_index)
 353);
 354
 355DEFINE_EVENT(btrfs__writepage, __extent_writepage,
 356
 357        TP_PROTO(struct page *page, struct inode *inode,
 358                 struct writeback_control *wbc),
 359
 360        TP_ARGS(page, inode, wbc)
 361);
 362
 363TRACE_EVENT(btrfs_writepage_end_io_hook,
 364
 365        TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
 366
 367        TP_ARGS(page, start, end, uptodate),
 368
 369        TP_STRUCT__entry(
 370                __field(        ino_t,   ino            )
 371                __field(        pgoff_t, index          )
 372                __field(        u64,     start          )
 373                __field(        u64,     end            )
 374                __field(        int,     uptodate       )
 375                __field(        u64,    root_objectid   )
 376        ),
 377
 378        TP_fast_assign(
 379                __entry->ino    = page->mapping->host->i_ino;
 380                __entry->index  = page->index;
 381                __entry->start  = start;
 382                __entry->end    = end;
 383                __entry->uptodate = uptodate;
 384                __entry->root_objectid  =
 385                         BTRFS_I(page->mapping->host)->root->root_key.objectid;
 386        ),
 387
 388        TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
 389                  "end = %llu, uptodate = %d",
 390                  show_root_type(__entry->root_objectid),
 391                  (unsigned long)__entry->ino, (unsigned long)__entry->index,
 392                  (unsigned long long)__entry->start,
 393                  (unsigned long long)__entry->end, __entry->uptodate)
 394);
 395
 396TRACE_EVENT(btrfs_sync_file,
 397
 398        TP_PROTO(struct file *file, int datasync),
 399
 400        TP_ARGS(file, datasync),
 401
 402        TP_STRUCT__entry(
 403                __field(        ino_t,  ino             )
 404                __field(        ino_t,  parent          )
 405                __field(        int,    datasync        )
 406                __field(        u64,    root_objectid   )
 407        ),
 408
 409        TP_fast_assign(
 410                struct dentry *dentry = file->f_path.dentry;
 411                struct inode *inode = d_inode(dentry);
 412
 413                __entry->ino            = inode->i_ino;
 414                __entry->parent         = d_inode(dentry->d_parent)->i_ino;
 415                __entry->datasync       = datasync;
 416                __entry->root_objectid  =
 417                                 BTRFS_I(inode)->root->root_key.objectid;
 418        ),
 419
 420        TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
 421                  show_root_type(__entry->root_objectid),
 422                  (unsigned long)__entry->ino, (unsigned long)__entry->parent,
 423                  __entry->datasync)
 424);
 425
 426TRACE_EVENT(btrfs_sync_fs,
 427
 428        TP_PROTO(int wait),
 429
 430        TP_ARGS(wait),
 431
 432        TP_STRUCT__entry(
 433                __field(        int,  wait              )
 434        ),
 435
 436        TP_fast_assign(
 437                __entry->wait   = wait;
 438        ),
 439
 440        TP_printk("wait = %d", __entry->wait)
 441);
 442
 443#define show_ref_action(action)                                         \
 444        __print_symbolic(action,                                        \
 445                { BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },        \
 446                { BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },       \
 447                { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" },     \
 448                { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
 449                        
 450
 451DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
 452
 453        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 454                 struct btrfs_delayed_tree_ref *full_ref,
 455                 int action),
 456
 457        TP_ARGS(ref, full_ref, action),
 458
 459        TP_STRUCT__entry(
 460                __field(        u64,  bytenr            )
 461                __field(        u64,  num_bytes         )
 462                __field(        int,  action            ) 
 463                __field(        u64,  parent            )
 464                __field(        u64,  ref_root          )
 465                __field(        int,  level             )
 466                __field(        int,  type              )
 467                __field(        u64,  seq               )
 468        ),
 469
 470        TP_fast_assign(
 471                __entry->bytenr         = ref->bytenr;
 472                __entry->num_bytes      = ref->num_bytes;
 473                __entry->action         = action;
 474                __entry->parent         = full_ref->parent;
 475                __entry->ref_root       = full_ref->root;
 476                __entry->level          = full_ref->level;
 477                __entry->type           = ref->type;
 478                __entry->seq            = ref->seq;
 479        ),
 480
 481        TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
 482                  "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
 483                  "type = %s, seq = %llu",
 484                  (unsigned long long)__entry->bytenr,
 485                  (unsigned long long)__entry->num_bytes,
 486                  show_ref_action(__entry->action),
 487                  show_root_type(__entry->parent),
 488                  show_root_type(__entry->ref_root),
 489                  __entry->level, show_ref_type(__entry->type),
 490                  (unsigned long long)__entry->seq)
 491);
 492
 493DEFINE_EVENT(btrfs_delayed_tree_ref,  add_delayed_tree_ref,
 494
 495        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 496                 struct btrfs_delayed_tree_ref *full_ref,
 497                 int action),
 498
 499        TP_ARGS(ref, full_ref, action)
 500);
 501
 502DEFINE_EVENT(btrfs_delayed_tree_ref,  run_delayed_tree_ref,
 503
 504        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 505                 struct btrfs_delayed_tree_ref *full_ref,
 506                 int action),
 507
 508        TP_ARGS(ref, full_ref, action)
 509);
 510
 511DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
 512
 513        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 514                 struct btrfs_delayed_data_ref *full_ref,
 515                 int action),
 516
 517        TP_ARGS(ref, full_ref, action),
 518
 519        TP_STRUCT__entry(
 520                __field(        u64,  bytenr            )
 521                __field(        u64,  num_bytes         )
 522                __field(        int,  action            ) 
 523                __field(        u64,  parent            )
 524                __field(        u64,  ref_root          )
 525                __field(        u64,  owner             )
 526                __field(        u64,  offset            )
 527                __field(        int,  type              )
 528                __field(        u64,  seq               )
 529        ),
 530
 531        TP_fast_assign(
 532                __entry->bytenr         = ref->bytenr;
 533                __entry->num_bytes      = ref->num_bytes;
 534                __entry->action         = action;
 535                __entry->parent         = full_ref->parent;
 536                __entry->ref_root       = full_ref->root;
 537                __entry->owner          = full_ref->objectid;
 538                __entry->offset         = full_ref->offset;
 539                __entry->type           = ref->type;
 540                __entry->seq            = ref->seq;
 541        ),
 542
 543        TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
 544                  "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
 545                  "offset = %llu, type = %s, seq = %llu",
 546                  (unsigned long long)__entry->bytenr,
 547                  (unsigned long long)__entry->num_bytes,
 548                  show_ref_action(__entry->action),
 549                  show_root_type(__entry->parent),
 550                  show_root_type(__entry->ref_root),
 551                  (unsigned long long)__entry->owner,
 552                  (unsigned long long)__entry->offset,
 553                  show_ref_type(__entry->type),
 554                  (unsigned long long)__entry->seq)
 555);
 556
 557DEFINE_EVENT(btrfs_delayed_data_ref,  add_delayed_data_ref,
 558
 559        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 560                 struct btrfs_delayed_data_ref *full_ref,
 561                 int action),
 562
 563        TP_ARGS(ref, full_ref, action)
 564);
 565
 566DEFINE_EVENT(btrfs_delayed_data_ref,  run_delayed_data_ref,
 567
 568        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 569                 struct btrfs_delayed_data_ref *full_ref,
 570                 int action),
 571
 572        TP_ARGS(ref, full_ref, action)
 573);
 574
 575DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
 576
 577        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 578                 struct btrfs_delayed_ref_head *head_ref,
 579                 int action),
 580
 581        TP_ARGS(ref, head_ref, action),
 582
 583        TP_STRUCT__entry(
 584                __field(        u64,  bytenr            )
 585                __field(        u64,  num_bytes         )
 586                __field(        int,  action            ) 
 587                __field(        int,  is_data           )
 588        ),
 589
 590        TP_fast_assign(
 591                __entry->bytenr         = ref->bytenr;
 592                __entry->num_bytes      = ref->num_bytes;
 593                __entry->action         = action;
 594                __entry->is_data        = head_ref->is_data;
 595        ),
 596
 597        TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
 598                  (unsigned long long)__entry->bytenr,
 599                  (unsigned long long)__entry->num_bytes,
 600                  show_ref_action(__entry->action),
 601                  __entry->is_data)
 602);
 603
 604DEFINE_EVENT(btrfs_delayed_ref_head,  add_delayed_ref_head,
 605
 606        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 607                 struct btrfs_delayed_ref_head *head_ref,
 608                 int action),
 609
 610        TP_ARGS(ref, head_ref, action)
 611);
 612
 613DEFINE_EVENT(btrfs_delayed_ref_head,  run_delayed_ref_head,
 614
 615        TP_PROTO(struct btrfs_delayed_ref_node *ref,
 616                 struct btrfs_delayed_ref_head *head_ref,
 617                 int action),
 618
 619        TP_ARGS(ref, head_ref, action)
 620);
 621
 622#define show_chunk_type(type)                                   \
 623        __print_flags(type, "|",                                \
 624                { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
 625                { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
 626                { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
 627                { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
 628                { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
 629                { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
 630                { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
 631                { BTRFS_BLOCK_GROUP_RAID5,      "RAID5" },      \
 632                { BTRFS_BLOCK_GROUP_RAID6,      "RAID6" })
 633
 634DECLARE_EVENT_CLASS(btrfs__chunk,
 635
 636        TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
 637                 u64 offset, u64 size),
 638
 639        TP_ARGS(root, map, offset, size),
 640
 641        TP_STRUCT__entry(
 642                __field(        int,  num_stripes               )
 643                __field(        u64,  type                      )
 644                __field(        int,  sub_stripes               )
 645                __field(        u64,  offset                    )
 646                __field(        u64,  size                      )
 647                __field(        u64,  root_objectid             )
 648        ),
 649
 650        TP_fast_assign(
 651                __entry->num_stripes    = map->num_stripes;
 652                __entry->type           = map->type;
 653                __entry->sub_stripes    = map->sub_stripes;
 654                __entry->offset         = offset;
 655                __entry->size           = size;
 656                __entry->root_objectid  = root->root_key.objectid;
 657        ),
 658
 659        TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
 660                  "num_stripes = %d, sub_stripes = %d, type = %s",
 661                  show_root_type(__entry->root_objectid),
 662                  (unsigned long long)__entry->offset,
 663                  (unsigned long long)__entry->size,
 664                  __entry->num_stripes, __entry->sub_stripes,
 665                  show_chunk_type(__entry->type))
 666);
 667
 668DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
 669
 670        TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
 671                 u64 offset, u64 size),
 672
 673        TP_ARGS(root, map, offset, size)
 674);
 675
 676DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
 677
 678        TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
 679                 u64 offset, u64 size),
 680
 681        TP_ARGS(root, map, offset, size)
 682);
 683
 684TRACE_EVENT(btrfs_cow_block,
 685
 686        TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
 687                 struct extent_buffer *cow),
 688
 689        TP_ARGS(root, buf, cow),
 690
 691        TP_STRUCT__entry(
 692                __field(        u64,  root_objectid             )
 693                __field(        u64,  buf_start                 )
 694                __field(        int,  refs                      )
 695                __field(        u64,  cow_start                 )
 696                __field(        int,  buf_level                 )
 697                __field(        int,  cow_level                 )
 698        ),
 699
 700        TP_fast_assign(
 701                __entry->root_objectid  = root->root_key.objectid;
 702                __entry->buf_start      = buf->start;
 703                __entry->refs           = atomic_read(&buf->refs);
 704                __entry->cow_start      = cow->start;
 705                __entry->buf_level      = btrfs_header_level(buf);
 706                __entry->cow_level      = btrfs_header_level(cow);
 707        ),
 708
 709        TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
 710                  "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
 711                  show_root_type(__entry->root_objectid),
 712                  __entry->refs,
 713                  (unsigned long long)__entry->buf_start,
 714                  __entry->buf_level,
 715                  (unsigned long long)__entry->cow_start,
 716                  __entry->cow_level)
 717);
 718
 719TRACE_EVENT(btrfs_space_reservation,
 720
 721        TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
 722                 u64 bytes, int reserve),
 723
 724        TP_ARGS(fs_info, type, val, bytes, reserve),
 725
 726        TP_STRUCT__entry(
 727                __array(        u8,     fsid,   BTRFS_UUID_SIZE )
 728                __string(       type,   type                    )
 729                __field(        u64,    val                     )
 730                __field(        u64,    bytes                   )
 731                __field(        int,    reserve                 )
 732        ),
 733
 734        TP_fast_assign(
 735                memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
 736                __assign_str(type, type);
 737                __entry->val            = val;
 738                __entry->bytes          = bytes;
 739                __entry->reserve        = reserve;
 740        ),
 741
 742        TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
 743                  __entry->val, __entry->reserve ? "reserve" : "release",
 744                  __entry->bytes)
 745);
 746
 747DECLARE_EVENT_CLASS(btrfs__reserved_extent,
 748
 749        TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
 750
 751        TP_ARGS(root, start, len),
 752
 753        TP_STRUCT__entry(
 754                __field(        u64,  root_objectid             )
 755                __field(        u64,  start                     )
 756                __field(        u64,  len                       )
 757        ),
 758
 759        TP_fast_assign(
 760                __entry->root_objectid  = root->root_key.objectid;
 761                __entry->start          = start;
 762                __entry->len            = len;
 763        ),
 764
 765        TP_printk("root = %llu(%s), start = %llu, len = %llu",
 766                  show_root_type(__entry->root_objectid),
 767                  (unsigned long long)__entry->start,
 768                  (unsigned long long)__entry->len)
 769);
 770
 771DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
 772
 773        TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
 774
 775        TP_ARGS(root, start, len)
 776);
 777
 778DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
 779
 780        TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
 781
 782        TP_ARGS(root, start, len)
 783);
 784
 785TRACE_EVENT(find_free_extent,
 786
 787        TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
 788                 u64 data),
 789
 790        TP_ARGS(root, num_bytes, empty_size, data),
 791
 792        TP_STRUCT__entry(
 793                __field(        u64,    root_objectid           )
 794                __field(        u64,    num_bytes               )
 795                __field(        u64,    empty_size              )
 796                __field(        u64,    data                    )
 797        ),
 798
 799        TP_fast_assign(
 800                __entry->root_objectid  = root->root_key.objectid;
 801                __entry->num_bytes      = num_bytes;
 802                __entry->empty_size     = empty_size;
 803                __entry->data           = data;
 804        ),
 805
 806        TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
 807                  "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
 808                  __entry->num_bytes, __entry->empty_size, __entry->data,
 809                  __print_flags((unsigned long)__entry->data, "|",
 810                                 BTRFS_GROUP_FLAGS))
 811);
 812
 813DECLARE_EVENT_CLASS(btrfs__reserve_extent,
 814
 815        TP_PROTO(struct btrfs_root *root,
 816                 struct btrfs_block_group_cache *block_group, u64 start,
 817                 u64 len),
 818
 819        TP_ARGS(root, block_group, start, len),
 820
 821        TP_STRUCT__entry(
 822                __field(        u64,    root_objectid           )
 823                __field(        u64,    bg_objectid             )
 824                __field(        u64,    flags                   )
 825                __field(        u64,    start                   )
 826                __field(        u64,    len                     )
 827        ),
 828
 829        TP_fast_assign(
 830                __entry->root_objectid  = root->root_key.objectid;
 831                __entry->bg_objectid    = block_group->key.objectid;
 832                __entry->flags          = block_group->flags;
 833                __entry->start          = start;
 834                __entry->len            = len;
 835        ),
 836
 837        TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
 838                  "start = %Lu, len = %Lu",
 839                  show_root_type(__entry->root_objectid), __entry->bg_objectid,
 840                  __entry->flags, __print_flags((unsigned long)__entry->flags,
 841                                                "|", BTRFS_GROUP_FLAGS),
 842                  __entry->start, __entry->len)
 843);
 844
 845DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
 846
 847        TP_PROTO(struct btrfs_root *root,
 848                 struct btrfs_block_group_cache *block_group, u64 start,
 849                 u64 len),
 850
 851        TP_ARGS(root, block_group, start, len)
 852);
 853
 854DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
 855
 856        TP_PROTO(struct btrfs_root *root,
 857                 struct btrfs_block_group_cache *block_group, u64 start,
 858                 u64 len),
 859
 860        TP_ARGS(root, block_group, start, len)
 861);
 862
 863TRACE_EVENT(btrfs_find_cluster,
 864
 865        TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
 866                 u64 bytes, u64 empty_size, u64 min_bytes),
 867
 868        TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
 869
 870        TP_STRUCT__entry(
 871                __field(        u64,    bg_objectid             )
 872                __field(        u64,    flags                   )
 873                __field(        u64,    start                   )
 874                __field(        u64,    bytes                   )
 875                __field(        u64,    empty_size              )
 876                __field(        u64,    min_bytes               )
 877        ),
 878
 879        TP_fast_assign(
 880                __entry->bg_objectid    = block_group->key.objectid;
 881                __entry->flags          = block_group->flags;
 882                __entry->start          = start;
 883                __entry->bytes          = bytes;
 884                __entry->empty_size     = empty_size;
 885                __entry->min_bytes      = min_bytes;
 886        ),
 887
 888        TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
 889                  " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
 890                  __entry->flags,
 891                  __print_flags((unsigned long)__entry->flags, "|",
 892                                BTRFS_GROUP_FLAGS), __entry->start,
 893                  __entry->bytes, __entry->empty_size,  __entry->min_bytes)
 894);
 895
 896TRACE_EVENT(btrfs_failed_cluster_setup,
 897
 898        TP_PROTO(struct btrfs_block_group_cache *block_group),
 899
 900        TP_ARGS(block_group),
 901
 902        TP_STRUCT__entry(
 903                __field(        u64,    bg_objectid             )
 904        ),
 905
 906        TP_fast_assign(
 907                __entry->bg_objectid    = block_group->key.objectid;
 908        ),
 909
 910        TP_printk("block_group = %Lu", __entry->bg_objectid)
 911);
 912
 913TRACE_EVENT(btrfs_setup_cluster,
 914
 915        TP_PROTO(struct btrfs_block_group_cache *block_group,
 916                 struct btrfs_free_cluster *cluster, u64 size, int bitmap),
 917
 918        TP_ARGS(block_group, cluster, size, bitmap),
 919
 920        TP_STRUCT__entry(
 921                __field(        u64,    bg_objectid             )
 922                __field(        u64,    flags                   )
 923                __field(        u64,    start                   )
 924                __field(        u64,    max_size                )
 925                __field(        u64,    size                    )
 926                __field(        int,    bitmap                  )
 927        ),
 928
 929        TP_fast_assign(
 930                __entry->bg_objectid    = block_group->key.objectid;
 931                __entry->flags          = block_group->flags;
 932                __entry->start          = cluster->window_start;
 933                __entry->max_size       = cluster->max_size;
 934                __entry->size           = size;
 935                __entry->bitmap         = bitmap;
 936        ),
 937
 938        TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
 939                  "size = %Lu, max_size = %Lu, bitmap = %d",
 940                  __entry->bg_objectid,
 941                  __entry->flags,
 942                  __print_flags((unsigned long)__entry->flags, "|",
 943                                BTRFS_GROUP_FLAGS), __entry->start,
 944                  __entry->size, __entry->max_size, __entry->bitmap)
 945);
 946
 947struct extent_state;
 948TRACE_EVENT(alloc_extent_state,
 949
 950        TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
 951
 952        TP_ARGS(state, mask, IP),
 953
 954        TP_STRUCT__entry(
 955                __field(struct extent_state *, state)
 956                __field(gfp_t, mask)
 957                __field(unsigned long, ip)
 958        ),
 959
 960        TP_fast_assign(
 961                __entry->state  = state,
 962                __entry->mask   = mask,
 963                __entry->ip     = IP
 964        ),
 965
 966        TP_printk("state=%p; mask = %s; caller = %pS", __entry->state,
 967                  show_gfp_flags(__entry->mask), (void *)__entry->ip)
 968);
 969
 970TRACE_EVENT(free_extent_state,
 971
 972        TP_PROTO(struct extent_state *state, unsigned long IP),
 973
 974        TP_ARGS(state, IP),
 975
 976        TP_STRUCT__entry(
 977                __field(struct extent_state *, state)
 978                __field(unsigned long, ip)
 979        ),
 980
 981        TP_fast_assign(
 982                __entry->state  = state,
 983                __entry->ip = IP
 984        ),
 985
 986        TP_printk(" state=%p; caller = %pS", __entry->state,
 987                  (void *)__entry->ip)
 988);
 989
 990DECLARE_EVENT_CLASS(btrfs__work,
 991
 992        TP_PROTO(struct btrfs_work *work),
 993
 994        TP_ARGS(work),
 995
 996        TP_STRUCT__entry(
 997                __field(        void *, work                    )
 998                __field(        void *, wq                      )
 999                __field(        void *, func                    )
1000                __field(        void *, ordered_func            )
1001                __field(        void *, ordered_free            )
1002                __field(        void *, normal_work             )
1003        ),
1004
1005        TP_fast_assign(
1006                __entry->work           = work;
1007                __entry->wq             = work->wq;
1008                __entry->func           = work->func;
1009                __entry->ordered_func   = work->ordered_func;
1010                __entry->ordered_free   = work->ordered_free;
1011                __entry->normal_work    = &work->normal_work;
1012        ),
1013
1014        TP_printk("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p,"
1015                  " ordered_free=%p",
1016                  __entry->work, __entry->normal_work, __entry->wq,
1017                   __entry->func, __entry->ordered_func, __entry->ordered_free)
1018);
1019
1020/* For situiations that the work is freed */
1021DECLARE_EVENT_CLASS(btrfs__work__done,
1022
1023        TP_PROTO(struct btrfs_work *work),
1024
1025        TP_ARGS(work),
1026
1027        TP_STRUCT__entry(
1028                __field(        void *, work                    )
1029        ),
1030
1031        TP_fast_assign(
1032                __entry->work           = work;
1033        ),
1034
1035        TP_printk("work->%p", __entry->work)
1036);
1037
1038DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1039
1040        TP_PROTO(struct btrfs_work *work),
1041
1042        TP_ARGS(work)
1043);
1044
1045DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1046
1047        TP_PROTO(struct btrfs_work *work),
1048
1049        TP_ARGS(work)
1050);
1051
1052DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1053
1054        TP_PROTO(struct btrfs_work *work),
1055
1056        TP_ARGS(work)
1057);
1058
1059DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1060
1061        TP_PROTO(struct btrfs_work *work),
1062
1063        TP_ARGS(work)
1064);
1065
1066DECLARE_EVENT_CLASS(btrfs__workqueue,
1067
1068        TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1069
1070        TP_ARGS(wq, name, high),
1071
1072        TP_STRUCT__entry(
1073                __field(        void *, wq                      )
1074                __string(       name,   name                    )
1075                __field(        int ,   high                    )
1076        ),
1077
1078        TP_fast_assign(
1079                __entry->wq             = wq;
1080                __assign_str(name, name);
1081                __entry->high           = high;
1082        ),
1083
1084        TP_printk("name=%s%s, wq=%p", __get_str(name),
1085                  __print_flags(__entry->high, "",
1086                                {(WQ_HIGHPRI),  "-high"}),
1087                  __entry->wq)
1088);
1089
1090DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1091
1092        TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1093
1094        TP_ARGS(wq, name, high)
1095);
1096
1097DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1098
1099        TP_PROTO(struct __btrfs_workqueue *wq),
1100
1101        TP_ARGS(wq),
1102
1103        TP_STRUCT__entry(
1104                __field(        void *, wq                      )
1105        ),
1106
1107        TP_fast_assign(
1108                __entry->wq             = wq;
1109        ),
1110
1111        TP_printk("wq=%p", __entry->wq)
1112);
1113
1114DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1115
1116        TP_PROTO(struct __btrfs_workqueue *wq),
1117
1118        TP_ARGS(wq)
1119);
1120
1121DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1122
1123        TP_PROTO(struct inode *inode, u64 free_reserved),
1124
1125        TP_ARGS(inode, free_reserved),
1126
1127        TP_STRUCT__entry(
1128                __field(        u64,            rootid          )
1129                __field(        unsigned long,  ino             )
1130                __field(        u64,            free_reserved   )
1131        ),
1132
1133        TP_fast_assign(
1134                __entry->rootid         =       BTRFS_I(inode)->root->objectid;
1135                __entry->ino            =       inode->i_ino;
1136                __entry->free_reserved  =       free_reserved;
1137        ),
1138
1139        TP_printk("rootid=%llu, ino=%lu, free_reserved=%llu",
1140                  __entry->rootid, __entry->ino, __entry->free_reserved)
1141);
1142
1143DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_init_data_rsv_map,
1144
1145        TP_PROTO(struct inode *inode, u64 free_reserved),
1146
1147        TP_ARGS(inode, free_reserved)
1148);
1149
1150DEFINE_EVENT(btrfs__qgroup_data_map, btrfs_qgroup_free_data_rsv_map,
1151
1152        TP_PROTO(struct inode *inode, u64 free_reserved),
1153
1154        TP_ARGS(inode, free_reserved)
1155);
1156
1157#define BTRFS_QGROUP_OPERATIONS                         \
1158        { QGROUP_RESERVE,       "reserve"       },      \
1159        { QGROUP_RELEASE,       "release"       },      \
1160        { QGROUP_FREE,          "free"          }
1161
1162DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1163
1164        TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1165
1166        TP_ARGS(inode, start, len, reserved, op),
1167
1168        TP_STRUCT__entry(
1169                __field(        u64,            rootid          )
1170                __field(        unsigned long,  ino             )
1171                __field(        u64,            start           )
1172                __field(        u64,            len             )
1173                __field(        u64,            reserved        )
1174                __field(        int,            op              )
1175        ),
1176
1177        TP_fast_assign(
1178                __entry->rootid         = BTRFS_I(inode)->root->objectid;
1179                __entry->ino            = inode->i_ino;
1180                __entry->start          = start;
1181                __entry->len            = len;
1182                __entry->reserved       = reserved;
1183                __entry->op             = op;
1184        ),
1185
1186        TP_printk("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s",
1187                  __entry->rootid, __entry->ino, __entry->start, __entry->len,
1188                  __entry->reserved,
1189                  __print_flags((unsigned long)__entry->op, "",
1190                                BTRFS_QGROUP_OPERATIONS)
1191        )
1192);
1193
1194DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_reserve_data,
1195
1196        TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1197
1198        TP_ARGS(inode, start, len, reserved, op)
1199);
1200
1201DEFINE_EVENT(btrfs__qgroup_rsv_data, btrfs_qgroup_release_data,
1202
1203        TP_PROTO(struct inode *inode, u64 start, u64 len, u64 reserved, int op),
1204
1205        TP_ARGS(inode, start, len, reserved, op)
1206);
1207
1208DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1209
1210        TP_PROTO(u64 ref_root, u64 reserved),
1211
1212        TP_ARGS(ref_root, reserved),
1213
1214        TP_STRUCT__entry(
1215                __field(        u64,            ref_root        )
1216                __field(        u64,            reserved        )
1217        ),
1218
1219        TP_fast_assign(
1220                __entry->ref_root       = ref_root;
1221                __entry->reserved       = reserved;
1222        ),
1223
1224        TP_printk("root=%llu, reserved=%llu, op=free",
1225                  __entry->ref_root, __entry->reserved)
1226);
1227
1228DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
1229
1230        TP_PROTO(u64 ref_root, u64 reserved),
1231
1232        TP_ARGS(ref_root, reserved)
1233);
1234
1235DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1236        TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1237
1238        TP_ARGS(rec),
1239
1240        TP_STRUCT__entry(
1241                __field(        u64,  bytenr            )
1242                __field(        u64,  num_bytes         )
1243        ),
1244
1245        TP_fast_assign(
1246                __entry->bytenr         = rec->bytenr,
1247                __entry->num_bytes      = rec->num_bytes;
1248        ),
1249
1250        TP_printk("bytenr = %llu, num_bytes = %llu",
1251                  (unsigned long long)__entry->bytenr,
1252                  (unsigned long long)__entry->num_bytes)
1253);
1254
1255DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1256
1257        TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1258
1259        TP_ARGS(rec)
1260);
1261
1262DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_insert_dirty_extent,
1263
1264        TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1265
1266        TP_ARGS(rec)
1267);
1268
1269TRACE_EVENT(btrfs_qgroup_account_extent,
1270
1271        TP_PROTO(u64 bytenr, u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
1272
1273        TP_ARGS(bytenr, num_bytes, nr_old_roots, nr_new_roots),
1274
1275        TP_STRUCT__entry(
1276                __field(        u64,  bytenr                    )
1277                __field(        u64,  num_bytes                 )
1278                __field(        u64,  nr_old_roots              )
1279                __field(        u64,  nr_new_roots              )
1280        ),
1281
1282        TP_fast_assign(
1283                __entry->bytenr         = bytenr;
1284                __entry->num_bytes      = num_bytes;
1285                __entry->nr_old_roots   = nr_old_roots;
1286                __entry->nr_new_roots   = nr_new_roots;
1287        ),
1288
1289        TP_printk("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
1290                  "nr_new_roots = %llu",
1291                  __entry->bytenr,
1292                  __entry->num_bytes,
1293                  __entry->nr_old_roots,
1294                  __entry->nr_new_roots)
1295);
1296
1297TRACE_EVENT(qgroup_update_counters,
1298
1299        TP_PROTO(u64 qgid, u64 cur_old_count, u64 cur_new_count),
1300
1301        TP_ARGS(qgid, cur_old_count, cur_new_count),
1302
1303        TP_STRUCT__entry(
1304                __field(        u64,  qgid                      )
1305                __field(        u64,  cur_old_count             )
1306                __field(        u64,  cur_new_count             )
1307        ),
1308
1309        TP_fast_assign(
1310                __entry->qgid           = qgid;
1311                __entry->cur_old_count  = cur_old_count;
1312                __entry->cur_new_count  = cur_new_count;
1313        ),
1314
1315        TP_printk("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
1316                  __entry->qgid,
1317                  __entry->cur_old_count,
1318                  __entry->cur_new_count)
1319);
1320
1321#endif /* _TRACE_BTRFS_H */
1322
1323/* This part must be outside protection */
1324#include <trace/define_trace.h>
1325