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