xfs: add attr state machine tracepoints
authorAllison Henderson <allison.henderson@oracle.com>
Sun, 8 Aug 2021 15:27:13 +0000 (08:27 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Aug 2021 23:16:40 +0000 (16:16 -0700)
This is a quick patch to add a new xfs_attr_*_return tracepoints.  We
use these to track when ever a new state is set or -EAGAIN is returned

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr_remote.c
fs/xfs/xfs_trace.h

index 191d517259889f37de9179a6ebf6ee5912800160..dec538d336d70f9577b352d74718bc5e11a31be3 100644 (file)
@@ -335,6 +335,7 @@ xfs_attr_sf_addname(
         * the attr fork to leaf format and will restart with the leaf
         * add.
         */
+       trace_xfs_attr_sf_addname_return(XFS_DAS_UNINIT, args->dp);
        dac->flags |= XFS_DAC_DEFER_FINISH;
        return -EAGAIN;
 }
@@ -394,6 +395,8 @@ xfs_attr_set_iter(
                                 * handling code below
                                 */
                                dac->flags |= XFS_DAC_DEFER_FINISH;
+                               trace_xfs_attr_set_iter_return(
+                                       dac->dela_state, args->dp);
                                return -EAGAIN;
                        } else if (error) {
                                return error;
@@ -411,6 +414,7 @@ xfs_attr_set_iter(
 
                        dac->dela_state = XFS_DAS_FOUND_NBLK;
                }
+               trace_xfs_attr_set_iter_return(dac->dela_state, args->dp);
                return -EAGAIN;
        case XFS_DAS_FOUND_LBLK:
                /*
@@ -438,6 +442,8 @@ xfs_attr_set_iter(
                        error = xfs_attr_rmtval_set_blk(dac);
                        if (error)
                                return error;
+                       trace_xfs_attr_set_iter_return(dac->dela_state,
+                                                      args->dp);
                        return -EAGAIN;
                }
 
@@ -472,6 +478,7 @@ xfs_attr_set_iter(
                 * series.
                 */
                dac->dela_state = XFS_DAS_FLIP_LFLAG;
+               trace_xfs_attr_set_iter_return(dac->dela_state, args->dp);
                return -EAGAIN;
        case XFS_DAS_FLIP_LFLAG:
                /*
@@ -489,10 +496,14 @@ xfs_attr_set_iter(
                dac->dela_state = XFS_DAS_RM_LBLK;
                if (args->rmtblkno) {
                        error = __xfs_attr_rmtval_remove(dac);
+                       if (error == -EAGAIN)
+                               trace_xfs_attr_set_iter_return(
+                                       dac->dela_state, args->dp);
                        if (error)
                                return error;
 
                        dac->dela_state = XFS_DAS_RD_LEAF;
+                       trace_xfs_attr_set_iter_return(dac->dela_state, args->dp);
                        return -EAGAIN;
                }
 
@@ -542,6 +553,8 @@ xfs_attr_set_iter(
                                error = xfs_attr_rmtval_set_blk(dac);
                                if (error)
                                        return error;
+                               trace_xfs_attr_set_iter_return(
+                                       dac->dela_state, args->dp);
                                return -EAGAIN;
                        }
 
@@ -577,6 +590,7 @@ xfs_attr_set_iter(
                 * series
                 */
                dac->dela_state = XFS_DAS_FLIP_NFLAG;
+               trace_xfs_attr_set_iter_return(dac->dela_state, args->dp);
                return -EAGAIN;
 
        case XFS_DAS_FLIP_NFLAG:
@@ -596,10 +610,15 @@ xfs_attr_set_iter(
                dac->dela_state = XFS_DAS_RM_NBLK;
                if (args->rmtblkno) {
                        error = __xfs_attr_rmtval_remove(dac);
+                       if (error == -EAGAIN)
+                               trace_xfs_attr_set_iter_return(
+                                       dac->dela_state, args->dp);
+
                        if (error)
                                return error;
 
                        dac->dela_state = XFS_DAS_CLR_FLAG;
+                       trace_xfs_attr_set_iter_return(dac->dela_state, args->dp);
                        return -EAGAIN;
                }
 
@@ -1176,6 +1195,8 @@ xfs_attr_node_addname(
                         * this point.
                         */
                        dac->flags |= XFS_DAC_DEFER_FINISH;
+                       trace_xfs_attr_node_addname_return(
+                                       dac->dela_state, args->dp);
                        return -EAGAIN;
                }
 
@@ -1422,10 +1443,13 @@ xfs_attr_remove_iter(
                         * blocks are removed.
                         */
                        error = __xfs_attr_rmtval_remove(dac);
-                       if (error == -EAGAIN)
+                       if (error == -EAGAIN) {
+                               trace_xfs_attr_remove_iter_return(
+                                               dac->dela_state, args->dp);
                                return error;
-                       else if (error)
+                       } else if (error) {
                                goto out;
+                       }
 
                        /*
                         * Refill the state structure with buffers (the prior
@@ -1438,6 +1462,7 @@ xfs_attr_remove_iter(
                                goto out;
                        dac->dela_state = XFS_DAS_RM_NAME;
                        dac->flags |= XFS_DAC_DEFER_FINISH;
+                       trace_xfs_attr_remove_iter_return(dac->dela_state, args->dp);
                        return -EAGAIN;
                }
 
@@ -1466,6 +1491,8 @@ xfs_attr_remove_iter(
 
                        dac->flags |= XFS_DAC_DEFER_FINISH;
                        dac->dela_state = XFS_DAS_RM_SHRINK;
+                       trace_xfs_attr_remove_iter_return(
+                                       dac->dela_state, args->dp);
                        return -EAGAIN;
                }
 
index 0c8bee3abc3b4937877ed058788029fb2de1cd30..70f880da563b991a7cd7b4e86317791a0a539072 100644 (file)
@@ -696,6 +696,7 @@ __xfs_attr_rmtval_remove(
         */
        if (!done) {
                dac->flags |= XFS_DAC_DEFER_FINISH;
+               trace_xfs_attr_rmtval_remove_return(dac->dela_state, args->dp);
                return -EAGAIN;
        }
 
index 36d771d00f7fa25d3a241abbeb960a8e2090834a..18a6e07f7dd4bf3c718b21208f5e2514fd88b8d6 100644 (file)
@@ -4073,6 +4073,30 @@ DEFINE_ICLOG_EVENT(xlog_iclog_want_sync);
 DEFINE_ICLOG_EVENT(xlog_iclog_wait_on);
 DEFINE_ICLOG_EVENT(xlog_iclog_write);
 
+DECLARE_EVENT_CLASS(xfs_das_state_class,
+       TP_PROTO(int das, struct xfs_inode *ip),
+       TP_ARGS(das, ip),
+       TP_STRUCT__entry(
+               __field(int, das)
+               __field(xfs_ino_t, ino)
+       ),
+       TP_fast_assign(
+               __entry->das = das;
+               __entry->ino = ip->i_ino;
+       ),
+       TP_printk("state change %d ino 0x%llx",
+                 __entry->das, __entry->ino)
+)
+
+#define DEFINE_DAS_STATE_EVENT(name) \
+DEFINE_EVENT(xfs_das_state_class, name, \
+       TP_PROTO(int das, struct xfs_inode *ip), \
+       TP_ARGS(das, ip))
+DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return);
+DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
+DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return);
+DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return);
+DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
 #endif /* _TRACE_XFS_H */
 
 #undef TRACE_INCLUDE_PATH