Преглед изворни кода

xfs: trace log reservations at mount time

At each mount, emit the transaction reservation type information via
tracepoints.  This makes it easier to compare the log reservation info
calculated by the kernel and xfsprogs so that we can more easily diagnose
minimum log size failures on freshly formatted filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Darrick J. Wong пре 7 година
родитељ
комит
b872af2c87
4 измењених фајлова са 52 додато и 1 уклоњено
  1. 1 1
      fs/xfs/libxfs/xfs_log_rlimit.c
  2. 3 0
      fs/xfs/libxfs/xfs_shared.h
  3. 26 0
      fs/xfs/xfs_trace.h
  4. 22 0
      fs/xfs/xfs_trans.c

+ 1 - 1
fs/xfs/libxfs/xfs_log_rlimit.c

@@ -55,7 +55,7 @@ xfs_log_calc_max_attrsetm_res(
  * the maximum one in terms of the pre-calculated values which were done
  * the maximum one in terms of the pre-calculated values which were done
  * at mount time.
  * at mount time.
  */
  */
-STATIC void
+void
 xfs_log_get_max_trans_res(
 xfs_log_get_max_trans_res(
 	struct xfs_mount	*mp,
 	struct xfs_mount	*mp,
 	struct xfs_trans_res	*max_resp)
 	struct xfs_trans_res	*max_resp)

+ 3 - 0
fs/xfs/libxfs/xfs_shared.h

@@ -76,6 +76,9 @@ struct xfs_log_item_desc {
 int	xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
 int	xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
 int	xfs_log_calc_minimum_size(struct xfs_mount *);
 int	xfs_log_calc_minimum_size(struct xfs_mount *);
 
 
+struct xfs_trans_res;
+void	xfs_log_get_max_trans_res(struct xfs_mount *mp,
+				  struct xfs_trans_res *max_resp);
 
 
 /*
 /*
  * Values for t_flags.
  * Values for t_flags.

+ 26 - 0
fs/xfs/xfs_trace.h

@@ -3313,6 +3313,32 @@ DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
 
 
+TRACE_EVENT(xfs_trans_resv_calc,
+	TP_PROTO(struct xfs_mount *mp, unsigned int type,
+		 struct xfs_trans_res *res),
+	TP_ARGS(mp, type, res),
+	TP_STRUCT__entry(
+		__field(dev_t, dev)
+		__field(int, type)
+		__field(uint, logres)
+		__field(int, logcount)
+		__field(int, logflags)
+	),
+	TP_fast_assign(
+		__entry->dev = mp->m_super->s_dev;
+		__entry->type = type;
+		__entry->logres = res->tr_logres;
+		__entry->logcount = res->tr_logcount;
+		__entry->logflags = res->tr_logflags;
+	),
+	TP_printk("dev %d:%d type %d logres %u logcount %d flags 0x%x",
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		  __entry->type,
+		  __entry->logres,
+		  __entry->logcount,
+		  __entry->logflags)
+);
+
 #endif /* _TRACE_XFS_H */
 #endif /* _TRACE_XFS_H */
 
 
 #undef TRACE_INCLUDE_PATH
 #undef TRACE_INCLUDE_PATH

+ 22 - 0
fs/xfs/xfs_trans.c

@@ -35,6 +35,27 @@
 kmem_zone_t	*xfs_trans_zone;
 kmem_zone_t	*xfs_trans_zone;
 kmem_zone_t	*xfs_log_item_desc_zone;
 kmem_zone_t	*xfs_log_item_desc_zone;
 
 
+#if defined(CONFIG_TRACEPOINTS)
+static void
+xfs_trans_trace_reservations(
+	struct xfs_mount	*mp)
+{
+	struct xfs_trans_res	resv;
+	struct xfs_trans_res	*res;
+	struct xfs_trans_res	*end_res;
+	int			i;
+
+	res = (struct xfs_trans_res *)M_RES(mp);
+	end_res = (struct xfs_trans_res *)(M_RES(mp) + 1);
+	for (i = 0; res < end_res; i++, res++)
+		trace_xfs_trans_resv_calc(mp, i, res);
+	xfs_log_get_max_trans_res(mp, &resv);
+	trace_xfs_trans_resv_calc(mp, -1, &resv);
+}
+#else
+# define xfs_trans_trace_reservations(mp)
+#endif
+
 /*
 /*
  * Initialize the precomputed transaction reservation values
  * Initialize the precomputed transaction reservation values
  * in the mount structure.
  * in the mount structure.
@@ -44,6 +65,7 @@ xfs_trans_init(
 	struct xfs_mount	*mp)
 	struct xfs_mount	*mp)
 {
 {
 	xfs_trans_resv_calc(mp, M_RES(mp));
 	xfs_trans_resv_calc(mp, M_RES(mp));
+	xfs_trans_trace_reservations(mp);
 }
 }
 
 
 /*
 /*