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