Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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