f2fs: add tracepoints for sync & inode operations
authorNamjae Jeon <namjae.jeon@samsung.com>
Fri, 19 Apr 2013 16:28:40 +0000 (01:28 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 23 Apr 2013 06:30:27 +0000 (15:30 +0900)
Add tracepoints in f2fs for tracing the syncing
operations like filesystem sync, file sync enter/exit.
It will helf to trace the code under debugging scenarios.

Also add tracepoints for tracing the various inode operations
like building inode, eviction of inode, link/unlike of
inodes.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Pankaj Kumar <pankaj.km@samsung.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
[Jaegeuk: combine and modify the tracepoint structures]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/file.c
fs/f2fs/inode.c
fs/f2fs/namei.c
fs/f2fs/super.c
include/trace/events/f2fs.h [new file with mode: 0644]

index 07be88ddb9f8025df9d125ec24f7614ef2c58962..0b0ba26ba76e1b6137b04ec2960d121e9b013f09 100644 (file)
@@ -25,6 +25,7 @@
 #include "segment.h"
 #include "xattr.h"
 #include "acl.h"
+#include <trace/events/f2fs.h>
 
 static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
                                                struct vm_fault *vmf)
@@ -116,9 +117,12 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
        if (inode->i_sb->s_flags & MS_RDONLY)
                return 0;
 
+       trace_f2fs_sync_file_enter(inode);
        ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
-       if (ret)
+       if (ret) {
+               trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
                return ret;
+       }
 
        /* guarantee free sections for fsync */
        f2fs_balance_fs(sbi);
@@ -153,6 +157,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
        }
 out:
        mutex_unlock(&inode->i_mutex);
+       trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
        return ret;
 }
 
index 60105b710958d0820a82c708b0c867747ee09cf1..91ac7f9d88eeaf84a86f38bb07866095910d8620 100644 (file)
@@ -16,6 +16,8 @@
 #include "f2fs.h"
 #include "node.h"
 
+#include <trace/events/f2fs.h>
+
 void f2fs_set_inode_flags(struct inode *inode)
 {
        unsigned int flags = F2FS_I(inode)->i_flags;
@@ -91,13 +93,16 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
 {
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
        struct inode *inode;
-       int ret;
+       int ret = 0;
 
        inode = iget_locked(sb, ino);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+
+       if (!(inode->i_state & I_NEW)) {
+               trace_f2fs_iget(inode);
                return inode;
+       }
        if (ino == F2FS_NODE_INO(sbi) || ino == F2FS_META_INO(sbi))
                goto make_now;
 
@@ -139,11 +144,12 @@ make_now:
                goto bad_inode;
        }
        unlock_new_inode(inode);
-
+       trace_f2fs_iget(inode);
        return inode;
 
 bad_inode:
        iget_failed(inode);
+       trace_f2fs_iget_exit(inode, ret);
        return ERR_PTR(ret);
 }
 
@@ -239,6 +245,7 @@ void f2fs_evict_inode(struct inode *inode)
        struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
        int ilock;
 
