btrfs: print-tree: Add locking status output for debug build
PATCH v2 1/1 btrfs: print-tree: Add locking status output for debug build
It's pretty handy if we can get debug output for locking status of an extent buffer, specially for race related debugging.
So add the following output for btrfs_print_tree() and btrfs_print_leaf():
- refs
- write_locks (as w:%d)
- read_locks (as r:%d)
- blocking_writers (as bw:%d)
- blocking_readers (as br:%d)
- spinning_writers (as sw:%d)
- spinning_readers (as sr:%d)
- lock_owner
- current->pid
---
changelog:
v2:
Use correct specifier for int (both atomic_t and pid_t, no special specifier found in Documentation/core-api/printk-formats.rst)
--- fs/btrfs/print-tree.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
fs/btrfs/print-tree.c +22 -0
@@ -179,6 +179,26 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset, } } +/* +* Helper to output refs and locking status. +* +* Useful to debug race related problem +*/ +static void print_eb_refs_lock (struct extent_buffer *eb) +{ +#ifdef CONFIG_BTRFS_DEBUG +btrfs_info (eb->fs_info, +"refs %u lock(w:%u r:%u bw:%u br:%u sw:%u sr:%u) lock_owner %u current %u" , +atomic_read (&eb->refs),atomic_read (&eb->write_locks), +atomic_read (&eb->read_locks), +atomic_read (&eb->blocking_writers), +atomic_read (&eb->blocking_readers), +atomic_read (&eb->spinning_writers), +atomic_read (&eb->spinning_readers), + eb->lock_owner, current->pid); +#endif +} +void btrfs_print_leaf (struct extent_buffer *l) {struct btrfs_fs_info *fs_info;
@@ -206,6 +226,7 @@ void btrfs_print_leaf(struct extent_buffer *l)"leaf %llu gen %llu total ptrs %d free space %d owner %llu" ,btrfs_header_bytenr (l),btrfs_header_generation (l), nr, btrfs_leaf_free_space(fs_info, l), btrfs_header_owner(l)); +print_eb_refs_lock (l);for (i =0 ; i < nr ; i++) { item =btrfs_item_nr (i);btrfs_item_key_to_cpu (l, &key, i);
@@ -360,6 +381,7 @@ void btrfs_print_tree(struct extent_buffer *c, bool follow)btrfs_header_bytenr (c), level,btrfs_header_generation (c), nr, (u32 )BTRFS_NODEPTRS_PER_BLOCK (fs_info) - nr, btrfs_header_owner(c)); +print_eb_refs_lock (c);for (i =0 ; i < nr; i++) {btrfs_node_key_to_cpu (c, &key, i); pr_info("\tkey %d (%llu %u %llu) block %llu gen %llu\n",
Signature · 1 line
2.17.0
Quoted 14 lines · Qu Wenruo
It's pretty handy if we can get debug output for locking status of an extent buffer, specially for race related debugging.
So add the following output for
btrfs_print_tree()andbtrfs_print_leaf():
- refs
-write_locks(as w:%d)
-read_locks(as r:%d)
-blocking_writers(as bw:%d)
-blocking_readers(as br:%d)
-spinning_writers(as sw:%d)
-spinning_readers(as sr:%d)
-lock_owner
-current->pid
This is fine
fs/btrfs/print-tree.c static void print_uuid_item(struct extent_buffer *l, unsigned long offset, · line 190
Quoted 1 line
fs/btrfs/print-tree.c +1
-0+ btrfs_info(eb->fs_info,
I'd rather make that btrfs_debug, but info is fine as long as it's under CONFIG_BTRFS_DEBUG.
Quoted 1 line
+"refs %u lock(w:%u r:%u bw:%u br:%u sw:%u sr:%u)
lock_owner%u current %u",
This is not :) but I'll fix that according to the above.
Quoted 18 lines · David Sterba
Quoted 14 lines · Qu Wenruo
It's pretty handy if we can get debug output for locking status of an extent buffer, specially for race related debugging.
So add the following output for
btrfs_print_tree()andbtrfs_print_leaf():
- refs
-write_locks(as w:%d)
-read_locks(as r:%d)
-blocking_writers(as bw:%d)
-blocking_readers(as br:%d)
-spinning_writers(as sw:%d)
-spinning_readers(as sr:%d)
-lock_owner
-current->pidThis is fine
Quoted 8 lines
fs/btrfs/print-tree.c static void print_uuid_item(struct extent_buffer *l, unsigned long offset, · line 190
Quoted 1 line
fs/btrfs/print-tree.c +1
-0+ btrfs_info(eb->fs_info,I'd rather make that
btrfs_debug, but info is fine as long as it's underCONFIG_BTRFS_DEBUG.Quoted 1 line
+"refs %u lock(w:%u r:%u bw:%u br:%u sw:%u sr:%u)
lock_owner%u current %u",This is not :) but I'll fix that according to the above.
Not again...
I forgot to commit the change, no wonder everything is the same and need to modify the patch commit message.
Sorry for the inconvenience.
Thanks,
Qu
Quoted 7 lines
Reviewed-by David Sterba <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html