raid5-log.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef _RAID5_LOG_H
  2. #define _RAID5_LOG_H
  3. extern int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev);
  4. extern void r5l_exit_log(struct r5conf *conf);
  5. extern int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh);
  6. extern void r5l_write_stripe_run(struct r5l_log *log);
  7. extern void r5l_flush_stripe_to_raid(struct r5l_log *log);
  8. extern void r5l_stripe_write_finished(struct stripe_head *sh);
  9. extern int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
  10. extern void r5l_quiesce(struct r5l_log *log, int state);
  11. extern bool r5l_log_disk_error(struct r5conf *conf);
  12. extern bool r5c_is_writeback(struct r5l_log *log);
  13. extern int
  14. r5c_try_caching_write(struct r5conf *conf, struct stripe_head *sh,
  15. struct stripe_head_state *s, int disks);
  16. extern void
  17. r5c_finish_stripe_write_out(struct r5conf *conf, struct stripe_head *sh,
  18. struct stripe_head_state *s);
  19. extern void r5c_release_extra_page(struct stripe_head *sh);
  20. extern void r5c_use_extra_page(struct stripe_head *sh);
  21. extern void r5l_wake_reclaim(struct r5l_log *log, sector_t space);
  22. extern void r5c_handle_cached_data_endio(struct r5conf *conf,
  23. struct stripe_head *sh, int disks);
  24. extern int r5c_cache_data(struct r5l_log *log, struct stripe_head *sh);
  25. extern void r5c_make_stripe_write_out(struct stripe_head *sh);
  26. extern void r5c_flush_cache(struct r5conf *conf, int num);
  27. extern void r5c_check_stripe_cache_usage(struct r5conf *conf);
  28. extern void r5c_check_cached_full_stripe(struct r5conf *conf);
  29. extern struct md_sysfs_entry r5c_journal_mode;
  30. extern void r5c_update_on_rdev_error(struct mddev *mddev,
  31. struct md_rdev *rdev);
  32. extern bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect);
  33. extern struct dma_async_tx_descriptor *
  34. ops_run_partial_parity(struct stripe_head *sh, struct raid5_percpu *percpu,
  35. struct dma_async_tx_descriptor *tx);
  36. extern int ppl_init_log(struct r5conf *conf);
  37. extern void ppl_exit_log(struct r5conf *conf);
  38. extern int ppl_write_stripe(struct r5conf *conf, struct stripe_head *sh);
  39. extern void ppl_write_stripe_run(struct r5conf *conf);
  40. extern void ppl_stripe_write_finished(struct stripe_head *sh);
  41. extern int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add);
  42. static inline bool raid5_has_ppl(struct r5conf *conf)
  43. {
  44. return test_bit(MD_HAS_PPL, &conf->mddev->flags);
  45. }
  46. static inline int log_stripe(struct stripe_head *sh, struct stripe_head_state *s)
  47. {
  48. struct r5conf *conf = sh->raid_conf;
  49. if (conf->log) {
  50. if (!test_bit(STRIPE_R5C_CACHING, &sh->state)) {
  51. /* writing out phase */
  52. if (s->waiting_extra_page)
  53. return 0;
  54. return r5l_write_stripe(conf->log, sh);
  55. } else if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) {
  56. /* caching phase */
  57. return r5c_cache_data(conf->log, sh);
  58. }
  59. } else if (raid5_has_ppl(conf)) {
  60. return ppl_write_stripe(conf, sh);
  61. }
  62. return -EAGAIN;
  63. }
  64. static inline void log_stripe_write_finished(struct stripe_head *sh)
  65. {
  66. struct r5conf *conf = sh->raid_conf;
  67. if (conf->log)
  68. r5l_stripe_write_finished(sh);
  69. else if (raid5_has_ppl(conf))
  70. ppl_stripe_write_finished(sh);
  71. }
  72. static inline void log_write_stripe_run(struct r5conf *conf)
  73. {
  74. if (conf->log)
  75. r5l_write_stripe_run(conf->log);
  76. else if (raid5_has_ppl(conf))
  77. ppl_write_stripe_run(conf);
  78. }
  79. static inline void log_exit(struct r5conf *conf)
  80. {
  81. if (conf->log)
  82. r5l_exit_log(conf);
  83. else if (raid5_has_ppl(conf))
  84. ppl_exit_log(conf);
  85. }
  86. static inline int log_init(struct r5conf *conf, struct md_rdev *journal_dev,
  87. bool ppl)
  88. {
  89. if (journal_dev)
  90. return r5l_init_log(conf, journal_dev);
  91. else if (ppl)
  92. return ppl_init_log(conf);
  93. return 0;
  94. }
  95. static inline int log_modify(struct r5conf *conf, struct md_rdev *rdev, bool add)
  96. {
  97. if (raid5_has_ppl(conf))
  98. return ppl_modify_log(conf, rdev, add);
  99. return 0;
  100. }
  101. #endif