Skip to content

Commit

Permalink
ANDROID: f2fs: add android fsync tracepoint
Browse files Browse the repository at this point in the history
Change-Id: Id7c23173f85a835a2294ee698597b7d60f1ee356
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Jaegeuk Kim committed Jul 15, 2019
1 parent ee0c93b commit 5e2c340
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "gc.h"
#include "trace.h"
#include <trace/events/f2fs.h>
#include <trace/events/android_fs.h>

static int f2fs_filemap_fault(struct vm_area_struct *vma,
struct vm_fault *vmf)
Expand Down Expand Up @@ -220,6 +221,15 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,

trace_f2fs_sync_file_enter(inode);

if (trace_android_fs_fsync_start_enabled()) {
char *path, pathbuf[MAX_TRACE_PATHBUF_LEN];

path = android_fstrace_get_pathname(pathbuf,
MAX_TRACE_PATHBUF_LEN, inode);
trace_android_fs_fsync_start(inode,
current->pid, path, current->comm);
}

if (S_ISDIR(inode->i_mode))
goto go_write;

Expand Down Expand Up @@ -325,6 +335,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
out:
trace_f2fs_sync_file_exit(inode, cp_reason, datasync, ret);
f2fs_trace_ios(NULL, 1);
trace_android_fs_fsync_end(inode, start, end - start);

return ret;
}

Expand Down
9 changes: 9 additions & 0 deletions include/trace/events/android_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ DEFINE_EVENT(android_fs_data_end_template, android_fs_datawrite_end,
TP_PROTO(struct inode *inode, loff_t offset, int bytes),
TP_ARGS(inode, offset, bytes));

DEFINE_EVENT(android_fs_fsync_start_template, android_fs_fsync_start,
TP_PROTO(struct inode *inode,
pid_t pid, char *pathname, char *command),
TP_ARGS(inode, pid, pathname, command));

DEFINE_EVENT(android_fs_data_end_template, android_fs_fsync_end,
TP_PROTO(struct inode *inode, loff_t offset, int bytes),
TP_ARGS(inode, offset, bytes));

#endif /* _TRACE_ANDROID_FS_H */

/* This part must be outside protection */
Expand Down
34 changes: 34 additions & 0 deletions include/trace/events/android_fs_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,38 @@ DECLARE_EVENT_CLASS(android_fs_data_end_template,
__entry->offset, __entry->bytes)
);

DECLARE_EVENT_CLASS(android_fs_fsync_start_template,
TP_PROTO(struct inode *inode,
pid_t pid, char *pathname, char *command),
TP_ARGS(inode, pid, pathname, command),
TP_STRUCT__entry(
__string(pathbuf, pathname);
__field(loff_t, i_size);
__string(cmdline, command);
__field(pid_t, pid);
__field(ino_t, ino);
),
TP_fast_assign(
{
/*
* Replace the spaces in filenames and cmdlines
* because this screws up the tooling that parses
* the traces.
*/
__assign_str(pathbuf, pathname);
(void)strreplace(__get_str(pathbuf), ' ', '_');
__entry->i_size = i_size_read(inode);
__assign_str(cmdline, command);
(void)strreplace(__get_str(cmdline), ' ', '_');
__entry->pid = pid;
__entry->ino = inode->i_ino;
}
),
TP_printk("entry_name %s, cmdline %s,"
" pid %d, i_size %llu, ino %lu",
__get_str(pathbuf),
__get_str(cmdline), __entry->pid, __entry->i_size,
(unsigned long) __entry->ino)
);

#endif /* _TRACE_ANDROID_FS_TEMPLATE_H */

0 comments on commit 5e2c340

Please sign in to comment.