+       trace_f2fs_evict_inode(inode);
        truncate_inode_pages(&inode->i_data, 0);
 
        if (inode->i_ino == F2FS_NODE_INO(sbi) ||
index 1dbf11d2bc879de70a4764ceea397ea01cdd9a0a..c57fd18b769d00b973ba13eb90e53c49137206b9 100644 (file)
@@ -18,6 +18,7 @@
 #include "node.h"
 #include "xattr.h"
 #include "acl.h"
+#include <trace/events/f2fs.h>
 
 static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
 {
@@ -235,6 +236,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
        int err = -ENOENT;
        int ilock;
 
+       trace_f2fs_unlink_enter(dir, dentry);
        f2fs_balance_fs(sbi);
 
        de = f2fs_find_entry(dir, &dentry->d_name, &page);
@@ -255,6 +257,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
        /* In order to evict this inode,  we set it dirty */
        mark_inode_dirty(inode);
 fail:
+       trace_f2fs_unlink_exit(inode, err);
        return err;
 }
 
index 541f21ffd8f21bb33ee520dc4f3da9996111cd75..b015b6cd7bd4f59af8b22600fc407347ce46a3a8 100644 (file)
@@ -29,6 +29,9 @@
 #include "segment.h"
 #include "xattr.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/f2fs.h>
+
 static struct kmem_cache *f2fs_inode_cachep;
 
 enum {
@@ -134,6 +137,8 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
 {
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
 
+       trace_f2fs_sync_fs(sb, sync);
+
        if (!sbi->s_dirty && !get_pages(sbi, F2FS_DIRTY_NODES))
                return 0;
 
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
new file mode 100644 (file)
index 0000000..03bb0db
--- /dev/null
@@ -0,0 +1,195 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM f2fs
+
+#if !defined(_TRACE_F2FS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_F2FS_H
+
+#include <linux/tracepoint.h>
+
+#define show_dev(entry)                MAJOR(entry->dev), MINOR(entry->dev)
+#define show_dev_ino(entry)    show_dev(entry), (unsigned long)entry->ino
+
+DECLARE_EVENT_CLASS(f2fs__inode,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(dev_t,  dev)
+               __field(ino_t,  ino)
+               __field(ino_t,  pino)
+               __field(umode_t, mode)
+               __field(loff_t, size)
+               __field(unsigned int, nlink)
+               __field(blkcnt_t, blocks)
+               __field(__u8,   advise)
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pino   = F2FS_I(inode)->i_pino;
+               __entry->mode   = inode->i_mode;
+               __entry->nlink  = inode->i_nlink;
+               __entry->size   = inode->i_size;
+               __entry->blocks = inode->i_blocks;
+               __entry->advise = F2FS_I(inode)->i_advise;
+       ),
+
+       TP_printk("dev = (%d,%d), ino = %lu, pino = %lu, i_mode = 0x%hx, "
+               "i_size = %lld, i_nlink = %u, i_blocks = %llu, i_advise = 0x%x",
+               show_dev_ino(__entry),
+               (unsigned long)__entry->pino,
+               __entry->mode,
+               __entry->size,
+               (unsigned int)__entry->nlink,
+               (unsigned long long)__entry->blocks,
+               (unsigned char)__entry->advise)
+);
+
+DECLARE_EVENT_CLASS(f2fs__inode_exit,
+
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret),
+
+       TP_STRUCT__entry(
+               __field(dev_t,  dev)
+               __field(ino_t,  ino)
+               __field(int,    ret)
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev = (%d,%d), ino = %lu, ret = %d",
+               show_dev_ino(__entry),
+               __entry->ret)
+);
+
+DEFINE_EVENT(f2fs__inode, f2fs_sync_file_enter,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+TRACE_EVENT(f2fs_sync_file_exit,
+
+       TP_PROTO(struct inode *inode, bool need_cp, int datasync, int ret),
+
+       TP_ARGS(inode, need_cp, datasync, ret),
+
+       TP_STRUCT__entry(
+               __field(dev_t,  dev)
+               __field(ino_t,  ino)
+               __field(bool,   need_cp)
+               __field(int,    datasync)
+               __field(int,    ret)
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->need_cp        = need_cp;
+               __entry->datasync       = datasync;
+               __entry->ret            = ret;
+       ),
+
+       TP_printk("dev = (%d,%d), ino = %lu, checkpoint is %s, "
+               "datasync = %d, ret = %d",
+               show_dev_ino(__entry),
+               __entry->need_cp ? "needed" : "not needed",
+               __entry->datasync,
+               __entry->ret)
+);
+
+TRACE_EVENT(f2fs_sync_fs,
+
+       TP_PROTO(struct super_block *sb, int wait),
+
+       TP_ARGS(sb, wait),
+
+       TP_STRUCT__entry(
+               __field(dev_t,  dev)
+               __field(int,    dirty)
+               __field(int,    wait)
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->dirty  = F2FS_SB(sb)->s_dirty;
+               __entry->wait   = wait;
+       ),
+
+       TP_printk("dev = (%d,%d), superblock is %s, wait = %d",
+               show_dev(__entry),
+               __entry->dirty ? "dirty" : "not dirty",
+               __entry->wait)
+);
+
+DEFINE_EVENT(f2fs__inode, f2fs_iget,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+DEFINE_EVENT(f2fs__inode_exit, f2fs_iget_exit,
+
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret)
+);
+
+DEFINE_EVENT(f2fs__inode, f2fs_evict_inode,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+TRACE_EVENT(f2fs_unlink_enter,
+
+       TP_PROTO(struct inode *dir, struct dentry *dentry),
+
+       TP_ARGS(dir, dentry),
+
+       TP_STRUCT__entry(
+               __field(dev_t,  dev)
+               __field(ino_t,  ino)
+               __field(loff_t, size)
+               __field(blkcnt_t, blocks)
+               __field(const char *,   name)
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = dir->i_sb->s_dev;
+               __entry->ino    = dir->i_ino;
+               __entry->size   = dir->i_size;
+               __entry->blocks = dir->i_blocks;
+               __entry->name   = dentry->d_name.name;
+       ),
+
+       TP_printk("dev = (%d,%d), dir ino = %lu, i_size = %lld, "
+               "i_blocks = %llu, name = %s",
+               show_dev_ino(__entry),
+               __entry->size,
+               (unsigned long long)__entry->blocks,
+               __entry->name)
+);
+
+DEFINE_EVENT(f2fs__inode_exit, f2fs_unlink_exit,
+
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret)
+);
+#endif /* _TRACE_F2FS_H */
+
+ /* This part must be outside protection */
+#include <trace/define_trace.h>