blk-sec.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BLK_SEC_H
  3. #define BLK_SEC_H
  4. enum {
  5. WB_REQ_IOSCHED = 0,
  6. WB_REQ_USER,
  7. NR_WB_REQ_TYPE
  8. };
  9. #if IS_ENABLED(CONFIG_BLK_SEC_COMMON)
  10. extern struct device *blk_sec_dev;
  11. extern struct workqueue_struct *blk_sec_common_wq;
  12. extern struct gendisk *blk_sec_internal_disk(void);
  13. #else
  14. static struct gendisk *blk_sec_internal_disk(void)
  15. {
  16. return NULL;
  17. }
  18. #endif
  19. #if IS_ENABLED(CONFIG_BLK_SEC_STATS)
  20. struct pio_node {
  21. struct list_head list;
  22. pid_t tgid;
  23. char name[TASK_COMM_LEN];
  24. u64 start_time;
  25. atomic_t kb[REQ_OP_DISCARD + 1];
  26. atomic_t ref_count;
  27. struct pio_node *h_next; /* next pio_node for hash */
  28. };
  29. extern void blk_sec_stat_account_init(struct request_queue *q);
  30. extern void blk_sec_stat_account_exit(struct elevator_queue *eq);
  31. extern void blk_sec_stat_account_io_prepare(struct request *rq,
  32. void *ptr_pio);
  33. extern void blk_sec_stat_account_io_complete(struct request *rq,
  34. unsigned int data_size, void *pio);
  35. extern void blk_sec_stat_account_io_finish(struct request *rq,
  36. void *ptr_pio);
  37. #else
  38. static inline void blk_sec_stat_account_init(struct request_queue *q)
  39. {
  40. }
  41. static inline void blk_sec_stat_account_exit(struct elevator_queue *eq)
  42. {
  43. }
  44. static inline void blk_sec_stat_account_io_prepare(struct request *rq,
  45. void *ptr_pio)
  46. {
  47. }
  48. static inline void blk_sec_stat_account_io_complete(struct request *rq,
  49. unsigned int data_size, void *pio)
  50. {
  51. }
  52. static inline void blk_sec_stat_account_io_finish(struct request *rq,
  53. void *ptr_pio)
  54. {
  55. }
  56. #endif
  57. #if IS_ENABLED(CONFIG_BLK_SEC_WB)
  58. extern int blk_sec_wb_ctrl(bool enable, int req_type);
  59. extern int blk_sec_wb_ctrl_async(bool enable, int req_type);
  60. extern bool blk_sec_wb_is_supported(struct gendisk *gd);
  61. #else
  62. static inline int blk_sec_wb_ctrl(bool enable, int req_type)
  63. {
  64. return 0;
  65. }
  66. static inline int blk_sec_wb_ctrl_async(bool enable, int req_type)
  67. {
  68. return 0;
  69. }
  70. static inline bool blk_sec_wb_is_supported(struct gendisk *gd)
  71. {
  72. return false;
  73. }
  74. #endif
  75. #endif // BLK_SEC_H