aboutsummaryrefslogtreecommitdiffstats
path: root/lib/raid6/algos.c
diff options
context:
space:
mode:
authorJim Kukunas <james.t.kukunas@linux.intel.com>2012-05-21 23:54:18 -0400
committerNeilBrown <neilb@suse.de>2012-05-21 23:54:18 -0400
commit048a8b8c89dc427dd7a58527c8923224b1e66d83 (patch)
treec8e09964537839f3848d0ad0e25ee40e873c3d09 /lib/raid6/algos.c
parentf674ef7b43881b2ac11f98d6ba2dc5d9dd0dd118 (diff)
lib/raid6: Add SSSE3 optimized recovery functions
Add SSSE3 optimized recovery functions, as well as a system for selecting the most appropriate recovery functions to use. Originally-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Jim Kukunas <james.t.kukunas@linux.intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'lib/raid6/algos.c')
-rw-r--r--lib/raid6/algos.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index f6a0f7899163..5a7f8022be13 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -64,6 +64,20 @@ const struct raid6_calls * const raid6_algos[] = {
64 NULL 64 NULL
65}; 65};
66 66
67void (*raid6_2data_recov)(int, size_t, int, int, void **);
68EXPORT_SYMBOL_GPL(raid6_2data_recov);
69
70void (*raid6_datap_recov)(int, size_t, int, void **);
71EXPORT_SYMBOL_GPL(raid6_datap_recov);
72
73const struct raid6_recov_calls *const raid6_recov_algos[] = {
74#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
75 &raid6_recov_ssse3,
76#endif
77 &raid6_recov_intx1,
78 NULL
79};
80
67#ifdef __KERNEL__ 81#ifdef __KERNEL__
68#define RAID6_TIME_JIFFIES_LG2 4 82#define RAID6_TIME_JIFFIES_LG2 4
69#else 83#else
@@ -72,6 +86,26 @@ const struct raid6_calls * const raid6_algos[] = {
72#define time_before(x, y) ((x) < (y)) 86#define time_before(x, y) ((x) < (y))
73#endif 87#endif
74 88
89static inline void raid6_choose_recov(void)
90{
91 const struct raid6_recov_calls *const *algo;
92 const struct raid6_recov_calls *best;
93
94 for (best = NULL, algo = raid6_recov_algos; *algo; algo++)
95 if (!best || (*algo)->priority > best->priority)
96 if (!(*algo)->valid || (*algo)->valid())
97 best = *algo;
98
99 if (best) {
100 raid6_2data_recov = best->data2;
101 raid6_datap_recov = best->datap;
102
103 printk("raid6: using %s recovery algorithm\n", best->name);
104 } else
105 printk("raid6: Yikes! No recovery algorithm found!\n");
106}
107
108
75/* Try to pick the best algorithm */ 109/* Try to pick the best algorithm */
76/* This code uses the gfmul table as convenient data set to abuse */ 110/* This code uses the gfmul table as convenient data set to abuse */
77 111
@@ -141,6 +175,9 @@ int __init raid6_select_algo(void)
141 175
142 free_pages((unsigned long)syndromes, 1); 176 free_pages((unsigned long)syndromes, 1);
143 177
178 /* select raid recover functions */
179 raid6_choose_recov();
180
144 return best ? 0 : -EINVAL; 181 return best ? 0 : -EINVAL;
145} 182}
146 183