xfs: simplify the read/write tracepoints
authorChristoph Hellwig <hch@lst.de>
Sat, 23 Jan 2021 18:06:29 +0000 (10:06 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 1 Feb 2021 17:47:19 +0000 (09:47 -0800)
Pass the iocb and iov_iter to the tracepoints and leave decoding of
actual arguments to the code only run when tracing is enabled.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_file.c
fs/xfs/xfs_trace.h

index b38002ddfa6cfa3e50f774088b5108fbab9bf3f0..27b81925f92a31728e3361b376889af0c0ae527e 100644 (file)
@@ -220,12 +220,11 @@ xfs_file_dio_read(
        struct iov_iter         *to)
 {
        struct xfs_inode        *ip = XFS_I(file_inode(iocb->ki_filp));
-       size_t                  count = iov_iter_count(to);
        ssize_t                 ret;
 
-       trace_xfs_file_direct_read(ip, count, iocb->ki_pos);
+       trace_xfs_file_direct_read(iocb, to);
 
-       if (!count)
+       if (!iov_iter_count(to))
                return 0; /* skip atime */
 
        file_accessed(iocb->ki_filp);
@@ -245,12 +244,11 @@ xfs_file_dax_read(
        struct iov_iter         *to)
 {
        struct xfs_inode        *ip = XFS_I(iocb->ki_filp->f_mapping->host);
-       size_t                  count = iov_iter_count(to);
        ssize_t                 ret = 0;
 
-       trace_xfs_file_dax_read(ip, count, iocb->ki_pos);
+       trace_xfs_file_dax_read(iocb, to);
 
-       if (!count)
+       if (!iov_iter_count(to))
                return 0; /* skip atime */
 
        ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED);
@@ -271,7 +269,7 @@ xfs_file_buffered_read(
        struct xfs_inode        *ip = XFS_I(file_inode(iocb->ki_filp));
        ssize_t                 ret;
 
-       trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos);
+       trace_xfs_file_buffered_read(iocb, to);
 
        ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED);
        if (ret)
@@ -598,7 +596,7 @@ xfs_file_dio_write(
                iolock = XFS_IOLOCK_SHARED;
        }
 
-       trace_xfs_file_direct_write(ip, count, iocb->ki_pos);
+       trace_xfs_file_direct_write(iocb, from);
        /*
         * If unaligned, this is the only IO in-flight. Wait on it before we
         * release the iolock to prevent subsequent overlapping IO.
@@ -621,7 +619,6 @@ xfs_file_dax_write(
        struct xfs_inode        *ip = XFS_I(inode);
        int                     iolock = XFS_IOLOCK_EXCL;
        ssize_t                 ret, error = 0;
-       size_t                  count;
        loff_t                  pos;
 
        ret = xfs_ilock_iocb(iocb, iolock);
@@ -632,9 +629,8 @@ xfs_file_dax_write(
                goto out;
 
        pos = iocb->ki_pos;
-       count = iov_iter_count(from);
 
-       trace_xfs_file_dax_write(ip, count, pos);
+       trace_xfs_file_dax_write(iocb, from);
        ret = dax_iomap_rw(iocb, from, &xfs_direct_write_iomap_ops);
        if (ret > 0 && iocb->ki_pos > i_size_read(inode)) {
                i_size_write(inode, iocb->ki_pos);
@@ -682,7 +678,7 @@ write_retry:
        /* We can write back this queue in page reclaim */
        current->backing_dev_info = inode_to_bdi(inode);
 
-       trace_xfs_file_buffered_write(ip, iov_iter_count(from), iocb->ki_pos);
+       trace_xfs_file_buffered_write(iocb, from);
        ret = iomap_file_buffered_write(iocb, from,
                        &xfs_buffered_write_iomap_ops);
        if (likely(ret >= 0))
index 5a263ae3d4f00890d6c67ed240d954afb9c36461..a6d04d860a565eb4556c065762843a62fbc6ef04 100644 (file)
@@ -1287,8 +1287,8 @@ TRACE_EVENT(xfs_log_assign_tail_lsn,
 )
 
 DECLARE_EVENT_CLASS(xfs_file_class,
-       TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset),
-       TP_ARGS(ip, count, offset),
+       TP_PROTO(struct kiocb *iocb, struct iov_iter *iter),
+       TP_ARGS(iocb, iter),
        TP_STRUCT__entry(
                __field(dev_t, dev)
                __field(xfs_ino_t, ino)
@@ -1297,11 +1297,11 @@ DECLARE_EVENT_CLASS(xfs_file_class,
                __field(size_t, count)
        ),
        TP_fast_assign(
-               __entry->dev = VFS_I(ip)->i_sb->s_dev;
-               __entry->ino = ip->i_ino;
-               __entry->size = ip->i_d.di_size;
-               __entry->offset = offset;
-               __entry->count = count;
+               __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
+               __entry->ino = XFS_I(file_inode(iocb->ki_filp))->i_ino;
+               __entry->size = XFS_I(file_inode(iocb->ki_filp))->i_d.di_size;
+               __entry->offset = iocb->ki_pos;
+               __entry->count = iov_iter_count(iter);
        ),
        TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx count 0x%zx",
                  MAJOR(__entry->dev), MINOR(__entry->dev),
@@ -1313,8 +1313,8 @@ DECLARE_EVENT_CLASS(xfs_file_class,
 
 #define DEFINE_RW_EVENT(name)          \
 DEFINE_EVENT(xfs_file_class, name,     \
-       TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset),    \
-       TP_ARGS(ip, count, offset))
+       TP_PROTO(struct kiocb *iocb, struct iov_iter *iter),            \
+       TP_ARGS(iocb, iter))
 DEFINE_RW_EVENT(xfs_file_buffered_read);
 DEFINE_RW_EVENT(xfs_file_direct_read);
 DEFINE_RW_EVENT(xfs_file_dax_read);