diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-08-02 21:13:02 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-08-02 21:13:02 -0400 |
commit | 3cd48abcc1f76d6cd5ce61f3540801849a6c82e0 (patch) | |
tree | d58936b397d197f0ac27353a1dd2efdf3abe970d | |
parent | 4e0cc29b91a8056f902f0974b49084b07491905f (diff) |
xfs: add tracepoints for the deferred ops mechanism
Add tracepoints for the internals of the deferred ops mechanism
and tracepoint classes for clients of the dops, to make debugging
easier.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/libxfs/xfs_defer.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.c | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.h | 198 |
3 files changed, 218 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 2809db75e0d3..054a2032fdb3 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c | |||
@@ -159,6 +159,7 @@ xfs_defer_intake_work( | |||
159 | struct xfs_defer_pending *dfp; | 159 | struct xfs_defer_pending *dfp; |
160 | 160 | ||
161 | list_for_each_entry(dfp, &dop->dop_intake, dfp_list) { | 161 | list_for_each_entry(dfp, &dop->dop_intake, dfp_list) { |
162 | trace_xfs_defer_intake_work(tp->t_mountp, dfp); | ||
162 | dfp->dfp_intent = dfp->dfp_type->create_intent(tp, | 163 | dfp->dfp_intent = dfp->dfp_type->create_intent(tp, |
163 | dfp->dfp_count); | 164 | dfp->dfp_count); |
164 | list_sort(tp->t_mountp, &dfp->dfp_work, | 165 | list_sort(tp->t_mountp, &dfp->dfp_work, |
@@ -179,6 +180,7 @@ xfs_defer_trans_abort( | |||
179 | { | 180 | { |
180 | struct xfs_defer_pending *dfp; | 181 | struct xfs_defer_pending *dfp; |
181 | 182 | ||
183 | trace_xfs_defer_trans_abort(tp->t_mountp, dop); | ||
182 | /* | 184 | /* |
183 | * If the transaction was committed, drop the intent reference | 185 | * If the transaction was committed, drop the intent reference |
184 | * since we're bailing out of here. The other reference is | 186 | * since we're bailing out of here. The other reference is |
@@ -191,6 +193,7 @@ xfs_defer_trans_abort( | |||
191 | 193 | ||
192 | /* Abort intent items. */ | 194 | /* Abort intent items. */ |
193 | list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { | 195 | list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { |
196 | trace_xfs_defer_pending_abort(tp->t_mountp, dfp); | ||
194 | if (dfp->dfp_committed) | 197 | if (dfp->dfp_committed) |
195 | dfp->dfp_type->abort_intent(dfp->dfp_intent); | 198 | dfp->dfp_type->abort_intent(dfp->dfp_intent); |
196 | } | 199 | } |
@@ -217,9 +220,12 @@ xfs_defer_trans_roll( | |||
217 | xfs_trans_log_inode(*tp, dop->dop_inodes[i], XFS_ILOG_CORE); | 220 | xfs_trans_log_inode(*tp, dop->dop_inodes[i], XFS_ILOG_CORE); |
218 | } | 221 | } |
219 | 222 | ||
223 | trace_xfs_defer_trans_roll((*tp)->t_mountp, dop); | ||
224 | |||
220 | /* Roll the transaction. */ | 225 | /* Roll the transaction. */ |
221 | error = xfs_trans_roll(tp, ip); | 226 | error = xfs_trans_roll(tp, ip); |
222 | if (error) { | 227 | if (error) { |
228 | trace_xfs_defer_trans_roll_error((*tp)->t_mountp, dop, error); | ||
223 | xfs_defer_trans_abort(*tp, dop, error); | 229 | xfs_defer_trans_abort(*tp, dop, error); |
224 | return error; | 230 | return error; |
225 | } | 231 | } |
@@ -291,6 +297,8 @@ xfs_defer_finish( | |||
291 | 297 | ||
292 | ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); | 298 | ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); |
293 | 299 | ||
300 | trace_xfs_defer_finish((*tp)->t_mountp, dop); | ||
301 | |||
294 | /* Until we run out of pending work to finish... */ | 302 | /* Until we run out of pending work to finish... */ |
295 | while (xfs_defer_has_unfinished_work(dop)) { | 303 | while (xfs_defer_has_unfinished_work(dop)) { |
296 | /* Log intents for work items sitting in the intake. */ | 304 | /* Log intents for work items sitting in the intake. */ |
@@ -305,12 +313,14 @@ xfs_defer_finish( | |||
305 | list_for_each_entry_reverse(dfp, &dop->dop_pending, dfp_list) { | 313 | list_for_each_entry_reverse(dfp, &dop->dop_pending, dfp_list) { |
306 | if (dfp->dfp_committed) | 314 | if (dfp->dfp_committed) |
307 | break; | 315 | break; |
316 | trace_xfs_defer_pending_commit((*tp)->t_mountp, dfp); | ||
308 | dfp->dfp_committed = true; | 317 | dfp->dfp_committed = true; |
309 | } | 318 | } |
310 | 319 | ||
311 | /* Log an intent-done item for the first pending item. */ | 320 | /* Log an intent-done item for the first pending item. */ |
312 | dfp = list_first_entry(&dop->dop_pending, | 321 | dfp = list_first_entry(&dop->dop_pending, |
313 | struct xfs_defer_pending, dfp_list); | 322 | struct xfs_defer_pending, dfp_list); |
323 | trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp); | ||
314 | done_item = dfp->dfp_type->create_done(*tp, dfp->dfp_intent, | 324 | done_item = dfp->dfp_type->create_done(*tp, dfp->dfp_intent, |
315 | dfp->dfp_count); | 325 | dfp->dfp_count); |
316 | cleanup_fn = dfp->dfp_type->finish_cleanup; | 326 | cleanup_fn = dfp->dfp_type->finish_cleanup; |
@@ -343,6 +353,10 @@ xfs_defer_finish( | |||
343 | } | 353 | } |
344 | 354 | ||
345 | out: | 355 | out: |
356 | if (error) | ||
357 | trace_xfs_defer_finish_error((*tp)->t_mountp, dop, error); | ||
358 | else | ||
359 | trace_xfs_defer_finish_done((*tp)->t_mountp, dop); | ||
346 | return error; | 360 | return error; |
347 | } | 361 | } |
348 | 362 | ||
@@ -358,11 +372,14 @@ xfs_defer_cancel( | |||
358 | struct list_head *pwi; | 372 | struct list_head *pwi; |
359 | struct list_head *n; | 373 | struct list_head *n; |
360 | 374 | ||
375 | trace_xfs_defer_cancel(NULL, dop); | ||
376 | |||
361 | /* | 377 | /* |
362 | * Free the pending items. Caller should already have arranged | 378 | * Free the pending items. Caller should already have arranged |
363 | * for the intent items to be released. | 379 | * for the intent items to be released. |
364 | */ | 380 | */ |
365 | list_for_each_entry_safe(dfp, pli, &dop->dop_intake, dfp_list) { | 381 | list_for_each_entry_safe(dfp, pli, &dop->dop_intake, dfp_list) { |
382 | trace_xfs_defer_intake_cancel(NULL, dfp); | ||
366 | list_del(&dfp->dfp_list); | 383 | list_del(&dfp->dfp_list); |
367 | list_for_each_safe(pwi, n, &dfp->dfp_work) { | 384 | list_for_each_safe(pwi, n, &dfp->dfp_work) { |
368 | list_del(pwi); | 385 | list_del(pwi); |
@@ -373,6 +390,7 @@ xfs_defer_cancel( | |||
373 | kmem_free(dfp); | 390 | kmem_free(dfp); |
374 | } | 391 | } |
375 | list_for_each_entry_safe(dfp, pli, &dop->dop_pending, dfp_list) { | 392 | list_for_each_entry_safe(dfp, pli, &dop->dop_pending, dfp_list) { |
393 | trace_xfs_defer_pending_cancel(NULL, dfp); | ||
376 | list_del(&dfp->dfp_list); | 394 | list_del(&dfp->dfp_list); |
377 | list_for_each_safe(pwi, n, &dfp->dfp_work) { | 395 | list_for_each_safe(pwi, n, &dfp->dfp_work) { |
378 | list_del(pwi); | 396 | list_del(pwi); |
@@ -441,4 +459,5 @@ xfs_defer_init( | |||
441 | *fbp = NULLFSBLOCK; | 459 | *fbp = NULLFSBLOCK; |
442 | INIT_LIST_HEAD(&dop->dop_intake); | 460 | INIT_LIST_HEAD(&dop->dop_intake); |
443 | INIT_LIST_HEAD(&dop->dop_pending); | 461 | INIT_LIST_HEAD(&dop->dop_pending); |
462 | trace_xfs_defer_init(NULL, dop); | ||
444 | } | 463 | } |
diff --git a/fs/xfs/xfs_trace.c b/fs/xfs/xfs_trace.c index 13a029806805..3971527c9a07 100644 --- a/fs/xfs/xfs_trace.c +++ b/fs/xfs/xfs_trace.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
25 | #include "xfs_defer.h" | ||
25 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
26 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
27 | #include "xfs_btree.h" | 28 | #include "xfs_btree.h" |
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index a5862680db31..a45b030d4592 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
@@ -2222,6 +2222,204 @@ DEFINE_EVENT(xfs_btree_cur_class, name, \ | |||
2222 | DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys); | 2222 | DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys); |
2223 | DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range); | 2223 | DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range); |
2224 | 2224 | ||
2225 | /* deferred ops */ | ||
2226 | struct xfs_defer_pending; | ||
2227 | struct xfs_defer_intake; | ||
2228 | struct xfs_defer_ops; | ||
2229 | |||
2230 | DECLARE_EVENT_CLASS(xfs_defer_class, | ||
2231 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop), | ||
2232 | TP_ARGS(mp, dop), | ||
2233 | TP_STRUCT__entry( | ||
2234 | __field(dev_t, dev) | ||
2235 | __field(void *, dop) | ||
2236 | __field(bool, committed) | ||
2237 | __field(bool, low) | ||
2238 | ), | ||
2239 | TP_fast_assign( | ||
2240 | __entry->dev = mp ? mp->m_super->s_dev : 0; | ||
2241 | __entry->dop = dop; | ||
2242 | __entry->committed = dop->dop_committed; | ||
2243 | __entry->low = dop->dop_low; | ||
2244 | ), | ||
2245 | TP_printk("dev %d:%d ops %p committed %d low %d\n", | ||
2246 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2247 | __entry->dop, | ||
2248 | __entry->committed, | ||
2249 | __entry->low) | ||
2250 | ) | ||
2251 | #define DEFINE_DEFER_EVENT(name) \ | ||
2252 | DEFINE_EVENT(xfs_defer_class, name, \ | ||
2253 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop), \ | ||
2254 | TP_ARGS(mp, dop)) | ||
2255 | |||
2256 | DECLARE_EVENT_CLASS(xfs_defer_error_class, | ||
2257 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error), | ||
2258 | TP_ARGS(mp, dop, error), | ||
2259 | TP_STRUCT__entry( | ||
2260 | __field(dev_t, dev) | ||
2261 | __field(void *, dop) | ||
2262 | __field(bool, committed) | ||
2263 | __field(bool, low) | ||
2264 | __field(int, error) | ||
2265 | ), | ||
2266 | TP_fast_assign( | ||
2267 | __entry->dev = mp ? mp->m_super->s_dev : 0; | ||
2268 | __entry->dop = dop; | ||
2269 | __entry->committed = dop->dop_committed; | ||
2270 | __entry->low = dop->dop_low; | ||
2271 | __entry->error = error; | ||
2272 | ), | ||
2273 | TP_printk("dev %d:%d ops %p committed %d low %d err %d\n", | ||
2274 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2275 | __entry->dop, | ||
2276 | __entry->committed, | ||
2277 | __entry->low, | ||
2278 | __entry->error) | ||
2279 | ) | ||
2280 | #define DEFINE_DEFER_ERROR_EVENT(name) \ | ||
2281 | DEFINE_EVENT(xfs_defer_error_class, name, \ | ||
2282 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error), \ | ||
2283 | TP_ARGS(mp, dop, error)) | ||
2284 | |||
2285 | DECLARE_EVENT_CLASS(xfs_defer_pending_class, | ||
2286 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), | ||
2287 | TP_ARGS(mp, dfp), | ||
2288 | TP_STRUCT__entry( | ||
2289 | __field(dev_t, dev) | ||
2290 | __field(int, type) | ||
2291 | __field(void *, intent) | ||
2292 | __field(bool, committed) | ||
2293 | __field(int, nr) | ||
2294 | ), | ||
2295 | TP_fast_assign( | ||
2296 | __entry->dev = mp ? mp->m_super->s_dev : 0; | ||
2297 | __entry->type = dfp->dfp_type->type; | ||
2298 | __entry->intent = dfp->dfp_intent; | ||
2299 | __entry->committed = dfp->dfp_committed; | ||
2300 | __entry->nr = dfp->dfp_count; | ||
2301 | ), | ||
2302 | TP_printk("dev %d:%d optype %d intent %p committed %d nr %d\n", | ||
2303 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2304 | __entry->type, | ||
2305 | __entry->intent, | ||
2306 | __entry->committed, | ||
2307 | __entry->nr) | ||
2308 | ) | ||
2309 | #define DEFINE_DEFER_PENDING_EVENT(name) \ | ||
2310 | DEFINE_EVENT(xfs_defer_pending_class, name, \ | ||
2311 | TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), \ | ||
2312 | TP_ARGS(mp, dfp)) | ||
2313 | |||
2314 | DECLARE_EVENT_CLASS(xfs_phys_extent_deferred_class, | ||
2315 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
2316 | int type, xfs_agblock_t agbno, xfs_extlen_t len), | ||
2317 | TP_ARGS(mp, agno, type, agbno, len), | ||
2318 | TP_STRUCT__entry( | ||
2319 | __field(dev_t, dev) | ||
2320 | __field(xfs_agnumber_t, agno) | ||
2321 | __field(int, type) | ||
2322 | __field(xfs_agblock_t, agbno) | ||
2323 | __field(xfs_extlen_t, len) | ||
2324 | ), | ||
2325 | TP_fast_assign( | ||
2326 | __entry->dev = mp->m_super->s_dev; | ||
2327 | __entry->agno = agno; | ||
2328 | __entry->type = type; | ||
2329 | __entry->agbno = agbno; | ||
2330 | __entry->len = len; | ||
2331 | ), | ||
2332 | TP_printk("dev %d:%d op %d agno %u agbno %u len %u", | ||
2333 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2334 | __entry->type, | ||
2335 | __entry->agno, | ||
2336 | __entry->agbno, | ||
2337 | __entry->len) | ||
2338 | ); | ||
2339 | #define DEFINE_PHYS_EXTENT_DEFERRED_EVENT(name) \ | ||
2340 | DEFINE_EVENT(xfs_phys_extent_deferred_class, name, \ | ||
2341 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ | ||
2342 | int type, \ | ||
2343 | xfs_agblock_t bno, \ | ||
2344 | xfs_extlen_t len), \ | ||
2345 | TP_ARGS(mp, agno, type, bno, len)) | ||
2346 | |||
2347 | DECLARE_EVENT_CLASS(xfs_map_extent_deferred_class, | ||
2348 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
2349 | int op, | ||
2350 | xfs_agblock_t agbno, | ||
2351 | xfs_ino_t ino, | ||
2352 | int whichfork, | ||
2353 | xfs_fileoff_t offset, | ||
2354 | xfs_filblks_t len, | ||
2355 | xfs_exntst_t state), | ||
2356 | TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state), | ||
2357 | TP_STRUCT__entry( | ||
2358 | __field(dev_t, dev) | ||
2359 | __field(xfs_agnumber_t, agno) | ||
2360 | __field(xfs_ino_t, ino) | ||
2361 | __field(xfs_agblock_t, agbno) | ||
2362 | __field(int, whichfork) | ||
2363 | __field(xfs_fileoff_t, l_loff) | ||
2364 | __field(xfs_filblks_t, l_len) | ||
2365 | __field(xfs_exntst_t, l_state) | ||
2366 | __field(int, op) | ||
2367 | ), | ||
2368 | TP_fast_assign( | ||
2369 | __entry->dev = mp->m_super->s_dev; | ||
2370 | __entry->agno = agno; | ||
2371 | __entry->ino = ino; | ||
2372 | __entry->agbno = agbno; | ||
2373 | __entry->whichfork = whichfork; | ||
2374 | __entry->l_loff = offset; | ||
2375 | __entry->l_len = len; | ||
2376 | __entry->l_state = state; | ||
2377 | __entry->op = op; | ||
2378 | ), | ||
2379 | TP_printk("dev %d:%d op %d agno %u agbno %u owner %lld %s offset %llu len %llu state %d", | ||
2380 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2381 | __entry->op, | ||
2382 | __entry->agno, | ||
2383 | __entry->agbno, | ||
2384 | __entry->ino, | ||
2385 | __entry->whichfork == XFS_ATTR_FORK ? "attr" : "data", | ||
2386 | __entry->l_loff, | ||
2387 | __entry->l_len, | ||
2388 | __entry->l_state) | ||
2389 | ); | ||
2390 | #define DEFINE_MAP_EXTENT_DEFERRED_EVENT(name) \ | ||
2391 | DEFINE_EVENT(xfs_map_extent_deferred_class, name, \ | ||
2392 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \ | ||
2393 | int op, \ | ||
2394 | xfs_agblock_t agbno, \ | ||
2395 | xfs_ino_t ino, \ | ||
2396 | int whichfork, \ | ||
2397 | xfs_fileoff_t offset, \ | ||
2398 | xfs_filblks_t len, \ | ||
2399 | xfs_exntst_t state), \ | ||
2400 | TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state)) | ||
2401 | |||
2402 | DEFINE_DEFER_EVENT(xfs_defer_init); | ||
2403 | DEFINE_DEFER_EVENT(xfs_defer_cancel); | ||
2404 | DEFINE_DEFER_EVENT(xfs_defer_trans_roll); | ||
2405 | DEFINE_DEFER_EVENT(xfs_defer_trans_abort); | ||
2406 | DEFINE_DEFER_EVENT(xfs_defer_finish); | ||
2407 | DEFINE_DEFER_EVENT(xfs_defer_finish_done); | ||
2408 | |||
2409 | DEFINE_DEFER_ERROR_EVENT(xfs_defer_trans_roll_error); | ||
2410 | DEFINE_DEFER_ERROR_EVENT(xfs_defer_finish_error); | ||
2411 | DEFINE_DEFER_ERROR_EVENT(xfs_defer_op_finish_error); | ||
2412 | |||
2413 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_intake_work); | ||
2414 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_intake_cancel); | ||
2415 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_commit); | ||
2416 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_cancel); | ||
2417 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish); | ||
2418 | DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort); | ||
2419 | |||
2420 | DEFINE_PHYS_EXTENT_DEFERRED_EVENT(xfs_defer_phys_extent); | ||
2421 | DEFINE_MAP_EXTENT_DEFERRED_EVENT(xfs_defer_map_extent); | ||
2422 | |||
2225 | #endif /* _TRACE_XFS_H */ | 2423 | #endif /* _TRACE_XFS_H */ |
2226 | 2424 | ||
2227 | #undef TRACE_INCLUDE_PATH | 2425 | #undef TRACE_INCLUDE_PATH |