2 int phys2log(int phys, int stripe, int n, int layout)
4 /* In an 'n' disk array using 'layout',
5 * in stripe 'stripe', the physical disc 'phys'
6 * stores what logical chunk?
11 case ALGORITHM_LEFT_ASYMMETRIC:
12 pd = (n-1) - (stripe % n);
19 case ALGORITHM_RIGHT_ASYMMETRIC:
27 case ALGORITHM_LEFT_SYMMETRIC:
28 pd = (n-1) - (stripe %n);
33 else return phys-pd-1;
35 case ALGORITHM_RIGHT_SYMMETRIC:
41 else return phys-pd-1;
46 raid5_extend(unsigned long len, int chunksize, int layout, int n, int m, int rfds[], int wfds[])
49 static char buf[4096];
51 unsigned long blocks = len/4;
52 unsigned int blocksperchunk= chunksize/4096;
56 for (b=0; b<blocks; b++) {
57 unsigned long stripe = b / blocksperchunk;
58 unsigned int offset = b - (stripe*blocksperchunk);
59 unsigned long chunk = stripe * (n-1);
61 for (src=0; src<n; src++) {
63 if (read(rfds[src], buf, sizeof(buf)) != sizeof(buf)) {
68 snum = phys2log(src, stripe, n, layout);
72 chunk = stripe*(n-1)+snum;
74 dstripe = chunk/(m-1);
75 dnum = log2phys(chunk-(stripe*(m-1)), dstripe, m, layout);
76 llseek(wfds[dnum], dstripe*chunksize+(offset*4096), 0);
77 write(wfds[dnum], buf, sizeof(buf));