diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-02-08 13:00:22 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-02-08 13:00:22 -0500 |
commit | 343d9c283c9847da043fda3e76e3197f27b667dd (patch) | |
tree | 6c37b7cd1d9eeb711fa1aeffee1930e446c406f8 | |
parent | 078d5039a13dedbd2ed14153a6d764fd75baae07 (diff) |
jbd2: add tracepoints which provide per-handle statistics
Handles which stay open a long time are problematic when it comes time
to close down a transaction so it can be committed. These tracepoints
will help us determine which ones are the problematic ones, and to
validate whether changes makes things better or worse.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | fs/jbd2/transaction.c | 28 | ||||
-rw-r--r-- | include/linux/jbd2.h | 8 | ||||
-rw-r--r-- | include/trace/events/jbd2.h | 98 |
3 files changed, 131 insertions, 3 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 735609e2d636..b7e2385c6e92 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/bug.h> | 30 | #include <linux/bug.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | 32 | ||
33 | #include <trace/events/jbd2.h> | ||
34 | |||
33 | static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh); | 35 | static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh); |
34 | static void __jbd2_journal_unfile_buffer(struct journal_head *jh); | 36 | static void __jbd2_journal_unfile_buffer(struct journal_head *jh); |
35 | 37 | ||
@@ -307,6 +309,8 @@ repeat: | |||
307 | */ | 309 | */ |
308 | update_t_max_wait(transaction, ts); | 310 | update_t_max_wait(transaction, ts); |
309 | handle->h_transaction = transaction; | 311 | handle->h_transaction = transaction; |
312 | handle->h_requested_credits = nblocks; | ||
313 | handle->h_start_jiffies = jiffies; | ||
310 | atomic_inc(&transaction->t_updates); | 314 | atomic_inc(&transaction->t_updates); |
311 | atomic_inc(&transaction->t_handle_count); | 315 | atomic_inc(&transaction->t_handle_count); |
312 | jbd_debug(4, "Handle %p given %d credits (total %d, free %d)\n", | 316 | jbd_debug(4, "Handle %p given %d credits (total %d, free %d)\n", |
@@ -353,7 +357,8 @@ static handle_t *new_handle(int nblocks) | |||
353 | * Return a pointer to a newly allocated handle, or an ERR_PTR() value | 357 | * Return a pointer to a newly allocated handle, or an ERR_PTR() value |
354 | * on failure. | 358 | * on failure. |
355 | */ | 359 | */ |
356 | handle_t *jbd2__journal_start(journal_t *journal, int nblocks, gfp_t gfp_mask) | 360 | handle_t *jbd2__journal_start(journal_t *journal, int nblocks, gfp_t gfp_mask, |
361 | unsigned int type, unsigned int line_no) | ||
357 | { | 362 | { |
358 | handle_t *handle = journal_current_handle(); | 363 | handle_t *handle = journal_current_handle(); |
359 | int err; | 364 | int err; |
@@ -379,6 +384,11 @@ handle_t *jbd2__journal_start(journal_t *journal, int nblocks, gfp_t gfp_mask) | |||
379 | current->journal_info = NULL; | 384 | current->journal_info = NULL; |
380 | handle = ERR_PTR(err); | 385 | handle = ERR_PTR(err); |
381 | } | 386 | } |
387 | handle->h_type = type; | ||
388 | handle->h_line_no = line_no; | ||
389 | trace_jbd2_handle_start(journal->j_fs_dev->bd_dev, | ||
390 | handle->h_transaction->t_tid, type, | ||
391 | line_no, nblocks); | ||
382 | return handle; | 392 | return handle; |
383 | } | 393 | } |
384 | EXPORT_SYMBOL(jbd2__journal_start); | 394 | EXPORT_SYMBOL(jbd2__journal_start); |
@@ -386,7 +396,7 @@ EXPORT_SYMBOL(jbd2__journal_start); | |||
386 | 396 | ||
387 | handle_t *jbd2_journal_start(journal_t *journal, int nblocks) | 397 | handle_t *jbd2_journal_start(journal_t *journal, int nblocks) |
388 | { | 398 | { |
389 | return jbd2__journal_start(journal, nblocks, GFP_NOFS); | 399 | return jbd2__journal_start(journal, nblocks, GFP_NOFS, 0, 0); |
390 | } | 400 | } |
391 | EXPORT_SYMBOL(jbd2_journal_start); | 401 | EXPORT_SYMBOL(jbd2_journal_start); |
392 | 402 | ||
@@ -448,7 +458,14 @@ int jbd2_journal_extend(handle_t *handle, int nblocks) | |||
448 | goto unlock; | 458 | goto unlock; |
449 | } | 459 | } |
450 | 460 | ||
461 | trace_jbd2_handle_extend(journal->j_fs_dev->bd_dev, | ||
462 | handle->h_transaction->t_tid, | ||
463 | handle->h_type, handle->h_line_no, | ||
464 | handle->h_buffer_credits, | ||
465 | nblocks); | ||
466 | |||
451 | handle->h_buffer_credits += nblocks; | 467 | handle->h_buffer_credits += nblocks; |
468 | handle->h_requested_credits += nblocks; | ||
452 | atomic_add(nblocks, &transaction->t_outstanding_credits); | 469 | atomic_add(nblocks, &transaction->t_outstanding_credits); |
453 | result = 0; | 470 | result = 0; |
454 | 471 | ||
@@ -1377,6 +1394,13 @@ int jbd2_journal_stop(handle_t *handle) | |||
1377 | } | 1394 | } |
1378 | 1395 | ||
1379 | jbd_debug(4, "Handle %p going down\n", handle); | 1396 | jbd_debug(4, "Handle %p going down\n", handle); |
1397 | trace_jbd2_handle_stats(journal->j_fs_dev->bd_dev, | ||
1398 | handle->h_transaction->t_tid, | ||
1399 | handle->h_type, handle->h_line_no, | ||
1400 | jiffies - handle->h_start_jiffies, | ||
1401 | handle->h_sync, handle->h_requested_credits, | ||
1402 | (handle->h_requested_credits - | ||
1403 | handle->h_buffer_credits)); | ||
1380 | 1404 | ||
1381 | /* | 1405 | /* |
1382 | * Implement synchronous transaction batching. If the handle | 1406 | * Implement synchronous transaction batching. If the handle |
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 24db7256a5ff..fa5fea17b619 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h | |||
@@ -400,6 +400,11 @@ struct jbd2_journal_handle | |||
400 | unsigned int h_sync: 1; /* sync-on-close */ | 400 | unsigned int h_sync: 1; /* sync-on-close */ |
401 | unsigned int h_jdata: 1; /* force data journaling */ | 401 | unsigned int h_jdata: 1; /* force data journaling */ |
402 | unsigned int h_aborted: 1; /* fatal error on handle */ | 402 | unsigned int h_aborted: 1; /* fatal error on handle */ |
403 | unsigned int h_type: 8; /* for handle statistics */ | ||
404 | unsigned int h_line_no: 16; /* for handle statistics */ | ||
405 | |||
406 | unsigned long h_start_jiffies; | ||
407 | unsigned int h_requested_credits; | ||
403 | 408 | ||
404 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 409 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
405 | struct lockdep_map h_lockdep_map; | 410 | struct lockdep_map h_lockdep_map; |
@@ -1071,7 +1076,8 @@ static inline handle_t *journal_current_handle(void) | |||
1071 | */ | 1076 | */ |
1072 | 1077 | ||
1073 | extern handle_t *jbd2_journal_start(journal_t *, int nblocks); | 1078 | extern handle_t *jbd2_journal_start(journal_t *, int nblocks); |
1074 | extern handle_t *jbd2__journal_start(journal_t *, int nblocks, gfp_t gfp_mask); | 1079 | extern handle_t *jbd2__journal_start(journal_t *, int nblocks, gfp_t gfp_mask, |
1080 | unsigned int type, unsigned int line_no); | ||
1075 | extern int jbd2_journal_restart(handle_t *, int nblocks); | 1081 | extern int jbd2_journal_restart(handle_t *, int nblocks); |
1076 | extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask); | 1082 | extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask); |
1077 | extern int jbd2_journal_extend (handle_t *, int nblocks); | 1083 | extern int jbd2_journal_extend (handle_t *, int nblocks); |
diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h index 5419f57beb1f..070df49e4a1d 100644 --- a/include/trace/events/jbd2.h +++ b/include/trace/events/jbd2.h | |||
@@ -132,6 +132,104 @@ TRACE_EVENT(jbd2_submit_inode_data, | |||
132 | (unsigned long) __entry->ino) | 132 | (unsigned long) __entry->ino) |
133 | ); | 133 | ); |
134 | 134 | ||
135 | TRACE_EVENT(jbd2_handle_start, | ||
136 | TP_PROTO(dev_t dev, unsigned long tid, unsigned int type, | ||
137 | unsigned int line_no, int requested_blocks), | ||
138 | |||
139 | TP_ARGS(dev, tid, type, line_no, requested_blocks), | ||
140 | |||
141 | TP_STRUCT__entry( | ||
142 | __field( dev_t, dev ) | ||
143 | __field( unsigned long, tid ) | ||
144 | __field( unsigned int, type ) | ||
145 | __field( unsigned int, line_no ) | ||
146 | __field( int, requested_blocks) | ||
147 | ), | ||
148 | |||
149 | TP_fast_assign( | ||
150 | __entry->dev = dev; | ||
151 | __entry->tid = tid; | ||
152 | __entry->type = type; | ||
153 | __entry->line_no = line_no; | ||
154 | __entry->requested_blocks = requested_blocks; | ||
155 | ), | ||
156 | |||
157 | TP_printk("dev %d,%d tid %lu type %u line_no %u " | ||
158 | "requested_blocks %d", | ||
159 | MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid, | ||
160 | __entry->type, __entry->line_no, __entry->requested_blocks) | ||
161 | ); | ||
162 | |||
163 | TRACE_EVENT(jbd2_handle_extend, | ||
164 | TP_PROTO(dev_t dev, unsigned long tid, unsigned int type, | ||
165 | unsigned int line_no, int buffer_credits, | ||
166 | int requested_blocks), | ||
167 | |||
168 | TP_ARGS(dev, tid, type, line_no, buffer_credits, requested_blocks), | ||
169 | |||
170 | TP_STRUCT__entry( | ||
171 | __field( dev_t, dev ) | ||
172 | __field( unsigned long, tid ) | ||
173 | __field( unsigned int, type ) | ||
174 | __field( unsigned int, line_no ) | ||
175 | __field( int, buffer_credits ) | ||
176 | __field( int, requested_blocks) | ||
177 | ), | ||
178 | |||
179 | TP_fast_assign( | ||
180 | __entry->dev = dev; | ||
181 | __entry->tid = tid; | ||
182 | __entry->type = type; | ||
183 | __entry->line_no = line_no; | ||
184 | __entry->buffer_credits = buffer_credits; | ||
185 | __entry->requested_blocks = requested_blocks; | ||
186 | ), | ||
187 | |||
188 | TP_printk("dev %d,%d tid %lu type %u line_no %u " | ||
189 | "buffer_credits %d requested_blocks %d", | ||
190 | MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid, | ||
191 | __entry->type, __entry->line_no, __entry->buffer_credits, | ||
192 | __entry->requested_blocks) | ||
193 | ); | ||
194 | |||
195 | TRACE_EVENT(jbd2_handle_stats, | ||
196 | TP_PROTO(dev_t dev, unsigned long tid, unsigned int type, | ||
197 | unsigned int line_no, int interval, int sync, | ||
198 | int requested_blocks, int dirtied_blocks), | ||
199 | |||
200 | TP_ARGS(dev, tid, type, line_no, interval, sync, | ||
201 | requested_blocks, dirtied_blocks), | ||
202 | |||
203 | TP_STRUCT__entry( | ||
204 | __field( dev_t, dev ) | ||
205 | __field( unsigned long, tid ) | ||
206 | __field( unsigned int, type ) | ||
207 | __field( unsigned int, line_no ) | ||
208 | __field( int, interval ) | ||
209 | __field( int, sync ) | ||
210 | __field( int, requested_blocks) | ||
211 | __field( int, dirtied_blocks ) | ||
212 | ), | ||
213 | |||
214 | TP_fast_assign( | ||
215 | __entry->dev = dev; | ||
216 | __entry->tid = tid; | ||
217 | __entry->type = type; | ||
218 | __entry->line_no = line_no; | ||
219 | __entry->interval = interval; | ||
220 | __entry->sync = sync; | ||
221 | __entry->requested_blocks = requested_blocks; | ||
222 | __entry->dirtied_blocks = dirtied_blocks; | ||
223 | ), | ||
224 | |||
225 | TP_printk("dev %d,%d tid %lu type %u line_no %u interval %d " | ||
226 | "sync %d requested_blocks %d dirtied_blocks %d", | ||
227 | MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid, | ||
228 | __entry->type, __entry->line_no, __entry->interval, | ||
229 | __entry->sync, __entry->requested_blocks, | ||
230 | __entry->dirtied_blocks) | ||
231 | ); | ||
232 | |||
135 | TRACE_EVENT(jbd2_run_stats, | 233 | TRACE_EVENT(jbd2_run_stats, |
136 | TP_PROTO(dev_t dev, unsigned long tid, | 234 | TP_PROTO(dev_t dev, unsigned long tid, |
137 | struct transaction_run_stats_s *stats), | 235 | struct transaction_run_stats_s *stats), |