From a9da40de25f45f7ec15680b9136173598e85a339 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 10 Aug 2016 11:35:59 +1000 Subject: [PATCH] xfs: add tracepoints and error injection for deferred extent freeing Source kernel commit: ba9e780246a15a35f8ebe5b60f4a11bb58e85bda Add a couple of tracepoints for the deferred extent free operation and a site for injecting errors while finishing the operation. This makes it easier to debug deferred ops and test log redo. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- include/xfs_trace.h | 3 +++ libxfs/xfs_alloc.c | 7 +++++++ libxfs/xfs_bmap.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index 4de187ef0..aa0323289 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -188,4 +188,7 @@ #define trace_xfs_defer_finish_error(a,b,c) ((void) 0) #define trace_xfs_defer_finish_done(a,b) ((void) 0) +#define trace_xfs_bmap_free_defer(a,b,c,d,e) ((void) 0) +#define trace_xfs_bmap_free_deferred(a,b,c,d,e) ((void) 0) + #endif /* __TRACE_H__ */ diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index f2d50863b..1a473b196 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -2699,6 +2699,13 @@ xfs_free_extent( ASSERT(len != 0); + trace_xfs_bmap_free_deferred(mp, agno, 0, agbno, len); + + if (XFS_TEST_ERROR(false, mp, + XFS_ERRTAG_FREE_EXTENT, + XFS_RANDOM_FREE_EXTENT)) + return -EIO; + error = xfs_free_extent_fix_freelist(tp, agno, &agbp); if (error) return error; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index ebb3f6dc2..a4a6ae62b 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -588,6 +588,8 @@ xfs_bmap_add_free( new = kmem_zone_alloc(xfs_bmap_free_item_zone, KM_SLEEP); new->xefi_startblock = bno; new->xefi_blockcount = (xfs_extlen_t)len; + trace_xfs_bmap_free_defer(mp, XFS_FSB_TO_AGNO(mp, bno), 0, + XFS_FSB_TO_AGBNO(mp, bno), len); xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list); } -- 2.50.1