linux-stable/fs/ext2/trace.h
Ritesh Harjani (IBM) 6e335cd789 ext2: Add direct-io trace points
This patch adds the trace point to ext2 direct-io apis
in fs/ext2/file.c

Here is how the output looks like

        a.out-467865 [006]  6758.170968: ext2_dio_write_begin: dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT|WRITE aio 1 ret 0
        a.out-467865 [006]  6758.171061: ext2_dio_write_end:   dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 0 flags DIRECT|WRITE aio 1 ret -529
kworker/3:153-444162 [003]  6758.171252: ext2_dio_write_endio: dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT|WRITE aio 1 ret 0
        a.out-468222 [001]  6761.628924: ext2_dio_read_begin:  dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT aio 1 ret 0
        a.out-468222 [001]  6761.629063: ext2_dio_read_end:    dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 0 flags DIRECT aio 1 ret -529
        a.out-468428 [005]  6763.937454: ext2_dio_write_begin: dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT aio 0 ret 0
        a.out-468428 [005]  6763.937829: ext2_dio_write_endio: dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT aio 0 ret 0
        a.out-468428 [005]  6763.937847: ext2_dio_write_end:   dev 7:12 ino 0xe isize 0x1000 pos 0x1000 len 0 flags DIRECT aio 0 ret 4096
        a.out-468609 [000]  6765.702878: ext2_dio_read_begin:  dev 7:12 ino 0xe isize 0x1000 pos 0x0 len 4096 flags DIRECT aio 0 ret 0
        a.out-468609 [000]  6765.703243: ext2_dio_read_end:    dev 7:12 ino 0xe isize 0x1000 pos 0x1000 len 0 flags DIRECT aio 0 ret 4096

Reported-and-tested-by: Disha Goel <disgoel@linux.ibm.com>
[Need to add CFLAGS_trace for fixing unable to find trace file problem]
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <b8b0897fa2b273a448d7b4ba7317357ac73c08bc.1682069716.git.ritesh.list@gmail.com>
2023-05-16 11:32:42 +02:00

94 lines
2.7 KiB
C

// SPDX-License-Identifier: GPL-2.0
#undef TRACE_SYSTEM
#define TRACE_SYSTEM ext2
#if !defined(_EXT2_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _EXT2_TRACE_H
#include <linux/tracepoint.h>
DECLARE_EVENT_CLASS(ext2_dio_class,
TP_PROTO(struct kiocb *iocb, struct iov_iter *iter, ssize_t ret),
TP_ARGS(iocb, iter, ret),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(ino_t, ino)
__field(loff_t, isize)
__field(loff_t, pos)
__field(size_t, count)
__field(int, ki_flags)
__field(bool, aio)
__field(ssize_t, ret)
),
TP_fast_assign(
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
__entry->isize = file_inode(iocb->ki_filp)->i_size;
__entry->pos = iocb->ki_pos;
__entry->count = iov_iter_count(iter);
__entry->ki_flags = iocb->ki_flags;
__entry->aio = !is_sync_kiocb(iocb);
__entry->ret = ret;
),
TP_printk("dev %d:%d ino 0x%lx isize 0x%llx pos 0x%llx len %zu flags %s aio %d ret %zd",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino,
__entry->isize,
__entry->pos,
__entry->count,
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
__entry->aio,
__entry->ret)
);
#define DEFINE_DIO_RW_EVENT(name) \
DEFINE_EVENT(ext2_dio_class, name, \
TP_PROTO(struct kiocb *iocb, struct iov_iter *iter, ssize_t ret), \
TP_ARGS(iocb, iter, ret))
DEFINE_DIO_RW_EVENT(ext2_dio_write_begin);
DEFINE_DIO_RW_EVENT(ext2_dio_write_end);
DEFINE_DIO_RW_EVENT(ext2_dio_write_buff_end);
DEFINE_DIO_RW_EVENT(ext2_dio_read_begin);
DEFINE_DIO_RW_EVENT(ext2_dio_read_end);
TRACE_EVENT(ext2_dio_write_endio,
TP_PROTO(struct kiocb *iocb, ssize_t size, int ret),
TP_ARGS(iocb, size, ret),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(ino_t, ino)
__field(loff_t, isize)
__field(loff_t, pos)
__field(ssize_t, size)
__field(int, ki_flags)
__field(bool, aio)
__field(int, ret)
),
TP_fast_assign(
__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
__entry->ino = file_inode(iocb->ki_filp)->i_ino;
__entry->isize = file_inode(iocb->ki_filp)->i_size;
__entry->pos = iocb->ki_pos;
__entry->size = size;
__entry->ki_flags = iocb->ki_flags;
__entry->aio = !is_sync_kiocb(iocb);
__entry->ret = ret;
),
TP_printk("dev %d:%d ino 0x%lx isize 0x%llx pos 0x%llx len %zd flags %s aio %d ret %d",
MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino,
__entry->isize,
__entry->pos,
__entry->size,
__print_flags(__entry->ki_flags, "|", TRACE_IOCB_STRINGS),
__entry->aio,
__entry->ret)
);
#endif /* _EXT2_TRACE_H */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE trace
#include <trace/define_trace.h>