Skip to content

Commit f701d58

Browse files
djbwneilbrown
authored andcommitted
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>
1 parent 18b0033 commit f701d58

15 files changed

Lines changed: 66 additions & 34 deletions

File tree

drivers/md/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ config MD_RAID10
121121
config MD_RAID456
122122
tristate "RAID-4/RAID-5/RAID-6 mode"
123123
depends on BLK_DEV_MD
124+
select MD_RAID6_PQ
124125
select ASYNC_MEMCPY
125126
select ASYNC_XOR
126127
---help---
@@ -180,6 +181,9 @@ config MD_RAID5_RESHAPE
180181

181182
If unsure, say Y.
182183

184+
config MD_RAID6_PQ
185+
tristate
186+
183187
config MD_MULTIPATH
184188
tristate "Multipath I/O support"
185189
depends on BLK_DEV_MD

drivers/md/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ dm-snapshot-y += dm-snap.o dm-exception-store.o dm-snap-transient.o \
99
dm-snap-persistent.o
1010
dm-mirror-y += dm-raid1.o
1111
md-mod-y += md.o bitmap.o
12-
raid456-y += raid5.o raid6algos.o raid6recov.o raid6tables.o \
12+
raid456-y += raid5.o
13+
raid6_pq-y += raid6algos.o raid6recov.o raid6tables.o \
1314
raid6int1.o raid6int2.o raid6int4.o \
1415
raid6int8.o raid6int16.o raid6int32.o \
1516
raid6altivec1.o raid6altivec2.o raid6altivec4.o \
@@ -26,6 +27,7 @@ obj-$(CONFIG_MD_LINEAR) += linear.o
2627
obj-$(CONFIG_MD_RAID0) += raid0.o
2728
obj-$(CONFIG_MD_RAID1) += raid1.o
2829
obj-$(CONFIG_MD_RAID10) += raid10.o
30+
obj-$(CONFIG_MD_RAID6_PQ) += raid6_pq.o
2931
obj-$(CONFIG_MD_RAID456) += raid456.o
3032
obj-$(CONFIG_MD_MULTIPATH) += multipath.o
3133
obj-$(CONFIG_MD_FAULTY) += faulty.o

drivers/md/mktables.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
5959
uint8_t v;
6060
uint8_t exptbl[256], invtbl[256];
6161

62-
printf("#include \"raid6.h\"\n");
62+
printf("#include <linux/raid/pq.h>\n");
6363

6464
/* Compute multiplication table */
6565
printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
7676
printf("\t},\n");
7777
}
7878
printf("};\n");
79+
printf("#ifdef __KERNEL__\n");
80+
printf("EXPORT_SYMBOL(raid6_gfmul);\n");
81+
printf("#endif\n");
7982

8083
/* Compute power-of-2 table (exponent) */
8184
v = 1;
@@ -92,6 +95,9 @@ int main(int argc, char *argv[])
9295
}
9396
}
9497
printf("};\n");
98+
printf("#ifdef __KERNEL__\n");
99+
printf("EXPORT_SYMBOL(raid6_gfexp);\n");
100+
printf("#endif\n");
95101

96102
/* Compute inverse table x^-1 == x^254 */
97103
printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -104,6 +110,9 @@ int main(int argc, char *argv[])
104110
}
105111
}
106112
printf("};\n");
113+
printf("#ifdef __KERNEL__\n");
114+
printf("EXPORT_SYMBOL(raid6_gfinv);\n");
115+
printf("#endif\n");
107116

108117
/* Compute inv(2^x + 1) (exponent-xor-inverse) table */
109118
printf("\nconst u8 __attribute__((aligned(256)))\n"
@@ -115,6 +124,9 @@ int main(int argc, char *argv[])
115124
(j == 7) ? '\n' : ' ');
116125
}
117126
printf("};\n");
127+
printf("#ifdef __KERNEL__\n");
128+
printf("EXPORT_SYMBOL(raid6_gfexi);\n");
129+
printf("#endif\n");
118130

119131
return 0;
120132
}

drivers/md/raid5.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545

4646
#include <linux/blkdev.h>
4747
#include <linux/kthread.h>
48+
#include <linux/raid/pq.h>
4849
#include <linux/async_tx.h>
4950
#include <linux/seq_file.h>
5051
#include "md.h"
5152
#include "raid5.h"
52-
#include "raid6.h"
5353
#include "bitmap.h"
5454

