aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-03-31 00:09:39 -0400
committerNeilBrown <neilb@suse.de>2009-03-31 00:09:39 -0400
commitf701d589aa34d7531183c9ac6f7713ba14212b02 (patch)
treed388cd7fa54c520f12233470a35ebb0676677e7a /drivers
parent18b0033491f584a2d79697da714b1ef9d6b27d22 (diff)
md/raid6: move raid6 data processing to raid6_pq.ko
Move the raid6 data processing routines into a standalone module (raid6_pq) to prepare them to be called from async_tx wrappers and other non-md drivers/modules. This precludes a circular dependency of raid456 needing the async modules for data processing while those modules in turn depend on raid456 for the base level synchronous raid6 routines. To support this move: 1/ The exportable definitions in raid6.h move to include/linux/raid/pq.h 2/ The raid6_call, recovery calls, and table symbols are exported 3/ Extra #ifdef __KERNEL__ statements to enable the userspace raid6test to compile Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/Kconfig4
-rw-r--r--drivers/md/Makefile4
-rw-r--r--drivers/md/mktables.c14
-rw-r--r--drivers/md/raid5.c12
-rw-r--r--drivers/md/raid5.h2
-rw-r--r--drivers/md/raid6.h126
-rw-r--r--drivers/md/raid6algos.c19
-rw-r--r--drivers/md/raid6altivec.uc2
-rw-r--r--drivers/md/raid6int.uc2
-rw-r--r--drivers/md/raid6mmx.c2
-rw-r--r--drivers/md/raid6recov.c11
-rw-r--r--drivers/md/raid6sse1.c2
-rw-r--r--drivers/md/raid6sse2.c2
-rw-r--r--drivers/md/raid6test/Makefile2
-rw-r--r--drivers/md/raid6test/test.c2
15 files changed, 53 insertions, 153 deletions
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 2281b5098e95..449d0b9cac14 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -121,6 +121,7 @@ config MD_RAID10
121config MD_RAID456 121config MD_RAID456
122 tristate "RAID-4/RAID-5/RAID-6 mode" 122 tristate "RAID-4/RAID-5/RAID-6 mode"
123 depends on BLK_DEV_MD 123 depends on BLK_DEV_MD
124 select MD_RAID6_PQ
124 select ASYNC_MEMCPY 125 select ASYNC_MEMCPY
125 select ASYNC_XOR 126 select ASYNC_XOR
126 ---help--- 127 ---help---
@@ -180,6 +181,9 @@ config MD_RAID5_RESHAPE
180 181
181 If unsure, say Y. 182 If unsure, say Y.
182 183
184config MD_RAID6_PQ
185 tristate
186
183config MD_MULTIPATH 187config MD_MULTIPATH
184 tristate "Multipath I/O support" 188 tristate "Multipath I/O support"
185 depends on BLK_DEV_MD 189 depends on BLK_DEV_MD
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 3b118da575ee..45cc5951d928 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -9,7 +9,8 @@ dm-snapshot-y += dm-snap.o dm-exception-store.o dm-snap-transient.o \
9 dm-snap-persistent.o 9 dm-snap-persistent.o
10dm-mirror-y += dm-raid1.o 10dm-mirror-y += dm-raid1.o
11md-mod-y += md.o bitmap.o 11md-mod-y += md.o bitmap.o
12raid456-y += raid5.o raid6algos.o raid6recov.o raid6tables.o \ 12raid456-y += raid5.o
13raid6_pq-y += raid6algos.o raid6recov.o raid6tables.o \
13 raid6int1.o raid6int2.o raid6int4.o \ 14 raid6int1.o raid6int2.o raid6int4.o \
14 raid6int8.o raid6int16.o raid6int32.o \ 15 raid6int8.o raid6int16.o raid6int32.o \
15 raid6altivec1.o raid6altivec2.o raid6altivec4.o \ 16 raid6altivec1.o raid6altivec2.o raid6altivec4.o \
@@ -26,6 +27,7 @@ obj-$(CONFIG_MD_LINEAR) += linear.o
26obj-$(CONFIG_MD_RAID0) += raid0.o 27obj-$(CONFIG_MD_RAID0) += raid0.o
27obj-$(CONFIG_MD_RAID1) += raid1.o 28obj-$(CONFIG_MD_RAID1) += raid1.o
28obj-$(CONFIG_MD_RAID10) += raid10.o 29obj-$(CONFIG_MD_RAID10) += raid10.o
30obj-$(CONFIG_MD_RAID6_PQ) += raid6_pq.o
29obj-$(CONFIG_MD_RAID456) += raid456.o 31obj-$(CONFIG_MD_RAID456) += raid456.o
30obj-$(CONFIG_MD_MULTIPATH) += multipath.o 32obj-$(CONFIG_MD_MULTIPATH) += multipath.o
31obj-$(CONFIG_MD_FAULTY) += faulty.o 33obj-$(CONFIG_MD_FAULTY) += faulty.o
diff --git a/drivers/md/mktables.c b/drivers/md/mktables.c
index b61d5767aae7..3b1500843bba 100644
--- a/drivers/md/mktables.c
+++ b/drivers/md/mktables.c
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
59 uint8_t v; 59 uint8_t v;
60 uint8_t exptbl[256], invtbl[256]; 60 uint8_t exptbl[256], invtbl[256];
61 61
62 printf("#include \"raid6.h\"\n"); 62 printf("#include <linux/raid/pq.h>\n");
63 63
64 /* Compute multiplication table */ 64 /* Compute multiplication table */
65 printf("\nconst u8 __attribute__((aligned(256)))\n" 65 printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
76 printf("\t},\n"); 76 printf("\t},\n");
77 } 77 }
78 printf("};\n"); 78 printf("};\n");
79 printf("#ifdef __KERNEL__\n");
80 printf("EXPORT_SYMBOL(raid6_gfmul);\n");
81 printf("#endif\n");
79 82
80 /* Compute power-of-2 table (exponent) */ 83 /* Compute power-of-2 table (exponent) */
81 v = 1; 84 v = 1;
@@ -92,6 +95,9 @@ int main(int argc, char *argv[])
92 } 95 }
93 } 96 }
94 printf("};\n"); 97 printf("};\n");
98 printf("#ifdef __KERNEL__\n");
99 printf("EXPORT_SYMBOL(raid6_gfexp);\n");
100 printf("#endif\n");
95 101
96 /* Compute inverse table x^-1 == x^254 */ 102 /* Compute inverse table x^-1 == x^254 */
97 printf("\nconst u8 __attribute__((aligned(256)))\n" 103 printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -104,6 +110,9 @@ int main(int argc, char *argv[])
104 } 110 }
105 } 111 }
106 printf("};\n"); 112 printf("};\n");
113 printf("#ifdef __KERNEL__\n");
114 printf("EXPORT_SYMBOL(raid6_gfinv);\n");
115 printf("#endif\n");
107 116
108 /* Compute inv(2^x + 1) (exponent-xor-inverse) table */ 117 /* Compute inv(2^x + 1) (exponent-xor-inverse) table */
109 printf("\nconst u8 __attribute__((aligned(256)))\n" 118 printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -115,6 +124,9 @@ int main(int argc, char *argv[])
115 (j == 7) ? '\n' : ' '); 124 (j == 7) ? '\n' : ' ');
116 } 125 }
117 printf("};\n"); 126 printf("};\n");
127 printf("#ifdef __KERNEL__\n");
128 printf("EXPORT_SYMBOL(raid6_gfexi);\n");
129 printf("#endif\n");
118 130
119 return 0; 131 return 0;
120} 132}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e1ee181b79bb..1f1b054ff0b6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -45,11 +45,11 @@
45 45
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/kthread.h> 47#include <linux/kthread.h>
48#include <linux/raid/pq.h>
48#include <linux/async_tx.h> 49#include <linux/async_tx.h>
49#include <linux/seq_file.h> 50#include <linux/seq_file.h>
50#include "md.h" 51#include "md.h"
51#include "raid5.h" 52#include "raid5.h"
52#include "raid6.h"
53#include "bitmap.h" 53#include "bitmap.h"
54 54
55/* 55/*
@@ -94,11 +94,6 @@
94 94
95#define printk_rl(args...) ((void) (printk_ratelimit() && printk(args))) 95#define printk_rl(args...) ((void) (printk_ratelimit() && printk(args)))
96 96
97#if !RAID6_USE_EMPTY_ZERO_PAGE
98/* In .bss so it's zeroed */
99const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256)));
100#endif
101
102/* 97/*
103 * We maintain a biased count of active stripes in the bottom 16 bits of 98 * We maintain a biased count of active stripes in the bottom 16 bits of
104 * bi_phys_segments, and a count of processed stripes in the upper 16 bits 99 * bi_phys_segments, and a count of processed stripes in the upper 16 bits
@@ -5153,11 +5148,6 @@ static struct mdk_personality raid4_personality =
5153 5148
5154static int __init raid5_init(void) 5149static int __init raid5_init(void)
5155{ 5150{
5156 int e;
5157
5158 e = raid6_select_algo();
5159 if ( e )
5160 return e;
5161 register_md_personality(&raid6_personality); 5151 register_md_personality(&raid6_personality);
5162 register_md_personality(&raid5_personality); 5152 register_md_personality(&raid5_personality);
5163 register_md_personality(&raid4_personality); 5153 register_md_personality(&raid4_personality);
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index c172371481c7..2934ee0a39c6 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -269,6 +269,8 @@ struct r6_state {
269#define READ_MODIFY_WRITE 2 269#define READ_MODIFY_WRITE 2
270/* not a write method, but a compute_parity mode */ 270/* not a write method, but a compute_parity mode */
271#define CHECK_PARITY 3 271#define CHECK_PARITY 3
272/* Additional compute_parity mode -- updates the parity w/o LOCKING */
273#define UPDATE_PARITY 4
272 274
273/* 275/*
274 * Stripe state 276 * Stripe state
diff --git a/drivers/md/raid6.h b/drivers/md/raid6.h
deleted file mode 100644
index 8a9c823bab9e..000000000000
--- a/drivers/md/raid6.h
+++ /dev/null
@@ -1,126 +0,0 @@
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * Copyright 2003 H. Peter Anvin - All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13#ifndef LINUX_RAID_RAID6_H
14#define LINUX_RAID_RAID6_H
15
16#ifdef __KERNEL__
17
18/* Set to 1 to use kernel-wide empty_zero_page */
19#define RAID6_USE_EMPTY_ZERO_PAGE 0
20#include <linux/blkdev.h>
21
22/* Additional compute_parity mode -- updates the parity w/o LOCKING */
23#define UPDATE_PARITY 4
24
25/* We need a pre-zeroed page... if we don't want to use the kernel-provided
26 one define it here */
27#if RAID6_USE_EMPTY_ZERO_PAGE
28# define raid6_empty_zero_page empty_zero_page
29#else
30extern const char raid6_empty_zero_page[PAGE_SIZE];
31#endif
32
33#else /* ! __KERNEL__ */
34/* Used for testing in user space */
35
36#include <errno.h>
37#include <inttypes.h>
38#include <limits.h>
39#include <stddef.h>
40#include <sys/mman.h>
41#include <sys/types.h>
42
43/* Not standard, but glibc defines it */
44#define BITS_PER_LONG __WORDSIZE
45
46typedef uint8_t u8;
47typedef uint16_t u16;
48typedef uint32_t u32;
49typedef uint64_t u64;
50
51#ifndef PAGE_SIZE
52# define PAGE_SIZE 4096
53#endif
54extern const char raid6_empty_zero_page[PAGE_SIZE];
55
56#define __init
57#define __exit
58#define __attribute_const__ __attribute__((const))
59#define noinline __attribute__((noinline))
60
61#define preempt_enable()
62#define preempt_disable()
63#define cpu_has_feature(x) 1
64#define enable_kernel_altivec()
65#define disable_kernel_altivec()
66
67#endif /* __KERNEL__ */
68
69/* Routine choices */
70struct raid6_calls {
71 void (*gen_syndrome)(int, size_t, void **);
72 int (*valid)(void); /* Returns 1 if this routine set is usable */
73 const char *name; /* Name of this routine set */
74 int prefer; /* Has special performance attribute */
75};
76
77/* Selected algorithm */
78extern struct raid6_calls raid6_call;
79
80/* Algorithm list */
81extern const struct raid6_calls * const raid6_algos[];
82int raid6_select_algo(void);
83
84/* Return values from chk_syndrome */
85#define RAID6_OK 0
86#define RAID6_P_BAD 1
87#define RAID6_Q_BAD 2
88#define RAID6_PQ_BAD 3
89
90/* Galois field tables */
91extern const u8 raid6_gfmul[256][256] __attribute__((aligned(256)));
92extern const u8 raid6_gfexp[256] __attribute__((aligned(256)));
93extern const u8 raid6_gfinv[256] __attribute__((aligned(256)));
94extern const u8 raid6_gfexi[256] __attribute__((aligned(256)));
95
96/* Recovery routines */
97void raid6_2data_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
98void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs);
99void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs);
100
101/* Some definitions to allow code to be compiled for testing in userspace */
102#ifndef __KERNEL__
103
104# define jiffies raid6_jiffies()
105# define printk printf
106# define GFP_KERNEL 0
107# define __get_free_pages(x,y) ((unsigned long)mmap(NULL, PAGE_SIZE << (y), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
108# define free_pages(x,y) munmap((void *)(x), (y)*PAGE_SIZE)
109
110static inline void cpu_relax(void)
111{
112 /* Nothing */
113}
114
115#undef HZ
116#define HZ 1000
117static inline uint32_t raid6_jiffies(void)
118{
119 struct timeval tv;
120 gettimeofday(&tv, NULL);
121 return tv.tv_sec*1000 + tv.tv_usec/1000;
122}
123
124#endif /* ! __KERNEL__ */
125
126#endif /* LINUX_RAID_RAID6_H */
diff --git a/drivers/md/raid6algos.c b/drivers/md/raid6algos.c
index 1f6a3c82ee0c..866215ac7f25 100644
--- a/drivers/md/raid6algos.c
+++ b/drivers/md/raid6algos.c
@@ -16,13 +16,20 @@
16 * Algorithm list and algorithm selection for RAID-6 16 * Algorithm list and algorithm selection for RAID-6
17 */ 17 */
18 18
19#include "raid6.h" 19#include <linux/raid/pq.h>
20#ifndef __KERNEL__ 20#ifndef __KERNEL__
21#include <sys/mman.h> 21#include <sys/mman.h>
22#include <stdio.h> 22#include <stdio.h>
23#else
24#if !RAID6_USE_EMPTY_ZERO_PAGE
25/* In .bss so it's zeroed */
26const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256)));
27EXPORT_SYMBOL(raid6_empty_zero_page);
28#endif
23#endif 29#endif
24 30
25struct raid6_calls raid6_call; 31struct raid6_calls raid6_call;
32EXPORT_SYMBOL_GPL(raid6_call);
26 33
27/* Various routine sets */ 34/* Various routine sets */
28extern const struct raid6_calls raid6_intx1; 35extern const struct raid6_calls raid6_intx1;
@@ -79,6 +86,7 @@ const struct raid6_calls * const raid6_algos[] = {
79#else 86#else
80/* Need more time to be stable in userspace */ 87/* Need more time to be stable in userspace */
81#define RAID6_TIME_JIFFIES_LG2 9 88#define RAID6_TIME_JIFFIES_LG2 9
89#define time_before(x, y) ((x) < (y))
82#endif 90#endif
83 91
84/* Try to pick the best algorithm */ 92/* Try to pick the best algorithm */
@@ -152,3 +160,12 @@ int __init raid6_select_algo(void)
152 160
153 return best ? 0 : -EINVAL; 161 return best ? 0 : -EINVAL;
154} 162}
163
164static void raid6_exit(void)
165{
166 do { } while (0);
167}
168
169subsys_initcall(raid6_select_algo);
170module_exit(raid6_exit);
171MODULE_LICENSE("GPL");
diff --git a/drivers/md/raid6altivec.uc b/drivers/md/raid6altivec.uc
index 217580667e0c..699dfeee4944 100644
--- a/drivers/md/raid6altivec.uc
+++ b/drivers/md/raid6altivec.uc
@@ -22,7 +22,7 @@
22 * bracked this with preempt_disable/enable or in a lock) 22 * bracked this with preempt_disable/enable or in a lock)
23 */ 23 */
24 24
25#include "raid6.h" 25#include <linux/raid/pq.h>
26 26
27#ifdef CONFIG_ALTIVEC 27#ifdef CONFIG_ALTIVEC
28 28
diff --git a/drivers/md/raid6int.uc b/drivers/md/raid6int.uc
index 32a0bac3eb3d..f9bf9cba357f 100644
--- a/drivers/md/raid6int.uc
+++ b/drivers/md/raid6int.uc
@@ -18,7 +18,7 @@
18 * This file is postprocessed using unroll.pl 18 * This file is postprocessed using unroll.pl
19 */ 19 */
20 20
21#include "raid6.h" 21#include <linux/raid/pq.h>
22 22
23/* 23/*
24 * This is the C data type to use 24 * This is the C data type to use
diff --git a/drivers/md/raid6mmx.c b/drivers/md/raid6mmx.c
index 804cb50ecc19..e7f6c13132bf 100644
--- a/drivers/md/raid6mmx.c
+++ b/drivers/md/raid6mmx.c
@@ -18,7 +18,7 @@
18 18
19#if defined(__i386__) && !defined(__arch_um__) 19#if defined(__i386__) && !defined(__arch_um__)
20 20
21#include "raid6.h" 21#include <linux/raid/pq.h>
22#include "raid6x86.h" 22#include "raid6x86.h"
23 23
24/* Shared with raid6sse1.c */ 24/* Shared with raid6sse1.c */
diff --git a/drivers/md/raid6recov.c b/drivers/md/raid6recov.c
index 7a98b8652582..2609f00e0d61 100644
--- a/drivers/md/raid6recov.c
+++ b/drivers/md/raid6recov.c
@@ -18,7 +18,7 @@
18 * the syndrome.) 18 * the syndrome.)
19 */ 19 */
20 20
21#include "raid6.h" 21#include <linux/raid/pq.h>
22 22
23/* Recover two failed data blocks. */ 23/* Recover two failed data blocks. */
24void raid6_2data_recov(int disks, size_t bytes, int faila, int failb, 24void raid6_2data_recov(int disks, size_t bytes, int faila, int failb,
@@ -63,9 +63,7 @@ void raid6_2data_recov(int disks, size_t bytes, int faila, int failb,
63 p++; q++; 63 p++; q++;
64 } 64 }
65} 65}
66 66EXPORT_SYMBOL_GPL(raid6_2data_recov);
67
68
69 67
70/* Recover failure of one data block plus the P block */ 68/* Recover failure of one data block plus the P block */
71void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs) 69void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs)
@@ -97,9 +95,10 @@ void raid6_datap_recov(int disks, size_t bytes, int faila, void **ptrs)
97 q++; dq++; 95 q++; dq++;
98 } 96 }
99} 97}
98EXPORT_SYMBOL_GPL(raid6_datap_recov);
100 99
101 100#ifndef __KERNEL__
102#ifndef __KERNEL__ /* Testing only */ 101/* Testing only */
103 102
104/* Recover two failed blocks. */ 103/* Recover two failed blocks. */
105void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs) 104void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs)
diff --git a/drivers/md/raid6sse1.c b/drivers/md/raid6sse1.c
index 15c588905225..b274dd5eab8f 100644
--- a/drivers/md/raid6sse1.c
+++ b/drivers/md/raid6sse1.c
@@ -23,7 +23,7 @@
23 23
24#if defined(__i386__) && !defined(__arch_um__) 24#if defined(__i386__) && !defined(__arch_um__)
25 25
26#include "raid6.h" 26#include <linux/raid/pq.h>
27#include "raid6x86.h" 27#include "raid6x86.h"
28 28
29/* Defined in raid6mmx.c */ 29/* Defined in raid6mmx.c */
diff --git a/drivers/md/raid6sse2.c b/drivers/md/raid6sse2.c
index 2e92e96275be..6ed6c6c0389f 100644
--- a/drivers/md/raid6sse2.c
+++ b/drivers/md/raid6sse2.c
@@ -19,7 +19,7 @@
19 19
20#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) 20#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)
21 21
22#include "raid6.h" 22#include <linux/raid/pq.h>
23#include "raid6x86.h" 23#include "raid6x86.h"
24 24
25static const struct raid6_sse_constants { 25static const struct raid6_sse_constants {
diff --git a/drivers/md/raid6test/Makefile b/drivers/md/raid6test/Makefile
index 78e0396adf2a..58ffdf4f5161 100644
--- a/drivers/md/raid6test/Makefile
+++ b/drivers/md/raid6test/Makefile
@@ -5,7 +5,7 @@
5 5
6CC = gcc 6CC = gcc
7OPTFLAGS = -O2 # Adjust as desired 7OPTFLAGS = -O2 # Adjust as desired
8CFLAGS = -I.. -g $(OPTFLAGS) 8CFLAGS = -I.. -I ../../../include -g $(OPTFLAGS)
9LD = ld 9LD = ld
10PERL = perl 10PERL = perl
11AR = ar 11AR = ar
diff --git a/drivers/md/raid6test/test.c b/drivers/md/raid6test/test.c
index 559cc41b2585..7a930318b17d 100644
--- a/drivers/md/raid6test/test.c
+++ b/drivers/md/raid6test/test.c
@@ -17,7 +17,7 @@
17#include <stdlib.h> 17#include <stdlib.h>
18#include <stdio.h> 18#include <stdio.h>
19#include <string.h> 19#include <string.h>
20#include "raid6.h" 20#include <linux/raid/pq.h>
21 21
22#define NDISKS 16 /* Including P and Q */ 22#define NDISKS 16 /* Including P and Q */
23 23