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