1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Events for filesystem locks 4 * 5 * Copyright 2013 Jeff Layton <jlayton@poochiereds.net> 6 */ 7 #undef TRACE_SYSTEM 8 #define TRACE_SYSTEM filelock 9 10 #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ) 11 #define _TRACE_FILELOCK_H 12 13 #include <linux/tracepoint.h> 14 #include <linux/fs.h> 15 #include <linux/device.h> 16 #include <linux/kdev_t.h> 17 18 #define show_fl_flags(val) \ 19 __print_flags(val, "|", \ 20 { FL_POSIX, "FL_POSIX" }, \ 21 { FL_FLOCK, "FL_FLOCK" }, \ 22 { FL_DELEG, "FL_DELEG" }, \ 23 { FL_ACCESS, "FL_ACCESS" }, \ 24 { FL_EXISTS, "FL_EXISTS" }, \ 25 { FL_LEASE, "FL_LEASE" }, \ 26 { FL_CLOSE, "FL_CLOSE" }, \ 27 { FL_SLEEP, "FL_SLEEP" }, \ 28 { FL_DOWNGRADE_PENDING, "FL_DOWNGRADE_PENDING" }, \ 29 { FL_UNLOCK_PENDING, "FL_UNLOCK_PENDING" }, \ 30 { FL_OFDLCK, "FL_OFDLCK" }) 31 32 #define show_fl_type(val) \ 33 __print_symbolic(val, \ 34 { F_RDLCK, "F_RDLCK" }, \ 35 { F_WRLCK, "F_WRLCK" }, \ 36 { F_UNLCK, "F_UNLCK" }) 37 38 TRACE_EVENT(locks_get_lock_context, 39 TP_PROTO(struct inode *inode, int type, struct file_lock_context *ctx), 40 41 TP_ARGS(inode, type, ctx), 42 43 TP_STRUCT__entry( 44 __field(unsigned long, i_ino) 45 __field(dev_t, s_dev) 46 __field(unsigned char, type) 47 __field(struct file_lock_context *, ctx) 48 ), 49 50 TP_fast_assign( 51 __entry->s_dev = inode->i_sb->s_dev; 52 __entry->i_ino = inode->i_ino; 53 __entry->type = type; 54 __entry->ctx = ctx; 55 ), 56 57 TP_printk("dev=0x%x:0x%x ino=0x%lx type=%s ctx=%p", 58 MAJOR(__entry->s_dev), MINOR(__entry->s_dev), 59 __entry->i_ino, show_fl_type(__entry->type), __entry->ctx) 60 ); 61 62 DECLARE_EVENT_CLASS(filelock_lock, 63 TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), 64 65 TP_ARGS(inode, fl, ret), 66 67 TP_STRUCT__entry( 68 __field(struct file_lock *, fl) 69 __field(unsigned long, i_ino) 70 __field(dev_t, s_dev) 71 __field(struct file_lock *, fl_next) 72 __field(fl_owner_t, fl_owner) 73 __field(unsigned int, fl_pid) 74 __field(unsigned int, fl_flags) 75 __field(unsigned char, fl_type) 76 __field(loff_t, fl_start) 77 __field(loff_t, fl_end) 78 __field(int, ret) 79 ), 80 81 TP_fast_assign( 82 __entry->fl = fl ? fl : NULL; 83 __entry->s_dev = inode->i_sb->s_dev; 84 __entry->i_ino = inode->i_ino; 85 __entry->fl_next = fl ? fl->fl_next : NULL; 86 __entry->fl_owner = fl ? fl->fl_owner : NULL; 87 __entry->fl_pid = fl ? fl->fl_pid : 0; 88 __entry->fl_flags = fl ? fl->fl_flags : 0; 89 __entry->fl_type = fl ? fl->fl_type : 0; 90 __entry->fl_start = fl ? fl->fl_start : 0; 91 __entry->fl_end = fl ? fl->fl_end : 0; 92 __entry->ret = ret; 93 ), 94 95 TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_pid=%u fl_flags=%s fl_type=%s fl_start=%lld fl_end=%lld ret=%d", 96 __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev), 97 __entry->i_ino, __entry->fl_next, __entry->fl_owner, 98 __entry->fl_pid, show_fl_flags(__entry->fl_flags), 99 show_fl_type(__entry->fl_type), 100 __entry->fl_start, __entry->fl_end, __entry->ret) 101 ); 102 103 DEFINE_EVENT(filelock_lock, posix_lock_inode, 104 TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), 105 TP_ARGS(inode, fl, ret)); 106 107 DEFINE_EVENT(filelock_lock, fcntl_setlk, 108 TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), 109 TP_ARGS(inode, fl, ret)); 110 111 DEFINE_EVENT(filelock_lock, locks_remove_posix, 112 TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), 113 TP_ARGS(inode, fl, ret)); 114 115 DEFINE_EVENT(filelock_lock, flock_lock_inode, 116 TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), 117 TP_ARGS(inode, fl, ret)); 118 119 DECLARE_EVENT_CLASS(filelock_lease, 120 TP_PROTO(struct inode *inode, struct file_lock *fl), 121 122 TP_ARGS(inode, fl), 123 124 TP_STRUCT__entry( 125 __field(struct file_lock *, fl) 126 __field(unsigned long, i_ino) 127 __field(dev_t, s_dev) 128 __field(struct file_lock *, fl_next) 129 __field(fl_owner_t, fl_owner) 130 __field(unsigned int, fl_flags) 131 __field(unsigned char, fl_type) 132 __field(unsigned long, fl_break_time) 133 __field(unsigned long, fl_downgrade_time) 134 ), 135 136 TP_fast_assign( 137 __entry->fl = fl ? fl : NULL; 138 __entry->s_dev = inode->i_sb->s_dev; 139 __entry->i_ino = inode->i_ino; 140 __entry->fl_next = fl ? fl->fl_next : NULL; 141 __entry->fl_owner = fl ? fl->fl_owner : NULL; 142 __entry->fl_flags = fl ? fl->fl_flags : 0; 143 __entry->fl_type = fl ? fl->fl_type : 0; 144 __entry->fl_break_time = fl ? fl->fl_break_time : 0; 145 __entry->fl_downgrade_time = fl ? fl->fl_downgrade_time : 0; 146 ), 147 148 TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_flags=%s fl_type=%s fl_break_time=%lu fl_downgrade_time=%lu", 149 __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev), 150 __entry->i_ino, __entry->fl_next, __entry->fl_owner, 151 show_fl_flags(__entry->fl_flags), 152 show_fl_type(__entry->fl_type), 153 __entry->fl_break_time, __entry->fl_downgrade_time) 154 ); 155 156 DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl), 157 TP_ARGS(inode, fl)); 158 159 DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl), 160 TP_ARGS(inode, fl)); 161 162 DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl), 163 TP_ARGS(inode, fl)); 164 165 DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl), 166 TP_ARGS(inode, fl)); 167 168 DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl), 169 TP_ARGS(inode, fl)); 170 171 TRACE_EVENT(generic_add_lease, 172 TP_PROTO(struct inode *inode, struct file_lock *fl), 173 174 TP_ARGS(inode, fl), 175 176 TP_STRUCT__entry( 177 __field(unsigned long, i_ino) 178 __field(int, wcount) 179 __field(int, dcount) 180 __field(int, icount) 181 __field(dev_t, s_dev) 182 __field(fl_owner_t, fl_owner) 183 __field(unsigned int, fl_flags) 184 __field(unsigned char, fl_type) 185 ), 186 187 TP_fast_assign( 188 __entry->s_dev = inode->i_sb->s_dev; 189 __entry->i_ino = inode->i_ino; 190 __entry->wcount = atomic_read(&inode->i_writecount); 191 __entry->dcount = d_count(fl->fl_file->f_path.dentry); 192 __entry->icount = atomic_read(&inode->i_count); 193 __entry->fl_owner = fl ? fl->fl_owner : NULL; 194 __entry->fl_flags = fl ? fl->fl_flags : 0; 195 __entry->fl_type = fl ? fl->fl_type : 0; 196 ), 197 198 TP_printk("dev=0x%x:0x%x ino=0x%lx wcount=%d dcount=%d icount=%d fl_owner=0x%p fl_flags=%s fl_type=%s", 199 MAJOR(__entry->s_dev), MINOR(__entry->s_dev), 200 __entry->i_ino, __entry->wcount, __entry->dcount, 201 __entry->icount, __entry->fl_owner, 202 show_fl_flags(__entry->fl_flags), 203 show_fl_type(__entry->fl_type)) 204 ); 205 206 #endif /* _TRACE_FILELOCK_H */ 207 208 /* This part must be outside protection */ 209 #include <trace/define_trace.h> 210