Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 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, |
NeilBrown | bd83d0a | 2017-03-15 14:05:12 +1100 | [diff] [blame] | 24 | struct stripe_head *sh, int disks); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 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; |
Song Liu | 70d466f | 2017-05-11 15:28:28 -0700 | [diff] [blame] | 31 | extern void r5c_update_on_rdev_error(struct mddev *mddev, |
| 32 | struct md_rdev *rdev); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 33 | extern bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect); |
| 34 | |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 35 | extern struct dma_async_tx_descriptor * |
| 36 | ops_run_partial_parity(struct stripe_head *sh, struct raid5_percpu *percpu, |
| 37 | struct dma_async_tx_descriptor *tx); |
| 38 | extern int ppl_init_log(struct r5conf *conf); |
| 39 | extern void ppl_exit_log(struct r5conf *conf); |
| 40 | extern int ppl_write_stripe(struct r5conf *conf, struct stripe_head *sh); |
| 41 | extern void ppl_write_stripe_run(struct r5conf *conf); |
| 42 | extern void ppl_stripe_write_finished(struct stripe_head *sh); |
Artur Paszkiewicz | 6358c23 | 2017-03-09 10:00:02 +0100 | [diff] [blame] | 43 | extern int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add); |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 44 | |
| 45 | static inline bool raid5_has_ppl(struct r5conf *conf) |
| 46 | { |
| 47 | return test_bit(MD_HAS_PPL, &conf->mddev->flags); |
| 48 | } |
| 49 | |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 50 | static inline int log_stripe(struct stripe_head *sh, struct stripe_head_state *s) |
| 51 | { |
| 52 | struct r5conf *conf = sh->raid_conf; |
| 53 | |
| 54 | if (conf->log) { |
| 55 | if (!test_bit(STRIPE_R5C_CACHING, &sh->state)) { |
| 56 | /* writing out phase */ |
| 57 | if (s->waiting_extra_page) |
| 58 | return 0; |
| 59 | return r5l_write_stripe(conf->log, sh); |
| 60 | } else if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) { |
| 61 | /* caching phase */ |
| 62 | return r5c_cache_data(conf->log, sh); |
| 63 | } |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 64 | } else if (raid5_has_ppl(conf)) { |
| 65 | return ppl_write_stripe(conf, sh); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | return -EAGAIN; |
| 69 | } |
| 70 | |
| 71 | static inline void log_stripe_write_finished(struct stripe_head *sh) |
| 72 | { |
| 73 | struct r5conf *conf = sh->raid_conf; |
| 74 | |
| 75 | if (conf->log) |
| 76 | r5l_stripe_write_finished(sh); |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 77 | else if (raid5_has_ppl(conf)) |
| 78 | ppl_stripe_write_finished(sh); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static inline void log_write_stripe_run(struct r5conf *conf) |
| 82 | { |
| 83 | if (conf->log) |
| 84 | r5l_write_stripe_run(conf->log); |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 85 | else if (raid5_has_ppl(conf)) |
| 86 | ppl_write_stripe_run(conf); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static inline void log_exit(struct r5conf *conf) |
| 90 | { |
| 91 | if (conf->log) |
| 92 | r5l_exit_log(conf); |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 93 | else if (raid5_has_ppl(conf)) |
| 94 | ppl_exit_log(conf); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Artur Paszkiewicz | 845b9e2 | 2017-04-04 13:13:57 +0200 | [diff] [blame] | 97 | static inline int log_init(struct r5conf *conf, struct md_rdev *journal_dev, |
| 98 | bool ppl) |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 99 | { |
| 100 | if (journal_dev) |
| 101 | return r5l_init_log(conf, journal_dev); |
Artur Paszkiewicz | 845b9e2 | 2017-04-04 13:13:57 +0200 | [diff] [blame] | 102 | else if (ppl) |
Artur Paszkiewicz | 3418d03 | 2017-03-09 09:59:59 +0100 | [diff] [blame] | 103 | return ppl_init_log(conf); |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
Artur Paszkiewicz | 6358c23 | 2017-03-09 10:00:02 +0100 | [diff] [blame] | 108 | static inline int log_modify(struct r5conf *conf, struct md_rdev *rdev, bool add) |
| 109 | { |
| 110 | if (raid5_has_ppl(conf)) |
| 111 | return ppl_modify_log(conf, rdev, add); |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
Artur Paszkiewicz | ff87573 | 2017-03-09 09:59:58 +0100 | [diff] [blame] | 116 | #endif |