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