Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _RAID5_LOG_H
  3#define _RAID5_LOG_H
  4
  5extern int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev);
  6extern void r5l_exit_log(struct r5conf *conf);
  7extern int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh);
  8extern void r5l_write_stripe_run(struct r5l_log *log);
  9extern void r5l_flush_stripe_to_raid(struct r5l_log *log);
 10extern void r5l_stripe_write_finished(struct stripe_head *sh);
 11extern int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
 12extern void r5l_quiesce(struct r5l_log *log, int quiesce);
 13extern bool r5l_log_disk_error(struct r5conf *conf);
 14extern bool r5c_is_writeback(struct r5l_log *log);
 15extern int
 16r5c_try_caching_write(struct r5conf *conf, struct stripe_head *sh,
 17		      struct stripe_head_state *s, int disks);
 18extern void
 19r5c_finish_stripe_write_out(struct r5conf *conf, struct stripe_head *sh,
 20			    struct stripe_head_state *s);
 21extern void r5c_release_extra_page(struct stripe_head *sh);
 22extern void r5c_use_extra_page(struct stripe_head *sh);
 23extern void r5l_wake_reclaim(struct r5l_log *log, sector_t space);
 24extern void r5c_handle_cached_data_endio(struct r5conf *conf,
 25	struct stripe_head *sh, int disks);
 26extern int r5c_cache_data(struct r5l_log *log, struct stripe_head *sh);
 27extern void r5c_make_stripe_write_out(struct stripe_head *sh);
 28extern void r5c_flush_cache(struct r5conf *conf, int num);
 29extern void r5c_check_stripe_cache_usage(struct r5conf *conf);
 30extern void r5c_check_cached_full_stripe(struct r5conf *conf);
 31extern struct md_sysfs_entry r5c_journal_mode;
 32extern void r5c_update_on_rdev_error(struct mddev *mddev,
 33				     struct md_rdev *rdev);
 34extern bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect);
 35extern int r5l_start(struct r5l_log *log);
 36
 37extern struct dma_async_tx_descriptor *
 38ops_run_partial_parity(struct stripe_head *sh, struct raid5_percpu *percpu,
 39		       struct dma_async_tx_descriptor *tx);
 40extern int ppl_init_log(struct r5conf *conf);
 41extern void ppl_exit_log(struct r5conf *conf);
 42extern int ppl_write_stripe(struct r5conf *conf, struct stripe_head *sh);
 43extern void ppl_write_stripe_run(struct r5conf *conf);
 44extern void ppl_stripe_write_finished(struct stripe_head *sh);
 45extern int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add);
 46extern void ppl_quiesce(struct r5conf *conf, int quiesce);
 47extern int ppl_handle_flush_request(struct r5l_log *log, struct bio *bio);
 48
 49static inline bool raid5_has_ppl(struct r5conf *conf)
 50{
 51	return test_bit(MD_HAS_PPL, &conf->mddev->flags);
 52}
 53
 54static inline int log_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 55{
 56	struct r5conf *conf = sh->raid_conf;
 57
 58	if (conf->log) {
 59		if (!test_bit(STRIPE_R5C_CACHING, &sh->state)) {
 60			/* writing out phase */
 61			if (s->waiting_extra_page)
 62				return 0;
 63			return r5l_write_stripe(conf->log, sh);
 64		} else if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) {
 65			/* caching phase */
 66			return r5c_cache_data(conf->log, sh);
 67		}
 68	} else if (raid5_has_ppl(conf)) {
 69		return ppl_write_stripe(conf, sh);
 70	}
 71
 72	return -EAGAIN;
 73}
 74
 75static inline void log_stripe_write_finished(struct stripe_head *sh)
 76{
 77	struct r5conf *conf = sh->raid_conf;
 78
 79	if (conf->log)
 80		r5l_stripe_write_finished(sh);
 81	else if (raid5_has_ppl(conf))
 82		ppl_stripe_write_finished(sh);
 83}
 84
 85static inline void log_write_stripe_run(struct r5conf *conf)
 86{
 87	if (conf->log)
 88		r5l_write_stripe_run(conf->log);
 89	else if (raid5_has_ppl(conf))
 90		ppl_write_stripe_run(conf);
 91}
 92
 93static inline void log_flush_stripe_to_raid(struct r5conf *conf)
 94{
 95	if (conf->log)
 96		r5l_flush_stripe_to_raid(conf->log);
 97	else if (raid5_has_ppl(conf))
 98		ppl_write_stripe_run(conf);
 99}
100
101static inline int log_handle_flush_request(struct r5conf *conf, struct bio *bio)
102{
103	int ret = -ENODEV;
104
105	if (conf->log)
106		ret = r5l_handle_flush_request(conf->log, bio);
107	else if (raid5_has_ppl(conf))
108		ret = ppl_handle_flush_request(conf->log, bio);
109
110	return ret;
111}
112
113static inline void log_quiesce(struct r5conf *conf, int quiesce)
114{
115	if (conf->log)
116		r5l_quiesce(conf->log, quiesce);
117	else if (raid5_has_ppl(conf))
118		ppl_quiesce(conf, quiesce);
119}
120
121static inline void log_exit(struct r5conf *conf)
122{
123	if (conf->log)
124		r5l_exit_log(conf);
125	else if (raid5_has_ppl(conf))
126		ppl_exit_log(conf);
127}
128
129static inline int log_init(struct r5conf *conf, struct md_rdev *journal_dev,
130			   bool ppl)
131{
132	if (journal_dev)
133		return r5l_init_log(conf, journal_dev);
134	else if (ppl)
135		return ppl_init_log(conf);
136
137	return 0;
138}
139
140static inline int log_modify(struct r5conf *conf, struct md_rdev *rdev, bool add)
141{
142	if (raid5_has_ppl(conf))
143		return ppl_modify_log(conf, rdev, add);
144
145	return 0;
146}
147
148#endif