summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/locking.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-04-15 09:15:25 -0400
committerDavid Sterba <dsterba@suse.com>2019-04-29 13:02:43 -0400
commit31aab402076f7743b70217cdaa00356e8f8ec530 (patch)
tree7d75128d2cf0a8c6cc67f5e747feba42134cf4f3 /fs/btrfs/locking.c
parent34e73cc930a8677426c9cbffdd3421e18f32e79f (diff)
btrfs: trace: Introduce trace events for all btrfs tree locking events
Unlike btrfs_tree_lock() and btrfs_tree_read_lock(), the remaining functions in locking.c will not sleep, thus doesn't make much sense to record their execution time. Those events are introduced mainly for user space tool to audit and detect lock leakage or dead lock. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/locking.c')
-rw-r--r--fs/btrfs/locking.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 67b77f1d113e..2f6c3c7851ed 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -87,6 +87,7 @@ static void btrfs_assert_tree_write_locks_put(struct extent_buffer *eb) { }
87 87
88void btrfs_set_lock_blocking_read(struct extent_buffer *eb) 88void btrfs_set_lock_blocking_read(struct extent_buffer *eb)
89{ 89{
90 trace_btrfs_set_lock_blocking_read(eb);
90 /* 91 /*
91 * No lock is required. The lock owner may change if we have a read 92 * No lock is required. The lock owner may change if we have a read
92 * lock, but it won't change to or away from us. If we have the write 93 * lock, but it won't change to or away from us. If we have the write
@@ -102,6 +103,7 @@ void btrfs_set_lock_blocking_read(struct extent_buffer *eb)
102 103
103void btrfs_set_lock_blocking_write(struct extent_buffer *eb) 104void btrfs_set_lock_blocking_write(struct extent_buffer *eb)
104{ 105{
106 trace_btrfs_set_lock_blocking_write(eb);
105 /* 107 /*
106 * No lock is required. The lock owner may change if we have a read 108 * No lock is required. The lock owner may change if we have a read
107 * lock, but it won't change to or away from us. If we have the write 109 * lock, but it won't change to or away from us. If we have the write
@@ -119,6 +121,7 @@ void btrfs_set_lock_blocking_write(struct extent_buffer *eb)
119 121
120void btrfs_clear_lock_blocking_read(struct extent_buffer *eb) 122void btrfs_clear_lock_blocking_read(struct extent_buffer *eb)
121{ 123{
124 trace_btrfs_clear_lock_blocking_read(eb);
122 /* 125 /*
123 * No lock is required. The lock owner may change if we have a read 126 * No lock is required. The lock owner may change if we have a read
124 * lock, but it won't change to or away from us. If we have the write 127 * lock, but it won't change to or away from us. If we have the write
@@ -136,6 +139,7 @@ void btrfs_clear_lock_blocking_read(struct extent_buffer *eb)
136 139
137void btrfs_clear_lock_blocking_write(struct extent_buffer *eb) 140void btrfs_clear_lock_blocking_write(struct extent_buffer *eb)
138{ 141{
142 trace_btrfs_clear_lock_blocking_write(eb);
139 /* 143 /*
140 * no lock is required. The lock owner may change if 144 * no lock is required. The lock owner may change if
141 * we have a read lock, but it won't change to or away 145 * we have a read lock, but it won't change to or away
@@ -209,6 +213,7 @@ int btrfs_tree_read_lock_atomic(struct extent_buffer *eb)
209 } 213 }
210 btrfs_assert_tree_read_locks_get(eb); 214 btrfs_assert_tree_read_locks_get(eb);
211 btrfs_assert_spinning_readers_get(eb); 215 btrfs_assert_spinning_readers_get(eb);
216 trace_btrfs_tree_read_lock_atomic(eb);
212 return 1; 217 return 1;
213} 218}
214 219
@@ -230,6 +235,7 @@ int btrfs_try_tree_read_lock(struct extent_buffer *eb)
230 } 235 }
231 btrfs_assert_tree_read_locks_get(eb); 236 btrfs_assert_tree_read_locks_get(eb);
232 btrfs_assert_spinning_readers_get(eb); 237 btrfs_assert_spinning_readers_get(eb);
238 trace_btrfs_try_tree_read_lock(eb);
233 return 1; 239 return 1;
234} 240}
235 241
@@ -252,6 +258,7 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
252 btrfs_assert_tree_write_locks_get(eb); 258 btrfs_assert_tree_write_locks_get(eb);
253 btrfs_assert_spinning_writers_get(eb); 259 btrfs_assert_spinning_writers_get(eb);
254 eb->lock_owner = current->pid; 260 eb->lock_owner = current->pid;
261 trace_btrfs_try_tree_write_lock(eb);
255 return 1; 262 return 1;
256} 263}
257 264
@@ -260,6 +267,7 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
260 */ 267 */
261void btrfs_tree_read_unlock(struct extent_buffer *eb) 268void btrfs_tree_read_unlock(struct extent_buffer *eb)
262{ 269{
270 trace_btrfs_tree_read_unlock(eb);
263 /* 271 /*
264 * if we're nested, we have the write lock. No new locking 272 * if we're nested, we have the write lock. No new locking
265 * is needed as long as we are the lock owner. 273 * is needed as long as we are the lock owner.
@@ -281,6 +289,7 @@ void btrfs_tree_read_unlock(struct extent_buffer *eb)
281 */ 289 */
282void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb) 290void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb)
283{ 291{
292 trace_btrfs_tree_read_unlock_blocking(eb);
284 /* 293 /*
285 * if we're nested, we have the write lock. No new locking 294 * if we're nested, we have the write lock. No new locking
286 * is needed as long as we are the lock owner. 295 * is needed as long as we are the lock owner.
@@ -336,6 +345,7 @@ void btrfs_tree_unlock(struct extent_buffer *eb)
336 BUG_ON(blockers > 1); 345 BUG_ON(blockers > 1);
337 346
338 btrfs_assert_tree_locked(eb); 347 btrfs_assert_tree_locked(eb);
348 trace_btrfs_tree_unlock(eb);
339 eb->lock_owner = 0; 349 eb->lock_owner = 0;
340 btrfs_assert_tree_write_locks_put(eb); 350 btrfs_assert_tree_write_locks_put(eb);
341 351