5555
/*
@@ -94,11 +94,6 @@
9494

9595
#define printk_rl(args...) ((void) (printk_ratelimit() && printk(args)))
9696

97-
#if !RAID6_USE_EMPTY_ZERO_PAGE
98-
/* In .bss so it's zeroed */
99-
const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256)));
100-
#endif
101-
10297
/*
10398
* We maintain a biased count of active stripes in the bottom 16 bits of
10499
* bi_phys_segments, and a count of processed stripes in the upper 16 bits
@@ -5153,11 +5148,6 @@ static struct mdk_personality raid4_personality =
51535148

51545149
static int __init raid5_init(void)
51555150
{
5156-
int e;
5157-
5158-
e = raid6_select_algo();
5159-
if ( e )
5160-
return e;
51615151
register_md_personality(&raid6_personality);
51625152
register_md_personality(&raid5_personality);
51635153
register_md_personality(&raid4_personality);

drivers/md/raid5.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ struct r6_state {
269269
#define READ_MODIFY_WRITE 2
270270
/* not a write method, but a compute_parity mode */
271271
#define CHECK_PARITY 3
272+
/* Additional compute_parity mode -- updates the parity w/o LOCKING */
273+
#define UPDATE_PARITY 4
272274

273275
/*
274276
* Stripe state

drivers/md/raid6algos.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616
* Algorithm list and algorithm selection for RAID-6
1717
*/
1818

19-
#include "raid6.h"
19+
#include <linux/raid/pq.h>
2020
#ifndef __KERNEL__
2121
#include <sys/mman.h>
2222
#include <stdio.h>
23+
#else
24+
#if !RAID6_USE_EMPTY_ZERO_PAGE
25+
/* In .bss so it's zeroed */
26+
const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256)));
27+
EXPORT_SYMBOL(raid6_empty_zero_page);
28+
#endif
2329
#endif
2430

2531
struct raid6_calls raid6_call;
32+
EXPORT_SYMBOL_GPL(raid6_call);
2633

2734
/* Various routine sets */
2835
extern const struct raid6_calls raid6_intx1;
@@ -79,6 +86,7 @@ const struct raid6_calls * const raid6_algos[] = {
7986
#else
8087
/* Need more time to be stable in userspace */
8188
#define RAID6_TIME_JIFFIES_LG2 9
89+
#define time_before(x, y) ((x) < (y))
8290
#endif
8391

8492
/* Try to pick the best algorithm */
@@ -152,3 +160,12 @@ int __init raid6_select_algo(void)
152160

153161
return best ? 0 : -EINVAL;
154162
}
163+
164+
static void raid6_exit(void)
165+
{
166+
do { } while (0);
167+
}
168+
169+
subsys_initcall(raid6_select_algo);
170+
module_exit(raid6_exit);
171+
MODULE_LICENSE("GPL");

drivers/md/raid6altivec.uc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* bracked this with preempt_disable/enable or in a lock)
2323
*/
2424

25-
#include "raid6.h"
25+
#include <linux/raid/pq.h>
2626

2727
#ifdef CONFIG_ALTIVEC
2828

drivers/md/raid6int.uc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* This file is postprocessed using unroll.pl
1919
*/
2020

21-
#include "raid6.h"
21+
#include <linux/raid/pq.h>
2222

2323
/*
2424
* This is the C data type to use

drivers/md/raid6mmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#if defined(__i386__) && !defined(__arch_um__)
2020

21-
#include "raid6.h"
21+
#include <linux/raid/pq.h>
2222
#include "raid6x86.h"
2323

2424
/* Shared with raid6sse1.c */

drivers/md/raid6recov.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* the syndrome.)
1919
*/
2020

21-
#include "raid6.h"
21+
#include <linux/raid/pq.h>
2222

2323
/* Recover two failed data blocks. */
2424
void 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,
6363
p++; q++;
6464
}
6565
}
66-
67-
68-
66+
EXPORT_SYMBOL_GPL(raid6_2data_recov);
6967

7068
/* Recover failure of one data block plus the P block */
7169
void 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)
9795
q++; dq++;
9896
}
9997
}
98+
EXPORT_SYMBOL_GPL(raid6_datap_recov);
10099

101-
102-
#ifndef __KERNEL__ /* Testing only */
100+
#ifndef __KERNEL__
101+
/* Testing only */
103102

104103
/* Recover two failed blocks. */
105104
void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, void **ptrs)

0 commit comments

Comments
 (0)