Skip to content

xfs: enums don't work with __print_symbolic

Dave Chinner linux-xfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3xfs: make iomap type tracing workfs/xfs/xfs_aops.h+5 -70 replies
2/3xfs: remove xfs_lookup_t enum because tracingfs/xfs/libxfs/xfs_btree.c fs/xfs/libxfs/xfs_btree.h fs/xfs/libxfs/xfs_ialloc.c +3 more+10 -140 replies
3/3xfs: remove xfs_extst_t enum because tracingfs/xfs/libxfs/xfs_bmap.c fs/xfs/libxfs/xfs_bmap.h fs/xfs/libxfs/xfs_rmap.c +8 more+21 -220 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] xfs: enums don't work with __print_symbolic

Hi folks,

When trying to read traces from fsx failurs, I kept coming across fields in the traces that had no output what-so-ever. The common theme was that they all were tables that were parsed by __print_symbolic() and the value definitions were enums.

Unfortunately, __print_symbolic() does some crazy stuff involving stringification of the table that is passed to it, which means the enums are turned into strings and so their never get treated as enums after pre-processing. The result is a format string that looks like:

# cat /sys/kernel/debug/tracing/events/xfs/xfs_iomap_alloc/format
.....
print fmt: ..... __print_symbolic(REC->type, { XFS_IO_INVALID, "invalid" }, { XFS_IO_DELALLOC, "delalloc" }, { XFS_IO_UNWRITTEN, "unwritten" }, { XFS_IO_OVERWRITE, "overwrite" }, { XFS_IO_COW, "CoW" }, { XFS_IO_HOLE, "hole" }), ....
#

And, well, XFS_IO_OVERWRITE is a string, not an integer value of 3. Hence __print_symbolic never prints out the correct value.

The way to fix this is to turn all the enums into defined macros, that way the preprocessor still substitutes the value for the stringified table as the it does string matches. The result is:

__print_symbolic(REC->type, { 0, "hole" }, { 1, "delalloc" }, { 2, "unwritten" }, { 3, "overwrite" }, { 4, "CoW" })

And the trace events now print the type correctly in the trace.

This series fixes the cases I noticed by removing the various enums that end up in trace format tables.

Cheers,

Dave.