Merge tag 'fixes-for-v4.1-rc2' of https://github.com/rjarzmik/linux into fixes
[linux-2.6-block.git] / lib / raid6 / int.uc
index 5b50f8dfc5d244efa4678e1034da785b296559fd..558aeac9342aa8e4b1a40832a7fd4464cb9c06a9 100644 (file)
@@ -107,9 +107,48 @@ static void raid6_int$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
        }
 }
 
+static void raid6_int$#_xor_syndrome(int disks, int start, int stop,
+                                    size_t bytes, void **ptrs)
+{
+       u8 **dptr = (u8 **)ptrs;
+       u8 *p, *q;
+       int d, z, z0;
+
+       unative_t wd$$, wq$$, wp$$, w1$$, w2$$;
+
+       z0 = stop;              /* P/Q right side optimization */
+       p = dptr[disks-2];      /* XOR parity */
+       q = dptr[disks-1];      /* RS syndrome */
+
+       for ( d = 0 ; d < bytes ; d += NSIZE*$# ) {
+               /* P/Q data pages */
+               wq$$ = wp$$ = *(unative_t *)&dptr[z0][d+$$*NSIZE];
+               for ( z = z0-1 ; z >= start ; z-- ) {
+                       wd$$ = *(unative_t *)&dptr[z][d+$$*NSIZE];
+                       wp$$ ^= wd$$;
+                       w2$$ = MASK(wq$$);
+                       w1$$ = SHLBYTE(wq$$);
+                       w2$$ &= NBYTES(0x1d);
+                       w1$$ ^= w2$$;
+                       wq$$ = w1$$ ^ wd$$;
+               }
+               /* P/Q left side optimization */
+               for ( z = start-1 ; z >= 0 ; z-- ) {
+                       w2$$ = MASK(wq$$);
+                       w1$$ = SHLBYTE(wq$$);
+                       w2$$ &= NBYTES(0x1d);
+                       wq$$ = w1$$ ^ w2$$;
+               }
+               *(unative_t *)&p[d+NSIZE*$$] ^= wp$$;
+               *(unative_t *)&q[d+NSIZE*$$] ^= wq$$;
+       }
+
+}
+
 const struct raid6_calls raid6_intx$# = {
        raid6_int$#_gen_syndrome,
-       NULL,           /* always valid */
+       raid6_int$#_xor_syndrome,
+       NULL,                   /* always valid */
        "int" NSTRING "x$#",
        0
 };