trace.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2018, Microsoft Corporation.
  4. *
  5. * Author(s): Steve French <stfrench@microsoft.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  15. * the GNU General Public License for more details.
  16. */
  17. #undef TRACE_SYSTEM
  18. #define TRACE_SYSTEM cifs
  19. #if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  20. #define _CIFS_TRACE_H
  21. #include <linux/tracepoint.h>
  22. /* For logging errors in read or write */
  23. DECLARE_EVENT_CLASS(smb3_rw_err_class,
  24. TP_PROTO(unsigned int xid,
  25. __u64 fid,
  26. __u32 tid,
  27. __u64 sesid,
  28. __u64 offset,
  29. __u32 len,
  30. int rc),
  31. TP_ARGS(xid, fid, tid, sesid, offset, len, rc),
  32. TP_STRUCT__entry(
  33. __field(unsigned int, xid)
  34. __field(__u64, fid)
  35. __field(__u32, tid)
  36. __field(__u64, sesid)
  37. __field(__u64, offset)
  38. __field(__u32, len)
  39. __field(int, rc)
  40. ),
  41. TP_fast_assign(
  42. __entry->xid = xid;
  43. __entry->fid = fid;
  44. __entry->tid = tid;
  45. __entry->sesid = sesid;
  46. __entry->offset = offset;
  47. __entry->len = len;
  48. __entry->rc = rc;
  49. ),
  50. TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x rc=%d",
  51. __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
  52. __entry->offset, __entry->len, __entry->rc)
  53. )
  54. #define DEFINE_SMB3_RW_ERR_EVENT(name) \
  55. DEFINE_EVENT(smb3_rw_err_class, smb3_##name, \
  56. TP_PROTO(unsigned int xid, \
  57. __u64 fid, \
  58. __u32 tid, \
  59. __u64 sesid, \
  60. __u64 offset, \
  61. __u32 len, \
  62. int rc), \
  63. TP_ARGS(xid, fid, tid, sesid, offset, len, rc))
  64. DEFINE_SMB3_RW_ERR_EVENT(write_err);
  65. DEFINE_SMB3_RW_ERR_EVENT(read_err);
  66. /* For logging successful read or write */
  67. DECLARE_EVENT_CLASS(smb3_rw_done_class,
  68. TP_PROTO(unsigned int xid,
  69. __u64 fid,
  70. __u32 tid,
  71. __u64 sesid,
  72. __u64 offset,
  73. __u32 len),
  74. TP_ARGS(xid, fid, tid, sesid, offset, len),
  75. TP_STRUCT__entry(
  76. __field(unsigned int, xid)
  77. __field(__u64, fid)
  78. __field(__u32, tid)
  79. __field(__u64, sesid)
  80. __field(__u64, offset)
  81. __field(__u32, len)
  82. ),
  83. TP_fast_assign(
  84. __entry->xid = xid;
  85. __entry->fid = fid;
  86. __entry->tid = tid;
  87. __entry->sesid = sesid;
  88. __entry->offset = offset;
  89. __entry->len = len;
  90. ),
  91. TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx offset=0x%llx len=0x%x",
  92. __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
  93. __entry->offset, __entry->len)
  94. )
  95. #define DEFINE_SMB3_RW_DONE_EVENT(name) \
  96. DEFINE_EVENT(smb3_rw_done_class, smb3_##name, \
  97. TP_PROTO(unsigned int xid, \
  98. __u64 fid, \
  99. __u32 tid, \
  100. __u64 sesid, \
  101. __u64 offset, \
  102. __u32 len), \
  103. TP_ARGS(xid, fid, tid, sesid, offset, len))
  104. DEFINE_SMB3_RW_DONE_EVENT(write_done);
  105. DEFINE_SMB3_RW_DONE_EVENT(read_done);
  106. /*
  107. * For handle based calls other than read and write, and get/set info
  108. */
  109. DECLARE_EVENT_CLASS(smb3_fd_err_class,
  110. TP_PROTO(unsigned int xid,
  111. __u64 fid,
  112. __u32 tid,
  113. __u64 sesid,
  114. int rc),
  115. TP_ARGS(xid, fid, tid, sesid, rc),
  116. TP_STRUCT__entry(
  117. __field(unsigned int, xid)
  118. __field(__u64, fid)
  119. __field(__u32, tid)
  120. __field(__u64, sesid)
  121. __field(int, rc)
  122. ),
  123. TP_fast_assign(
  124. __entry->xid = xid;
  125. __entry->fid = fid;
  126. __entry->tid = tid;
  127. __entry->sesid = sesid;
  128. __entry->rc = rc;
  129. ),
  130. TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx rc=%d",
  131. __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
  132. __entry->rc)
  133. )
  134. #define DEFINE_SMB3_FD_ERR_EVENT(name) \
  135. DEFINE_EVENT(smb3_fd_err_class, smb3_##name, \
  136. TP_PROTO(unsigned int xid, \
  137. __u64 fid, \
  138. __u32 tid, \
  139. __u64 sesid, \
  140. int rc), \
  141. TP_ARGS(xid, fid, tid, sesid, rc))
  142. DEFINE_SMB3_FD_ERR_EVENT(flush_err);
  143. DEFINE_SMB3_FD_ERR_EVENT(lock_err);
  144. DEFINE_SMB3_FD_ERR_EVENT(close_err);
  145. /*
  146. * For handle based query/set info calls
  147. */
  148. DECLARE_EVENT_CLASS(smb3_inf_err_class,
  149. TP_PROTO(unsigned int xid,
  150. __u64 fid,
  151. __u32 tid,
  152. __u64 sesid,
  153. __u8 infclass,
  154. __u32 type,
  155. int rc),
  156. TP_ARGS(xid, fid, tid, sesid, infclass, type, rc),
  157. TP_STRUCT__entry(
  158. __field(unsigned int, xid)
  159. __field(__u64, fid)
  160. __field(__u32, tid)
  161. __field(__u64, sesid)
  162. __field(__u8, infclass)
  163. __field(__u32, type)
  164. __field(int, rc)
  165. ),
  166. TP_fast_assign(
  167. __entry->xid = xid;
  168. __entry->fid = fid;
  169. __entry->tid = tid;
  170. __entry->sesid = sesid;
  171. __entry->infclass = infclass;
  172. __entry->type = type;
  173. __entry->rc = rc;
  174. ),
  175. TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx class=%u type=0x%x rc=%d",
  176. __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
  177. __entry->infclass, __entry->type, __entry->rc)
  178. )
  179. #define DEFINE_SMB3_INF_ERR_EVENT(name) \
  180. DEFINE_EVENT(smb3_inf_err_class, smb3_##name, \
  181. TP_PROTO(unsigned int xid, \
  182. __u64 fid, \
  183. __u32 tid, \
  184. __u64 sesid, \
  185. __u8 infclass, \
  186. __u32 type, \
  187. int rc), \
  188. TP_ARGS(xid, fid, tid, sesid, infclass, type, rc))
  189. DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
  190. DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
  191. DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
  192. /*
  193. * For logging SMB3 Status code and Command for responses which return errors
  194. */
  195. DECLARE_EVENT_CLASS(smb3_cmd_err_class,
  196. TP_PROTO(__u32 tid,
  197. __u64 sesid,
  198. __u16 cmd,
  199. __u64 mid,
  200. __u32 status,
  201. int rc),
  202. TP_ARGS(tid, sesid, cmd, mid, status, rc),
  203. TP_STRUCT__entry(
  204. __field(__u32, tid)
  205. __field(__u64, sesid)
  206. __field(__u16, cmd)
  207. __field(__u64, mid)
  208. __field(__u32, status)
  209. __field(int, rc)
  210. ),
  211. TP_fast_assign(
  212. __entry->tid = tid;
  213. __entry->sesid = sesid;
  214. __entry->cmd = cmd;
  215. __entry->mid = mid;
  216. __entry->status = status;
  217. __entry->rc = rc;
  218. ),
  219. TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu status=0x%x rc=%d",
  220. __entry->sesid, __entry->tid, __entry->cmd, __entry->mid,
  221. __entry->status, __entry->rc)
  222. )
  223. #define DEFINE_SMB3_CMD_ERR_EVENT(name) \
  224. DEFINE_EVENT(smb3_cmd_err_class, smb3_##name, \
  225. TP_PROTO(__u32 tid, \
  226. __u64 sesid, \
  227. __u16 cmd, \
  228. __u64 mid, \
  229. __u32 status, \
  230. int rc), \
  231. TP_ARGS(tid, sesid, cmd, mid, status, rc))
  232. DEFINE_SMB3_CMD_ERR_EVENT(cmd_err);
  233. DECLARE_EVENT_CLASS(smb3_cmd_done_class,
  234. TP_PROTO(__u32 tid,
  235. __u64 sesid,
  236. __u16 cmd,
  237. __u64 mid),
  238. TP_ARGS(tid, sesid, cmd, mid),
  239. TP_STRUCT__entry(
  240. __field(__u32, tid)
  241. __field(__u64, sesid)
  242. __field(__u16, cmd)
  243. __field(__u64, mid)
  244. ),
  245. TP_fast_assign(
  246. __entry->tid = tid;
  247. __entry->sesid = sesid;
  248. __entry->cmd = cmd;
  249. __entry->mid = mid;
  250. ),
  251. TP_printk("\tsid=0x%llx tid=0x%x cmd=%u mid=%llu",
  252. __entry->sesid, __entry->tid,
  253. __entry->cmd, __entry->mid)
  254. )
  255. #define DEFINE_SMB3_CMD_DONE_EVENT(name) \
  256. DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \
  257. TP_PROTO(__u32 tid, \
  258. __u64 sesid, \
  259. __u16 cmd, \
  260. __u64 mid), \
  261. TP_ARGS(tid, sesid, cmd, mid))
  262. DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
  263. DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
  264. DECLARE_EVENT_CLASS(smb3_mid_class,
  265. TP_PROTO(__u16 cmd,
  266. __u64 mid,
  267. __u32 pid,
  268. unsigned long when_sent,
  269. unsigned long when_received),
  270. TP_ARGS(cmd, mid, pid, when_sent, when_received),
  271. TP_STRUCT__entry(
  272. __field(__u16, cmd)
  273. __field(__u64, mid)
  274. __field(__u32, pid)
  275. __field(unsigned long, when_sent)
  276. __field(unsigned long, when_received)
  277. ),
  278. TP_fast_assign(
  279. __entry->cmd = cmd;
  280. __entry->mid = mid;
  281. __entry->pid = pid;
  282. __entry->when_sent = when_sent;
  283. __entry->when_received = when_received;
  284. ),
  285. TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
  286. __entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
  287. __entry->when_received)
  288. )
  289. #define DEFINE_SMB3_MID_EVENT(name) \
  290. DEFINE_EVENT(smb3_mid_class, smb3_##name, \
  291. TP_PROTO(__u16 cmd, \
  292. __u64 mid, \
  293. __u32 pid, \
  294. unsigned long when_sent, \
  295. unsigned long when_received), \
  296. TP_ARGS(cmd, mid, pid, when_sent, when_received))
  297. DEFINE_SMB3_MID_EVENT(slow_rsp);
  298. DECLARE_EVENT_CLASS(smb3_exit_err_class,
  299. TP_PROTO(unsigned int xid,
  300. const char *func_name,
  301. int rc),
  302. TP_ARGS(xid, func_name, rc),
  303. TP_STRUCT__entry(
  304. __field(unsigned int, xid)
  305. __field(const char *, func_name)
  306. __field(int, rc)
  307. ),
  308. TP_fast_assign(
  309. __entry->xid = xid;
  310. __entry->func_name = func_name;
  311. __entry->rc = rc;
  312. ),
  313. TP_printk("\t%s: xid=%u rc=%d",
  314. __entry->func_name, __entry->xid, __entry->rc)
  315. )
  316. #define DEFINE_SMB3_EXIT_ERR_EVENT(name) \
  317. DEFINE_EVENT(smb3_exit_err_class, smb3_##name, \
  318. TP_PROTO(unsigned int xid, \
  319. const char *func_name, \
  320. int rc), \
  321. TP_ARGS(xid, func_name, rc))
  322. DEFINE_SMB3_EXIT_ERR_EVENT(exit_err);
  323. DECLARE_EVENT_CLASS(smb3_enter_exit_class,
  324. TP_PROTO(unsigned int xid,
  325. const char *func_name),
  326. TP_ARGS(xid, func_name),
  327. TP_STRUCT__entry(
  328. __field(unsigned int, xid)
  329. __field(const char *, func_name)
  330. ),
  331. TP_fast_assign(
  332. __entry->xid = xid;
  333. __entry->func_name = func_name;
  334. ),
  335. TP_printk("\t%s: xid=%u",
  336. __entry->func_name, __entry->xid)
  337. )
  338. #define DEFINE_SMB3_ENTER_EXIT_EVENT(name) \
  339. DEFINE_EVENT(smb3_enter_exit_class, smb3_##name, \
  340. TP_PROTO(unsigned int xid, \
  341. const char *func_name), \
  342. TP_ARGS(xid, func_name))
  343. DEFINE_SMB3_ENTER_EXIT_EVENT(enter);
  344. DEFINE_SMB3_ENTER_EXIT_EVENT(exit_done);
  345. /*
  346. * For smb2/smb3 open call
  347. */
  348. DECLARE_EVENT_CLASS(smb3_open_err_class,
  349. TP_PROTO(unsigned int xid,
  350. __u32 tid,
  351. __u64 sesid,
  352. int create_options,
  353. int desired_access,
  354. int rc),
  355. TP_ARGS(xid, tid, sesid, create_options, desired_access, rc),
  356. TP_STRUCT__entry(
  357. __field(unsigned int, xid)
  358. __field(__u32, tid)
  359. __field(__u64, sesid)
  360. __field(int, create_options)
  361. __field(int, desired_access)
  362. __field(int, rc)
  363. ),
  364. TP_fast_assign(
  365. __entry->xid = xid;
  366. __entry->tid = tid;
  367. __entry->sesid = sesid;
  368. __entry->create_options = create_options;
  369. __entry->desired_access = desired_access;
  370. __entry->rc = rc;
  371. ),
  372. TP_printk("xid=%u sid=0x%llx tid=0x%x cr_opts=0x%x des_access=0x%x rc=%d",
  373. __entry->xid, __entry->sesid, __entry->tid,
  374. __entry->create_options, __entry->desired_access, __entry->rc)
  375. )
  376. #define DEFINE_SMB3_OPEN_ERR_EVENT(name) \
  377. DEFINE_EVENT(smb3_open_err_class, smb3_##name, \
  378. TP_PROTO(unsigned int xid, \
  379. __u32 tid, \
  380. __u64 sesid, \
  381. int create_options, \
  382. int desired_access, \
  383. int rc), \
  384. TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
  385. DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
  386. DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
  387. DECLARE_EVENT_CLASS(smb3_open_done_class,
  388. TP_PROTO(unsigned int xid,
  389. __u64 fid,
  390. __u32 tid,
  391. __u64 sesid,
  392. int create_options,
  393. int desired_access),
  394. TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
  395. TP_STRUCT__entry(
  396. __field(unsigned int, xid)
  397. __field(__u64, fid)
  398. __field(__u32, tid)
  399. __field(__u64, sesid)
  400. __field(int, create_options)
  401. __field(int, desired_access)
  402. ),
  403. TP_fast_assign(
  404. __entry->xid = xid;
  405. __entry->fid = fid;
  406. __entry->tid = tid;
  407. __entry->sesid = sesid;
  408. __entry->create_options = create_options;
  409. __entry->desired_access = desired_access;
  410. ),
  411. TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
  412. __entry->xid, __entry->sesid, __entry->tid, __entry->fid,
  413. __entry->create_options, __entry->desired_access)
  414. )
  415. #define DEFINE_SMB3_OPEN_DONE_EVENT(name) \
  416. DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
  417. TP_PROTO(unsigned int xid, \
  418. __u64 fid, \
  419. __u32 tid, \
  420. __u64 sesid, \
  421. int create_options, \
  422. int desired_access), \
  423. TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
  424. DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
  425. DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
  426. DECLARE_EVENT_CLASS(smb3_reconnect_class,
  427. TP_PROTO(__u64 currmid,
  428. char *hostname),
  429. TP_ARGS(currmid, hostname),
  430. TP_STRUCT__entry(
  431. __field(__u64, currmid)
  432. __field(char *, hostname)
  433. ),
  434. TP_fast_assign(
  435. __entry->currmid = currmid;
  436. __entry->hostname = hostname;
  437. ),
  438. TP_printk("server=%s current_mid=0x%llx",
  439. __entry->hostname,
  440. __entry->currmid)
  441. )
  442. #define DEFINE_SMB3_RECONNECT_EVENT(name) \
  443. DEFINE_EVENT(smb3_reconnect_class, smb3_##name, \
  444. TP_PROTO(__u64 currmid, \
  445. char *hostname), \
  446. TP_ARGS(currmid, hostname))
  447. DEFINE_SMB3_RECONNECT_EVENT(reconnect);
  448. DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
  449. #endif /* _CIFS_TRACE_H */
  450. #undef TRACE_INCLUDE_PATH
  451. #define TRACE_INCLUDE_PATH .
  452. #define TRACE_INCLUDE_FILE trace
  453. #include <trace/define_trace.h>