0001
0002 #ifndef _RAID5_LOG_H
0003 #define _RAID5_LOG_H
0004
0005 int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev);
0006 void r5l_exit_log(struct r5conf *conf);
0007 int r5l_write_stripe(struct r5l_log *log, struct stripe_head *head_sh);
0008 void r5l_write_stripe_run(struct r5l_log *log);
0009 void r5l_flush_stripe_to_raid(struct r5l_log *log);
0010 void r5l_stripe_write_finished(struct stripe_head *sh);
0011 int r5l_handle_flush_request(struct r5l_log *log, struct bio *bio);
0012 void r5l_quiesce(struct r5l_log *log, int quiesce);
0013 bool r5l_log_disk_error(struct r5conf *conf);
0014 bool r5c_is_writeback(struct r5l_log *log);
0015 int r5c_try_caching_write(struct r5conf *conf, struct stripe_head *sh,
0016 struct stripe_head_state *s, int disks);
0017 void r5c_finish_stripe_write_out(struct r5conf *conf, struct stripe_head *sh,
0018 struct stripe_head_state *s);
0019 void r5c_release_extra_page(struct stripe_head *sh);
0020 void r5c_use_extra_page(struct stripe_head *sh);
0021 void r5l_wake_reclaim(struct r5l_log *log, sector_t space);
0022 void r5c_handle_cached_data_endio(struct r5conf *conf,
0023 struct stripe_head *sh, int disks);
0024 int r5c_cache_data(struct r5l_log *log, struct stripe_head *sh);
0025 void r5c_make_stripe_write_out(struct stripe_head *sh);
0026 void r5c_flush_cache(struct r5conf *conf, int num);
0027 void r5c_check_stripe_cache_usage(struct r5conf *conf);
0028 void r5c_check_cached_full_stripe(struct r5conf *conf);
0029 extern struct md_sysfs_entry r5c_journal_mode;
0030 void r5c_update_on_rdev_error(struct mddev *mddev, struct md_rdev *rdev);
0031 bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect);
0032 int r5l_start(struct r5l_log *log);
0033
0034 struct dma_async_tx_descriptor *
0035 ops_run_partial_parity(struct stripe_head *sh, struct raid5_percpu *percpu,
0036 struct dma_async_tx_descriptor *tx);
0037 int ppl_init_log(struct r5conf *conf);
0038 void ppl_exit_log(struct r5conf *conf);
0039 int ppl_write_stripe(struct r5conf *conf, struct stripe_head *sh);
0040 void ppl_write_stripe_run(struct r5conf *conf);
0041 void ppl_stripe_write_finished(struct stripe_head *sh);
0042 int ppl_modify_log(struct r5conf *conf, struct md_rdev *rdev, bool add);
0043 void ppl_quiesce(struct r5conf *conf, int quiesce);
0044 int ppl_handle_flush_request(struct bio *bio);
0045 extern struct md_sysfs_entry ppl_write_hint;
0046
0047 static inline bool raid5_has_log(struct r5conf *conf)
0048 {
0049 return test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
0050 }
0051
0052 static inline bool raid5_has_ppl(struct r5conf *conf)
0053 {
0054 return test_bit(MD_HAS_PPL, &conf->mddev->flags);
0055 }
0056
0057 static inline int log_stripe(struct stripe_head *sh, struct stripe_head_state *s)
0058 {
0059 struct r5conf *conf = sh->raid_conf;
0060
0061 if (conf->log) {
0062 if (!test_bit(STRIPE_R5C_CACHING, &sh->state)) {
0063
0064 if (s->waiting_extra_page)
0065 return 0;
0066 return r5l_write_stripe(conf->log, sh);
0067 } else if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) {
0068
0069 return r5c_cache_data(conf->log, sh);
0070 }
0071 } else if (raid5_has_ppl(conf)) {
0072 return ppl_write_stripe(conf, sh);
0073 }
0074
0075 return -EAGAIN;
0076 }
0077
0078 static inline void log_stripe_write_finished(struct stripe_head *sh)
0079 {
0080 struct r5conf *conf = sh->raid_conf;
0081
0082 if (conf->log)
0083 r5l_stripe_write_finished(sh);
0084 else if (raid5_has_ppl(conf))
0085 ppl_stripe_write_finished(sh);
0086 }
0087
0088 static inline void log_write_stripe_run(struct r5conf *conf)
0089 {
0090 if (conf->log)
0091 r5l_write_stripe_run(conf->log);
0092 else if (raid5_has_ppl(conf))
0093 ppl_write_stripe_run(conf);
0094 }
0095
0096 static inline void log_flush_stripe_to_raid(struct r5conf *conf)
0097 {
0098 if (conf->log)
0099 r5l_flush_stripe_to_raid(conf->log);
0100 else if (raid5_has_ppl(conf))
0101 ppl_write_stripe_run(conf);
0102 }
0103
0104 static inline int log_handle_flush_request(struct r5conf *conf, struct bio *bio)
0105 {
0106 int ret = -ENODEV;
0107
0108 if (conf->log)
0109 ret = r5l_handle_flush_request(conf->log, bio);
0110 else if (raid5_has_ppl(conf))
0111 ret = ppl_handle_flush_request(bio);
0112
0113 return ret;
0114 }
0115
0116 static inline void log_quiesce(struct r5conf *conf, int quiesce)
0117 {
0118 if (conf->log)
0119 r5l_quiesce(conf->log, quiesce);
0120 else if (raid5_has_ppl(conf))
0121 ppl_quiesce(conf, quiesce);
0122 }
0123
0124 static inline void log_exit(struct r5conf *conf)
0125 {
0126 if (conf->log)
0127 r5l_exit_log(conf);
0128 else if (raid5_has_ppl(conf))
0129 ppl_exit_log(conf);
0130 }
0131
0132 static inline int log_init(struct r5conf *conf, struct md_rdev *journal_dev,
0133 bool ppl)
0134 {
0135 if (journal_dev)
0136 return r5l_init_log(conf, journal_dev);
0137 else if (ppl)
0138 return ppl_init_log(conf);
0139
0140 return 0;
0141 }
0142
0143 static inline int log_modify(struct r5conf *conf, struct md_rdev *rdev, bool add)
0144 {
0145 if (raid5_has_ppl(conf))
0146 return ppl_modify_log(conf, rdev, add);
0147
0148 return 0;
0149 }
0150
0151 #endif