aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-13 20:40:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-13 20:40:22 -0500
commite96f8f18c81b2f5b290206fc0da74b551e82646d (patch)
tree325bc21cf8afc3a9673cc0e75f50bd48b13774d0
parent04e396277b5f171f8676defc5b720084f1cc0948 (diff)
parent0bf70aebf12d8fa0d06967b72ca4b257eb6adf06 (diff)
Merge branch 'for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason: "These are all over the place. The tracepoint part of the pull fixes a crash and adds a little more information to two tracepoints, while the rest are good old fashioned fixes" * 'for-linus-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: btrfs: make tracepoint format strings more compact Btrfs: add truncated_len for ordered extent tracepoints Btrfs: add 'inode' for extent map tracepoint btrfs: fix crash when tracepoint arguments are freed by wq callbacks Btrfs: adjust outstanding_extents counter properly when dio write is split Btrfs: fix lockdep warning about log_mutex Btrfs: use down_read_nested to make lockdep silent btrfs: fix locking when we put back a delayed ref that's too new btrfs: fix error handling when run_delayed_extent_op fails btrfs: return the actual error value from from btrfs_uuid_tree_iterate
-rw-r--r--fs/btrfs/async-thread.c15
-rw-r--r--fs/btrfs/extent-tree.c8
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/btrfs/tree-log.c13
-rw-r--r--fs/btrfs/uuid-tree.c4
-rw-r--r--include/trace/events/btrfs.h146
6 files changed, 117 insertions, 82 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 63d197724519..ff0b0be92d61 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -273,6 +273,8 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
273 unsigned long flags; 273 unsigned long flags;
274 274
275 while (1) { 275 while (1) {
276 void *wtag;
277
276 spin_lock_irqsave(lock, flags); 278 spin_lock_irqsave(lock, flags);
277 if (list_empty(list)) 279 if (list_empty(list))
278 break; 280 break;
@@ -299,11 +301,13 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
299 spin_unlock_irqrestore(lock, flags); 301 spin_unlock_irqrestore(lock, flags);
300 302
301 /* 303 /*
302 * we don't want to call the ordered free functions 304 * We don't want to call the ordered free functions with the
303 * with the lock held though 305 * lock held though. Save the work as tag for the trace event,
306 * because the callback could free the structure.
304 */ 307 */
308 wtag = work;
305 work->ordered_free(work); 309 work->ordered_free(work);
306 trace_btrfs_all_work_done(work); 310 trace_btrfs_all_work_done(wq->fs_info, wtag);
307 } 311 }
308 spin_unlock_irqrestore(lock, flags); 312 spin_unlock_irqrestore(lock, flags);
309} 313}
@@ -311,6 +315,7 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
311static void normal_work_helper(struct btrfs_work *work) 315static void normal_work_helper(struct btrfs_work *work)
312{ 316{
313 struct __btrfs_workqueue *wq; 317 struct __btrfs_workqueue *wq;
318 void *wtag;
314 int need_order = 0; 319 int need_order = 0;
315 320
316 /* 321 /*
@@ -324,6 +329,8 @@ static void normal_work_helper(struct btrfs_work *work)
324 if (work->ordered_func) 329 if (work->ordered_func)
325 need_order = 1; 330 need_order = 1;
326 wq = work->wq; 331 wq = work->wq;
332 /* Safe for tracepoints in case work gets freed by the callback */
333 wtag = work;
327 334
328 trace_btrfs_work_sched(work); 335 trace_btrfs_work_sched(work);
329 thresh_exec_hook(wq); 336 thresh_exec_hook(wq);
@@ -333,7 +340,7 @@ static void normal_work_helper(struct btrfs_work *work)
333 run_ordered_work(wq); 340 run_ordered_work(wq);
334 } 341 }
335 if (!need_order) 342 if (!need_order)
336 trace_btrfs_all_work_done(work); 343 trace_btrfs_all_work_done(wq->fs_info, wtag);
337} 344}
338 345
339void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func, 346void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e97302f437a1..dcd2e798767e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2522,11 +2522,11 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2522 if (ref && ref->seq && 2522 if (ref && ref->seq &&
2523 btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) { 2523 btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) {
2524 spin_unlock(&locked_ref->lock); 2524 spin_unlock(&locked_ref->lock);
2525 btrfs_delayed_ref_unlock(locked_ref);
2526 spin_lock(&delayed_refs->lock); 2525 spin_lock(&delayed_refs->lock);
2527 locked_ref->processing = 0; 2526 locked_ref->processing = 0;
2528 delayed_refs->num_heads_ready++; 2527 delayed_refs->num_heads_ready++;
2529 spin_unlock(&delayed_refs->lock); 2528 spin_unlock(&delayed_refs->lock);
2529 btrfs_delayed_ref_unlock(locked_ref);
2530 locked_ref = NULL; 2530 locked_ref = NULL;
2531 cond_resched(); 2531 cond_resched();
2532 count++; 2532 count++;
@@ -2572,7 +2572,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2572 */ 2572 */
2573 if (must_insert_reserved) 2573 if (must_insert_reserved)
2574 locked_ref->must_insert_reserved = 1; 2574 locked_ref->must_insert_reserved = 1;
2575 spin_lock(&delayed_refs->lock);
2575 locked_ref->processing = 0; 2576 locked_ref->processing = 0;
2577 delayed_refs->num_heads_ready++;
2578 spin_unlock(&delayed_refs->lock);
2576 btrfs_debug(fs_info, 2579 btrfs_debug(fs_info,
2577 "run_delayed_extent_op returned %d", 2580 "run_delayed_extent_op returned %d",
2578 ret); 2581 ret);
@@ -7384,7 +7387,8 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
7384 7387
7385 spin_unlock(&cluster->refill_lock); 7388 spin_unlock(&cluster->refill_lock);
7386 7389
7387 down_read(&used_bg->data_rwsem); 7390 /* We should only have one-level nested. */
7391 down_read_nested(&used_bg->data_rwsem, SINGLE_DEPTH_NESTING);
7388 7392
7389 spin_lock(&cluster->refill_lock); 7393 spin_lock(&cluster->refill_lock);
7390 if (used_bg == cluster->block_group) 7394 if (used_bg == cluster->block_group)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f2b281ad7af6..4e024260ad71 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7059,7 +7059,7 @@ insert:
7059 write_unlock(&em_tree->lock); 7059 write_unlock(&em_tree->lock);
7060out: 7060out:
7061 7061
7062 trace_btrfs_get_extent(root, em); 7062 trace_btrfs_get_extent(root, inode, em);
7063 7063
7064 btrfs_free_path(path); 7064 btrfs_free_path(path);
7065 if (trans) { 7065 if (trans) {
@@ -7623,11 +7623,18 @@ static void adjust_dio_outstanding_extents(struct inode *inode,
7623 * within our reservation, otherwise we need to adjust our inode 7623 * within our reservation, otherwise we need to adjust our inode
7624 * counter appropriately. 7624 * counter appropriately.
7625 */ 7625 */
7626 if (dio_data->outstanding_extents) { 7626 if (dio_data->outstanding_extents >= num_extents) {
7627 dio_data->outstanding_extents -= num_extents; 7627 dio_data->outstanding_extents -= num_extents;
7628 } else { 7628 } else {
7629 /*
7630 * If dio write length has been split due to no large enough
7631 * contiguous space, we need to compensate our inode counter
7632 * appropriately.
7633 */
7634 u64 num_needed = num_extents - dio_data->outstanding_extents;
7635
7629 spin_lock(&BTRFS_I(inode)->lock); 7636 spin_lock(&BTRFS_I(inode)->lock);
7630 BTRFS_I(inode)->outstanding_extents += num_extents; 7637 BTRFS_I(inode)->outstanding_extents += num_needed;
7631 spin_unlock(&BTRFS_I(inode)->lock); 7638 spin_unlock(&BTRFS_I(inode)->lock);
7632 } 7639 }
7633} 7640}
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f10bf5213ed8..eeffff84f280 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -37,6 +37,7 @@
37 */ 37 */
38#define LOG_INODE_ALL 0 38#define LOG_INODE_ALL 0
39#define LOG_INODE_EXISTS 1 39#define LOG_INODE_EXISTS 1
40#define LOG_OTHER_INODE 2
40 41
41/* 42/*
42 * directory trouble cases 43 * directory trouble cases
@@ -4641,7 +4642,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4641 if (S_ISDIR(inode->i_mode) || 4642 if (S_ISDIR(inode->i_mode) ||
4642 (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, 4643 (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
4643 &BTRFS_I(inode)->runtime_flags) && 4644 &BTRFS_I(inode)->runtime_flags) &&
4644 inode_only == LOG_INODE_EXISTS)) 4645 inode_only >= LOG_INODE_EXISTS))
4645 max_key.type = BTRFS_XATTR_ITEM_KEY; 4646 max_key.type = BTRFS_XATTR_ITEM_KEY;
4646 else 4647 else
4647 max_key.type = (u8)-1; 4648 max_key.type = (u8)-1;
@@ -4665,7 +4666,13 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
4665 return ret; 4666 return ret;
4666 } 4667 }
4667 4668
4668 mutex_lock(&BTRFS_I(inode)->log_mutex); 4669 if (inode_only == LOG_OTHER_INODE) {
4670 inode_only = LOG_INODE_EXISTS;
4671 mutex_lock_nested(&BTRFS_I(inode)->log_mutex,
4672 SINGLE_DEPTH_NESTING);
4673 } else {
4674 mutex_lock(&BTRFS_I(inode)->log_mutex);
4675 }
4669 4676
4670 /* 4677 /*
4671 * a brute force approach to making sure we get the most uptodate 4678 * a brute force approach to making sure we get the most uptodate
@@ -4817,7 +4824,7 @@ again:
4817 * unpin it. 4824 * unpin it.
4818 */ 4825 */
4819 err = btrfs_log_inode(trans, root, other_inode, 4826 err = btrfs_log_inode(trans, root, other_inode,
4820 LOG_INODE_EXISTS, 4827 LOG_OTHER_INODE,
4821 0, LLONG_MAX, ctx); 4828 0, LLONG_MAX, ctx);
4822 iput(other_inode); 4829 iput(other_inode);
4823 if (err) 4830 if (err)
diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 161342b73ce5..726f928238d0 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -352,7 +352,5 @@ skip:
352 352
353out: 353out:
354 btrfs_free_path(path); 354 btrfs_free_path(path);
355 if (ret) 355 return ret;
356 btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
357 return 0;
358} 356}
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c14bed4ab097..88d18a8ceb59 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -130,8 +130,8 @@ DECLARE_EVENT_CLASS(btrfs__inode,
130 BTRFS_I(inode)->root->root_key.objectid; 130 BTRFS_I(inode)->root->root_key.objectid;
131 ), 131 ),
132 132
133 TP_printk_btrfs("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, " 133 TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%lu blocks=%llu "
134 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu", 134 "disk_i_size=%llu last_trans=%llu logged_trans=%llu",
135 show_root_type(__entry->root_objectid), 135 show_root_type(__entry->root_objectid),
136 (unsigned long long)__entry->generation, 136 (unsigned long long)__entry->generation,
137 (unsigned long)__entry->ino, 137 (unsigned long)__entry->ino,
@@ -184,14 +184,16 @@ DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
184 184
185TRACE_EVENT_CONDITION(btrfs_get_extent, 185TRACE_EVENT_CONDITION(btrfs_get_extent,
186 186
187 TP_PROTO(struct btrfs_root *root, struct extent_map *map), 187 TP_PROTO(struct btrfs_root *root, struct inode *inode,
188 struct extent_map *map),
188 189
189 TP_ARGS(root, map), 190 TP_ARGS(root, inode, map),
190 191
191 TP_CONDITION(map), 192 TP_CONDITION(map),
192 193
193 TP_STRUCT__entry_btrfs( 194 TP_STRUCT__entry_btrfs(
194 __field( u64, root_objectid ) 195 __field( u64, root_objectid )
196 __field( u64, ino )
195 __field( u64, start ) 197 __field( u64, start )
196 __field( u64, len ) 198 __field( u64, len )
197 __field( u64, orig_start ) 199 __field( u64, orig_start )
@@ -204,7 +206,8 @@ TRACE_EVENT_CONDITION(btrfs_get_extent,
204 206
205 TP_fast_assign_btrfs(root->fs_info, 207 TP_fast_assign_btrfs(root->fs_info,
206 __entry->root_objectid = root->root_key.objectid; 208 __entry->root_objectid = root->root_key.objectid;
207 __entry->start = map->start; 209 __entry->ino = btrfs_ino(inode);
210 __entry->start = map->start;
208 __entry->len = map->len; 211 __entry->len = map->len;
209 __entry->orig_start = map->orig_start; 212 __entry->orig_start = map->orig_start;
210 __entry->block_start = map->block_start; 213 __entry->block_start = map->block_start;
@@ -214,11 +217,12 @@ TRACE_EVENT_CONDITION(btrfs_get_extent,
214 __entry->compress_type = map->compress_type; 217 __entry->compress_type = map->compress_type;
215 ), 218 ),
216 219
217 TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu, " 220 TP_printk_btrfs("root=%llu(%s) ino=%llu start=%llu len=%llu "
218 "orig_start = %llu, block_start = %llu(%s), " 221 "orig_start=%llu block_start=%llu(%s) "
219 "block_len = %llu, flags = %s, refs = %u, " 222 "block_len=%llu flags=%s refs=%u "
220 "compress_type = %u", 223 "compress_type=%u",
221 show_root_type(__entry->root_objectid), 224 show_root_type(__entry->root_objectid),
225 (unsigned long long)__entry->ino,
222 (unsigned long long)__entry->start, 226 (unsigned long long)__entry->start,
223 (unsigned long long)__entry->len, 227 (unsigned long long)__entry->len,
224 (unsigned long long)__entry->orig_start, 228 (unsigned long long)__entry->orig_start,
@@ -259,6 +263,7 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
259 __field( int, compress_type ) 263 __field( int, compress_type )
260 __field( int, refs ) 264 __field( int, refs )
261 __field( u64, root_objectid ) 265 __field( u64, root_objectid )
266 __field( u64, truncated_len )
262 ), 267 ),
263 268
264 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 269 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb),
@@ -273,18 +278,21 @@ DECLARE_EVENT_CLASS(btrfs__ordered_extent,
273 __entry->refs = atomic_read(&ordered->refs); 278 __entry->refs = atomic_read(&ordered->refs);
274 __entry->root_objectid = 279 __entry->root_objectid =
275 BTRFS_I(inode)->root->root_key.objectid; 280 BTRFS_I(inode)->root->root_key.objectid;
281 __entry->truncated_len = ordered->truncated_len;
276 ), 282 ),
277 283
278 TP_printk_btrfs("root = %llu(%s), ino = %llu, file_offset = %llu, " 284 TP_printk_btrfs("root=%llu(%s) ino=%llu file_offset=%llu "
279 "start = %llu, len = %llu, disk_len = %llu, " 285 "start=%llu len=%llu disk_len=%llu "
280 "bytes_left = %llu, flags = %s, compress_type = %d, " 286 "truncated_len=%llu "
281 "refs = %d", 287 "bytes_left=%llu flags=%s compress_type=%d "
288 "refs=%d",
282 show_root_type(__entry->root_objectid), 289 show_root_type(__entry->root_objectid),
283 (unsigned long long)__entry->ino, 290 (unsigned long long)__entry->ino,
284 (unsigned long long)__entry->file_offset, 291 (unsigned long long)__entry->file_offset,
285 (unsigned long long)__entry->start, 292 (unsigned long long)__entry->start,
286 (unsigned long long)__entry->len, 293 (unsigned long long)__entry->len,
287 (unsigned long long)__entry->disk_len, 294 (unsigned long long)__entry->disk_len,
295 (unsigned long long)__entry->truncated_len,
288 (unsigned long long)__entry->bytes_left, 296 (unsigned long long)__entry->bytes_left,
289 show_ordered_flags(__entry->flags), 297 show_ordered_flags(__entry->flags),
290 __entry->compress_type, __entry->refs) 298 __entry->compress_type, __entry->refs)
@@ -354,10 +362,10 @@ DECLARE_EVENT_CLASS(btrfs__writepage,
354 BTRFS_I(inode)->root->root_key.objectid; 362 BTRFS_I(inode)->root->root_key.objectid;
355 ), 363 ),
356 364
357 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, " 365 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu "
358 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, " 366 "nr_to_write=%ld pages_skipped=%ld range_start=%llu "
359 "range_end = %llu, for_kupdate = %d, " 367 "range_end=%llu for_kupdate=%d "
360 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu", 368 "for_reclaim=%d range_cyclic=%d writeback_index=%lu",
361 show_root_type(__entry->root_objectid), 369 show_root_type(__entry->root_objectid),
362 (unsigned long)__entry->ino, __entry->index, 370 (unsigned long)__entry->ino, __entry->index,
363 __entry->nr_to_write, __entry->pages_skipped, 371 __entry->nr_to_write, __entry->pages_skipped,
@@ -400,8 +408,8 @@ TRACE_EVENT(btrfs_writepage_end_io_hook,
400 BTRFS_I(page->mapping->host)->root->root_key.objectid; 408 BTRFS_I(page->mapping->host)->root->root_key.objectid;
401 ), 409 ),
402 410
403 TP_printk_btrfs("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, " 411 TP_printk_btrfs("root=%llu(%s) ino=%lu page_index=%lu start=%llu "
404 "end = %llu, uptodate = %d", 412 "end=%llu uptodate=%d",
405 show_root_type(__entry->root_objectid), 413 show_root_type(__entry->root_objectid),
406 (unsigned long)__entry->ino, (unsigned long)__entry->index, 414 (unsigned long)__entry->ino, (unsigned long)__entry->index,
407 (unsigned long long)__entry->start, 415 (unsigned long long)__entry->start,
@@ -433,7 +441,7 @@ TRACE_EVENT(btrfs_sync_file,
433 BTRFS_I(inode)->root->root_key.objectid; 441 BTRFS_I(inode)->root->root_key.objectid;
434 ), 442 ),
435 443
436 TP_printk_btrfs("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d", 444 TP_printk_btrfs("root=%llu(%s) ino=%ld parent=%ld datasync=%d",
437 show_root_type(__entry->root_objectid), 445 show_root_type(__entry->root_objectid),
438 (unsigned long)__entry->ino, (unsigned long)__entry->parent, 446 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
439 __entry->datasync) 447 __entry->datasync)
@@ -484,9 +492,9 @@ TRACE_EVENT(btrfs_add_block_group,
484 __entry->create = create; 492 __entry->create = create;
485 ), 493 ),
486 494
487 TP_printk("%pU: block_group offset = %llu, size = %llu, " 495 TP_printk("%pU: block_group offset=%llu size=%llu "
488 "flags = %llu(%s), bytes_used = %llu, bytes_super = %llu, " 496 "flags=%llu(%s) bytes_used=%llu bytes_super=%llu "
489 "create = %d", __entry->fsid, 497 "create=%d", __entry->fsid,
490 (unsigned long long)__entry->offset, 498 (unsigned long long)__entry->offset,
491 (unsigned long long)__entry->size, 499 (unsigned long long)__entry->size,
492 (unsigned long long)__entry->flags, 500 (unsigned long long)__entry->flags,
@@ -535,9 +543,9 @@ DECLARE_EVENT_CLASS(btrfs_delayed_tree_ref,
535 __entry->seq = ref->seq; 543 __entry->seq = ref->seq;
536 ), 544 ),
537 545
538 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, " 546 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
539 "parent = %llu(%s), ref_root = %llu(%s), level = %d, " 547 "parent=%llu(%s) ref_root=%llu(%s) level=%d "
540 "type = %s, seq = %llu", 548 "type=%s seq=%llu",
541 (unsigned long long)__entry->bytenr, 549 (unsigned long long)__entry->bytenr,
542 (unsigned long long)__entry->num_bytes, 550 (unsigned long long)__entry->num_bytes,
543 show_ref_action(__entry->action), 551 show_ref_action(__entry->action),
@@ -600,9 +608,9 @@ DECLARE_EVENT_CLASS(btrfs_delayed_data_ref,
600 __entry->seq = ref->seq; 608 __entry->seq = ref->seq;
601 ), 609 ),
602 610
603 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, " 611 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s "
604 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, " 612 "parent=%llu(%s) ref_root=%llu(%s) owner=%llu "
605 "offset = %llu, type = %s, seq = %llu", 613 "offset=%llu type=%s seq=%llu",
606 (unsigned long long)__entry->bytenr, 614 (unsigned long long)__entry->bytenr,
607 (unsigned long long)__entry->num_bytes, 615 (unsigned long long)__entry->num_bytes,
608 show_ref_action(__entry->action), 616 show_ref_action(__entry->action),
@@ -657,7 +665,7 @@ DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
657 __entry->is_data = head_ref->is_data; 665 __entry->is_data = head_ref->is_data;
658 ), 666 ),
659 667
660 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d", 668 TP_printk_btrfs("bytenr=%llu num_bytes=%llu action=%s is_data=%d",
661 (unsigned long long)__entry->bytenr, 669 (unsigned long long)__entry->bytenr,
662 (unsigned long long)__entry->num_bytes, 670 (unsigned long long)__entry->num_bytes,
663 show_ref_action(__entry->action), 671 show_ref_action(__entry->action),
@@ -721,8 +729,8 @@ DECLARE_EVENT_CLASS(btrfs__chunk,
721 __entry->root_objectid = fs_info->chunk_root->root_key.objectid; 729 __entry->root_objectid = fs_info->chunk_root->root_key.objectid;
722 ), 730 ),
723 731
724 TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, " 732 TP_printk_btrfs("root=%llu(%s) offset=%llu size=%llu "
725 "num_stripes = %d, sub_stripes = %d, type = %s", 733 "num_stripes=%d sub_stripes=%d type=%s",
726 show_root_type(__entry->root_objectid), 734 show_root_type(__entry->root_objectid),
727 (unsigned long long)__entry->offset, 735 (unsigned long long)__entry->offset,
728 (unsigned long long)__entry->size, 736 (unsigned long long)__entry->size,
@@ -771,8 +779,8 @@ TRACE_EVENT(btrfs_cow_block,
771 __entry->cow_level = btrfs_header_level(cow); 779 __entry->cow_level = btrfs_header_level(cow);
772 ), 780 ),
773 781
774 TP_printk_btrfs("root = %llu(%s), refs = %d, orig_buf = %llu " 782 TP_printk_btrfs("root=%llu(%s) refs=%d orig_buf=%llu "
775 "(orig_level = %d), cow_buf = %llu (cow_level = %d)", 783 "(orig_level=%d) cow_buf=%llu (cow_level=%d)",
776 show_root_type(__entry->root_objectid), 784 show_root_type(__entry->root_objectid),
777 __entry->refs, 785 __entry->refs,
778 (unsigned long long)__entry->buf_start, 786 (unsigned long long)__entry->buf_start,
@@ -836,7 +844,7 @@ TRACE_EVENT(btrfs_trigger_flush,
836 __assign_str(reason, reason) 844 __assign_str(reason, reason)
837 ), 845 ),
838 846
839 TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu", 847 TP_printk("%pU: %s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
840 __entry->fsid, __get_str(reason), __entry->flush, 848 __entry->fsid, __get_str(reason), __entry->flush,
841 show_flush_action(__entry->flush), 849 show_flush_action(__entry->flush),
842 (unsigned long long)__entry->flags, 850 (unsigned long long)__entry->flags,
@@ -879,8 +887,8 @@ TRACE_EVENT(btrfs_flush_space,
879 __entry->ret = ret; 887 __entry->ret = ret;
880 ), 888 ),
881 889
882 TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, " 890 TP_printk("%pU: state=%d(%s) flags=%llu(%s) num_bytes=%llu "
883 "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state, 891 "orig_bytes=%llu ret=%d", __entry->fsid, __entry->state,
884 show_flush_state(__entry->state), 892 show_flush_state(__entry->state),
885 (unsigned long long)__entry->flags, 893 (unsigned long long)__entry->flags,
886 __print_flags((unsigned long)__entry->flags, "|", 894 __print_flags((unsigned long)__entry->flags, "|",
@@ -905,7 +913,7 @@ DECLARE_EVENT_CLASS(btrfs__reserved_extent,
905 __entry->len = len; 913 __entry->len = len;
906 ), 914 ),
907 915
908 TP_printk_btrfs("root = %llu(%s), start = %llu, len = %llu", 916 TP_printk_btrfs("root=%llu(%s) start=%llu len=%llu",
909 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 917 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
910 (unsigned long long)__entry->start, 918 (unsigned long long)__entry->start,
911 (unsigned long long)__entry->len) 919 (unsigned long long)__entry->len)
@@ -944,7 +952,7 @@ TRACE_EVENT(find_free_extent,
944 __entry->data = data; 952 __entry->data = data;
945 ), 953 ),
946 954
947 TP_printk_btrfs("root = %Lu(%s), len = %Lu, empty_size = %Lu, flags = %Lu(%s)", 955 TP_printk_btrfs("root=%Lu(%s) len=%Lu empty_size=%Lu flags=%Lu(%s)",
948 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 956 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
949 __entry->num_bytes, __entry->empty_size, __entry->data, 957 __entry->num_bytes, __entry->empty_size, __entry->data,
950 __print_flags((unsigned long)__entry->data, "|", 958 __print_flags((unsigned long)__entry->data, "|",
@@ -973,8 +981,8 @@ DECLARE_EVENT_CLASS(btrfs__reserve_extent,
973 __entry->len = len; 981 __entry->len = len;
974 ), 982 ),
975 983
976 TP_printk_btrfs("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), " 984 TP_printk_btrfs("root=%Lu(%s) block_group=%Lu flags=%Lu(%s) "
977 "start = %Lu, len = %Lu", 985 "start=%Lu len=%Lu",
978 show_root_type(BTRFS_EXTENT_TREE_OBJECTID), 986 show_root_type(BTRFS_EXTENT_TREE_OBJECTID),
979 __entry->bg_objectid, 987 __entry->bg_objectid,
980 __entry->flags, __print_flags((unsigned long)__entry->flags, 988 __entry->flags, __print_flags((unsigned long)__entry->flags,
@@ -1025,8 +1033,8 @@ TRACE_EVENT(btrfs_find_cluster,
1025 __entry->min_bytes = min_bytes; 1033 __entry->min_bytes = min_bytes;
1026 ), 1034 ),
1027 1035
1028 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu," 1036 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) start=%Lu len=%Lu "
1029 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid, 1037 "empty_size=%Lu min_bytes=%Lu", __entry->bg_objectid,
1030 __entry->flags, 1038 __entry->flags,
1031 __print_flags((unsigned long)__entry->flags, "|", 1039 __print_flags((unsigned long)__entry->flags, "|",
1032 BTRFS_GROUP_FLAGS), __entry->start, 1040 BTRFS_GROUP_FLAGS), __entry->start,
@@ -1047,7 +1055,7 @@ TRACE_EVENT(btrfs_failed_cluster_setup,
1047 __entry->bg_objectid = block_group->key.objectid; 1055 __entry->bg_objectid = block_group->key.objectid;
1048 ), 1056 ),
1049 1057
1050 TP_printk_btrfs("block_group = %Lu", __entry->bg_objectid) 1058 TP_printk_btrfs("block_group=%Lu", __entry->bg_objectid)
1051); 1059);
1052 1060
1053TRACE_EVENT(btrfs_setup_cluster, 1061TRACE_EVENT(btrfs_setup_cluster,
@@ -1075,8 +1083,8 @@ TRACE_EVENT(btrfs_setup_cluster,
1075 __entry->bitmap = bitmap; 1083 __entry->bitmap = bitmap;
1076 ), 1084 ),
1077 1085
1078 TP_printk_btrfs("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, " 1086 TP_printk_btrfs("block_group=%Lu flags=%Lu(%s) window_start=%Lu "
1079 "size = %Lu, max_size = %Lu, bitmap = %d", 1087 "size=%Lu max_size=%Lu bitmap=%d",
1080 __entry->bg_objectid, 1088 __entry->bg_objectid,
1081 __entry->flags, 1089 __entry->flags,
1082 __print_flags((unsigned long)__entry->flags, "|", 1090 __print_flags((unsigned long)__entry->flags, "|",
@@ -1103,7 +1111,7 @@ TRACE_EVENT(alloc_extent_state,
1103 __entry->ip = IP 1111 __entry->ip = IP
1104 ), 1112 ),
1105 1113
1106 TP_printk("state=%p; mask = %s; caller = %pS", __entry->state, 1114 TP_printk("state=%p mask=%s caller=%pS", __entry->state,
1107 show_gfp_flags(__entry->mask), (void *)__entry->ip) 1115 show_gfp_flags(__entry->mask), (void *)__entry->ip)
1108); 1116);
1109 1117
@@ -1123,7 +1131,7 @@ TRACE_EVENT(free_extent_state,
1123 __entry->ip = IP 1131 __entry->ip = IP
1124 ), 1132 ),
1125 1133
1126 TP_printk(" state=%p; caller = %pS", __entry->state, 1134 TP_printk("state=%p caller=%pS", __entry->state,
1127 (void *)__entry->ip) 1135 (void *)__entry->ip)
1128); 1136);
1129 1137
@@ -1151,28 +1159,32 @@ DECLARE_EVENT_CLASS(btrfs__work,
1151 __entry->normal_work = &work->normal_work; 1159 __entry->normal_work = &work->normal_work;
1152 ), 1160 ),
1153 1161
1154 TP_printk_btrfs("work=%p (normal_work=%p), wq=%p, func=%pf, ordered_func=%p," 1162 TP_printk_btrfs("work=%p (normal_work=%p) wq=%p func=%pf ordered_func=%p "
1155 " ordered_free=%p", 1163 "ordered_free=%p",
1156 __entry->work, __entry->normal_work, __entry->wq, 1164 __entry->work, __entry->normal_work, __entry->wq,
1157 __entry->func, __entry->ordered_func, __entry->ordered_free) 1165 __entry->func, __entry->ordered_func, __entry->ordered_free)
1158); 1166);
1159 1167
1160/* For situiations that the work is freed */ 1168/*
1169 * For situiations when the work is freed, we pass fs_info and a tag that that
1170 * matches address of the work structure so it can be paired with the
1171 * scheduling event.
1172 */
1161DECLARE_EVENT_CLASS(btrfs__work__done, 1173DECLARE_EVENT_CLASS(btrfs__work__done,
1162 1174
1163 TP_PROTO(struct btrfs_work *work), 1175 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1164 1176
1165 TP_ARGS(work), 1177 TP_ARGS(fs_info, wtag),
1166 1178
1167 TP_STRUCT__entry_btrfs( 1179 TP_STRUCT__entry_btrfs(
1168 __field( void *, work ) 1180 __field( void *, wtag )
1169 ), 1181 ),
1170 1182
1171 TP_fast_assign_btrfs(btrfs_work_owner(work), 1183 TP_fast_assign_btrfs(fs_info,
1172 __entry->work = work; 1184 __entry->wtag = wtag;
1173 ), 1185 ),
1174 1186
1175 TP_printk_btrfs("work->%p", __entry->work) 1187 TP_printk_btrfs("work->%p", __entry->wtag)
1176); 1188);
1177 1189
1178DEFINE_EVENT(btrfs__work, btrfs_work_queued, 1190DEFINE_EVENT(btrfs__work, btrfs_work_queued,
@@ -1191,9 +1203,9 @@ DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1191 1203
1192DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done, 1204DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1193 1205
1194 TP_PROTO(struct btrfs_work *work), 1206 TP_PROTO(struct btrfs_fs_info *fs_info, void *wtag),
1195 1207
1196 TP_ARGS(work) 1208 TP_ARGS(fs_info, wtag)
1197); 1209);
1198 1210
1199DEFINE_EVENT(btrfs__work, btrfs_ordered_sched, 1211DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
@@ -1221,7 +1233,7 @@ DECLARE_EVENT_CLASS(btrfs__workqueue,
1221 __entry->high = high; 1233 __entry->high = high;
1222 ), 1234 ),
1223 1235
1224 TP_printk_btrfs("name=%s%s, wq=%p", __get_str(name), 1236 TP_printk_btrfs("name=%s%s wq=%p", __get_str(name),
1225 __print_flags(__entry->high, "", 1237 __print_flags(__entry->high, "",
1226 {(WQ_HIGHPRI), "-high"}), 1238 {(WQ_HIGHPRI), "-high"}),
1227 __entry->wq) 1239 __entry->wq)
@@ -1276,7 +1288,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_data_map,
1276 __entry->free_reserved = free_reserved; 1288 __entry->free_reserved = free_reserved;
1277 ), 1289 ),
1278 1290
1279 TP_printk_btrfs("rootid=%llu, ino=%lu, free_reserved=%llu", 1291 TP_printk_btrfs("rootid=%llu ino=%lu free_reserved=%llu",
1280 __entry->rootid, __entry->ino, __entry->free_reserved) 1292 __entry->rootid, __entry->ino, __entry->free_reserved)
1281); 1293);
1282 1294
@@ -1323,7 +1335,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_rsv_data,
1323 __entry->op = op; 1335 __entry->op = op;
1324 ), 1336 ),
1325 1337
1326 TP_printk_btrfs("root=%llu, ino=%lu, start=%llu, len=%llu, reserved=%llu, op=%s", 1338 TP_printk_btrfs("root=%llu ino=%lu start=%llu len=%llu reserved=%llu op=%s",
1327 __entry->rootid, __entry->ino, __entry->start, __entry->len, 1339 __entry->rootid, __entry->ino, __entry->start, __entry->len,
1328 __entry->reserved, 1340 __entry->reserved,
1329 __print_flags((unsigned long)__entry->op, "", 1341 __print_flags((unsigned long)__entry->op, "",
@@ -1361,7 +1373,7 @@ DECLARE_EVENT_CLASS(btrfs__qgroup_delayed_ref,
1361 __entry->reserved = reserved; 1373 __entry->reserved = reserved;
1362 ), 1374 ),
1363 1375
1364 TP_printk_btrfs("root=%llu, reserved=%llu, op=free", 1376 TP_printk_btrfs("root=%llu reserved=%llu op=free",
1365 __entry->ref_root, __entry->reserved) 1377 __entry->ref_root, __entry->reserved)
1366); 1378);
1367 1379
@@ -1388,7 +1400,7 @@ DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1388 __entry->num_bytes = rec->num_bytes; 1400 __entry->num_bytes = rec->num_bytes;
1389 ), 1401 ),
1390 1402
1391 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu", 1403 TP_printk_btrfs("bytenr=%llu num_bytes=%llu",
1392 (unsigned long long)__entry->bytenr, 1404 (unsigned long long)__entry->bytenr,
1393 (unsigned long long)__entry->num_bytes) 1405 (unsigned long long)__entry->num_bytes)
1394); 1406);
@@ -1430,8 +1442,8 @@ TRACE_EVENT(btrfs_qgroup_account_extent,
1430 __entry->nr_new_roots = nr_new_roots; 1442 __entry->nr_new_roots = nr_new_roots;
1431 ), 1443 ),
1432 1444
1433 TP_printk_btrfs("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, " 1445 TP_printk_btrfs("bytenr=%llu num_bytes=%llu nr_old_roots=%llu "
1434 "nr_new_roots = %llu", 1446 "nr_new_roots=%llu",
1435 __entry->bytenr, 1447 __entry->bytenr,
1436 __entry->num_bytes, 1448 __entry->num_bytes,
1437 __entry->nr_old_roots, 1449 __entry->nr_old_roots,
@@ -1457,7 +1469,7 @@ TRACE_EVENT(qgroup_update_counters,
1457 __entry->cur_new_count = cur_new_count; 1469 __entry->cur_new_count = cur_new_count;
1458 ), 1470 ),
1459 1471
1460 TP_printk_btrfs("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu", 1472 TP_printk_btrfs("qgid=%llu cur_old_count=%llu cur_new_count=%llu",
1461 __entry->qgid, 1473 __entry->qgid,
1462 __entry->cur_old_count, 1474 __entry->cur_old_count,
1463 __entry->cur_new_count) 1475 __entry->cur_new_count)