summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2017-04-18 13:56:54 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-04-18 13:56:54 -0700
commita4da2aadd98caaddf3e4b3045abc20de1afd68ac (patch)
treee21713819772980e0ea3adf3d9eeee3853edc595 /include
parent74cf65d68c9f1920e3308e5fdd05f3161df84c6b (diff)
parent4918990f6bf31e270f437fab434f379cef1cd77f (diff)
Merge "ANDROID: Refactor fs readpage/write tracepoints."
Diffstat (limited to 'include')
-rw-r--r--include/trace/events/android_fs.h44
-rw-r--r--include/trace/events/android_fs_template.h34
2 files changed, 45 insertions, 33 deletions
diff --git a/include/trace/events/android_fs.h b/include/trace/events/android_fs.h
index 531da433a7bc..49509533d3fa 100644
--- a/include/trace/events/android_fs.h
+++ b/include/trace/events/android_fs.h
@@ -9,8 +9,8 @@
DEFINE_EVENT(android_fs_data_start_template, android_fs_dataread_start,
TP_PROTO(struct inode *inode, loff_t offset, int bytes,
- pid_t pid, char *command),
- TP_ARGS(inode, offset, bytes, pid, command));
+ pid_t pid, char *pathname, char *command),
+ TP_ARGS(inode, offset, bytes, pid, pathname, command));
DEFINE_EVENT(android_fs_data_end_template, android_fs_dataread_end,
TP_PROTO(struct inode *inode, loff_t offset, int bytes),
@@ -18,14 +18,48 @@ DEFINE_EVENT(android_fs_data_end_template, android_fs_dataread_end,
DEFINE_EVENT(android_fs_data_start_template, android_fs_datawrite_start,
TP_PROTO(struct inode *inode, loff_t offset, int bytes,
- pid_t pid, char *command),
- TP_ARGS(inode, offset, bytes, pid, command));
+ pid_t pid, char *pathname, char *command),
+ TP_ARGS(inode, offset, bytes, pid, pathname, command));
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));
+ TP_ARGS(inode, offset, bytes));
#endif /* _TRACE_ANDROID_FS_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+
+#ifndef ANDROID_FSTRACE_GET_PATHNAME
+#define ANDROID_FSTRACE_GET_PATHNAME
+
+/* Sizes an on-stack array, so careful if sizing this up ! */
+#define MAX_TRACE_PATHBUF_LEN 256
+
+static inline char *
+android_fstrace_get_pathname(char *buf, int buflen, struct inode *inode)
+{
+ char *path;
+ struct dentry *d;
+
+ /*
+ * d_obtain_alias() will either iput() if it locates an existing
+ * dentry or transfer the reference to the new dentry created.
+ * So get an extra reference here.
+ */
+ ihold(inode);
+ d = d_obtain_alias(inode);
+ if (likely(!IS_ERR(d))) {
+ path = dentry_path_raw(d, buf, buflen);
+ if (unlikely(IS_ERR(path))) {
+ strcpy(buf, "ERROR");
+ path = buf;
+ }
+ dput(d);
+ } else {
+ strcpy(buf, "ERROR");
+ path = buf;
+ }
+ return path;
+}
+#endif
diff --git a/include/trace/events/android_fs_template.h b/include/trace/events/android_fs_template.h
index 618988b047c1..4e61ffe7a814 100644
--- a/include/trace/events/android_fs_template.h
+++ b/include/trace/events/android_fs_template.h
@@ -5,11 +5,10 @@
DECLARE_EVENT_CLASS(android_fs_data_start_template,
TP_PROTO(struct inode *inode, loff_t offset, int bytes,
- pid_t pid, char *command),
- TP_ARGS(inode, offset, bytes, pid, command),
+ pid_t pid, char *pathname, char *command),
+ TP_ARGS(inode, offset, bytes, pid, pathname, command),
TP_STRUCT__entry(
- __array(char, path, MAX_FILTER_STR_VAL);
- __field(char *, pathname);
+ __string(pathbuf, pathname);
__field(loff_t, offset);
__field(int, bytes);
__field(loff_t, i_size);
@@ -19,27 +18,7 @@ DECLARE_EVENT_CLASS(android_fs_data_start_template,
),
TP_fast_assign(
{
- struct dentry *d;
-
- /*
- * Grab a reference to the inode here because
- * d_obtain_alias() will either drop the inode
- * reference if it locates an existing dentry
- * or transfer the reference to the new dentry
- * created. In our case, the file is still open,
- * so the dentry is guaranteed to exist (connected),
- * so d_obtain_alias() drops the reference we
- * grabbed here.
- */
- ihold(inode);
- d = d_obtain_alias(inode);
- if (!IS_ERR(d)) {
- __entry->pathname = dentry_path(d,
- __entry->path,
- MAX_FILTER_STR_VAL);
- dput(d);
- } else
- __entry->pathname = ERR_PTR(-EINVAL);
+ __assign_str(pathbuf, pathname);
__entry->offset = offset;
__entry->bytes = bytes;
__entry->i_size = i_size_read(inode);
@@ -50,9 +29,8 @@ DECLARE_EVENT_CLASS(android_fs_data_start_template,
),
TP_printk("entry_name %s, offset %llu, bytes %d, cmdline %s,"
" pid %d, i_size %llu, ino %lu",
- (IS_ERR(__entry->pathname) ? "ERROR" : __entry->pathname),
- __entry->offset, __entry->bytes, __get_str(cmdline),
- __entry->pid, __entry->i_size,
+ __get_str(pathbuf), __entry->offset, __entry->bytes,
+ __get_str(cmdline), __entry->pid, __entry->i_size,
(unsigned long) __entry->ino)
);