Merge tag 'lsk-v4.4-17.03-android' of git://git.linaro.org/kernel/linux-linaro-stable.git
[firefly-linux-kernel-4.4.55.git] / include / trace / events / android_fs_template.h
1 #if !defined(_TRACE_ANDROID_FS_TEMPLATE_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define _TRACE_ANDROID_FS_TEMPLATE_H
3
4 #include <linux/tracepoint.h>
5
6 DECLARE_EVENT_CLASS(android_fs_data_start_template,
7         TP_PROTO(struct inode *inode, loff_t offset, int bytes,
8                  pid_t pid, char *command),
9         TP_ARGS(inode, offset, bytes, pid, command),
10         TP_STRUCT__entry(
11                 __array(char, path, MAX_FILTER_STR_VAL);
12                 __field(char *, pathname);
13                 __field(loff_t, offset);
14                 __field(int,    bytes);
15                 __field(loff_t, i_size);
16                 __string(cmdline, command);
17                 __field(pid_t,  pid);
18                 __field(ino_t,  ino);
19         ),
20         TP_fast_assign(
21                 {
22                         struct dentry *d;
23
24                         /*
25                          * Grab a reference to the inode here because
26                          * d_obtain_alias() will either drop the inode
27                          * reference if it locates an existing dentry
28                          * or transfer the reference to the new dentry
29                          * created. In our case, the file is still open,
30                          * so the dentry is guaranteed to exist (connected),
31                          * so d_obtain_alias() drops the reference we
32                          * grabbed here.
33                          */
34                         ihold(inode);
35                         d = d_obtain_alias(inode);
36                         if (!IS_ERR(d)) {
37                                 __entry->pathname = dentry_path(d,
38                                                         __entry->path,
39                                                         MAX_FILTER_STR_VAL);
40                                 dput(d);
41                         } else
42                                 __entry->pathname = ERR_PTR(-EINVAL);
43                         __entry->offset         = offset;
44                         __entry->bytes          = bytes;
45                         __entry->i_size         = i_size_read(inode);
46                         __assign_str(cmdline, command);
47                         __entry->pid            = pid;
48                         __entry->ino            = inode->i_ino;
49                 }
50         ),
51         TP_printk("entry_name %s, offset %llu, bytes %d, cmdline %s,"
52                   " pid %d, i_size %llu, ino %lu",
53                   (IS_ERR(__entry->pathname) ? "ERROR" : __entry->pathname),
54                   __entry->offset, __entry->bytes, __get_str(cmdline),
55                   __entry->pid, __entry->i_size,
56                   (unsigned long) __entry->ino)
57 );
58
59 DECLARE_EVENT_CLASS(android_fs_data_end_template,
60         TP_PROTO(struct inode *inode, loff_t offset, int bytes),
61         TP_ARGS(inode, offset, bytes),
62         TP_STRUCT__entry(
63                 __field(ino_t,  ino);
64                 __field(loff_t, offset);
65                 __field(int,    bytes);
66         ),
67         TP_fast_assign(
68                 {
69                         __entry->ino            = inode->i_ino;
70                         __entry->offset         = offset;
71                         __entry->bytes          = bytes;
72                 }
73         ),
74         TP_printk("ino %lu, offset %llu, bytes %d",
75                   (unsigned long) __entry->ino,
76                   __entry->offset, __entry->bytes)
77 );
78
79 #endif /* _TRACE_ANDROID_FS_TEMPLATE_H */