mt_fuse.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. FUSE: file io log
  3. Copyright (C) 2015 Perry Hsu <perry.hsu@mediatek.com>
  4. This program can be distributed under the terms of the GNU GPL.
  5. See the file COPYING.
  6. */
  7. #ifndef _FS_MT_FUSE_H
  8. #define _FS_MT_FUSE_H
  9. #include <linux/fuse.h>
  10. #include <linux/fs.h>
  11. void fuse_request_send_background_ex(struct fuse_conn *fc,
  12. struct fuse_req *req, __u32 size);
  13. void fuse_request_send_ex(struct fuse_conn *fc, struct fuse_req *req,
  14. __u32 size);
  15. #if defined(CONFIG_FUSE_IO_LOG) /* IO log is only enabled in eng load */
  16. #include <linux/sched.h>
  17. #include <linux/kthread.h>
  18. /* max number of access traces in one log */
  19. #define FUSE_IOLOG_MAX 12
  20. /* kernel log print buffer size */
  21. #define FUSE_IOLOG_BUFLEN 512
  22. /* latency time between logs */
  23. #define FUSE_IOLOG_LATENCY 1
  24. /* max number of logs in the ring buffer */
  25. #define FUSE_IOLOG_RINGBUF_MAX 120
  26. void fuse_time_diff(struct timespec *start,
  27. struct timespec *end,
  28. struct timespec *diff);
  29. void fuse_iolog_add(__u32 io_bytes, int type,
  30. struct timespec *start,
  31. struct timespec *end);
  32. __u32 fuse_iolog_timeus_diff(struct timespec *start,
  33. struct timespec *end);
  34. void fuse_iolog_exit(void);
  35. void fuse_iolog_init(void);
  36. /* access trace statistic */
  37. struct fuse_rw_info {
  38. __u32 count;
  39. __u32 bytes;
  40. __u32 us;
  41. };
  42. /* access trace */
  43. struct fuse_proc_info {
  44. pid_t pid;
  45. __u32 valid;
  46. int misc_type;
  47. struct fuse_rw_info read;
  48. struct fuse_rw_info write;
  49. struct fuse_rw_info misc;
  50. };
  51. /* data container for timing macros */
  52. struct fuse_iolog_t {
  53. struct timespec _tstart, _tend;
  54. __u32 size;
  55. unsigned int opcode;
  56. };
  57. /* log entry of ring buffer */
  58. struct fuse_proc_log {
  59. uint64_t time;
  60. struct fuse_proc_info info[FUSE_IOLOG_MAX];
  61. };
  62. #define FUSE_IOLOG_INIT(iobytes, type) struct fuse_iolog_t _iolog = { .size = iobytes, .opcode = type }
  63. #define FUSE_IOLOG_START() get_monotonic_boottime(&_iolog._tstart)
  64. #define FUSE_IOLOG_END() get_monotonic_boottime(&_iolog._tend)
  65. #define FUSE_IOLOG_US() fuse_iolog_timeus_diff(&_iolog._tstart, &_iolog._tend)
  66. #define FUSE_IOLOG_PRINT() fuse_iolog_add(_iolog.size, _iolog.opcode, &_iolog._tstart, &_iolog._tend)
  67. #else
  68. #define FUSE_IOLOG_INIT(...)
  69. #define FUSE_IOLOG_START(...)
  70. #define FUSE_IOLOG_END(...)
  71. #define FUSE_IOLOG_PRINT(...)
  72. #define fuse_iolog_init(...)
  73. #define fuse_iolog_exit(...)
  74. #endif
  75. #endif