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