Merge pull request #777 from krishnasrinivas/missingEncodedBlocksCount

Use missingEncodedBlocksCount directly instead of "-1" workaround in …
master
Harshavardhana 10 years ago
commit 6707e58bb3
  1. 3
      pkg/erasure/ctypes.go
  2. 6
      pkg/erasure/ec_minio_decode.c
  3. 10
      pkg/erasure/erasure_decode.go

@ -25,6 +25,9 @@ import (
// intSlice2CIntArray converts Go int slice to C int array
func intSlice2CIntArray(srcErrList []int) *C.int32_t {
if len(srcErrList) == 0 {
return (*C.int32_t)(unsafe.Pointer(nil))
}
var sizeErrInt = int(unsafe.Sizeof(srcErrList[0]))
switch sizeInt {
case sizeErrInt:

@ -22,10 +22,10 @@
#include "ec_minio_common.h"
static
int32_t _minio_src_index_in_error (int r, int32_t *error_index)
int32_t _minio_src_index_in_error (int r, int32_t *error_index, int errs)
{
int i;
for (i = 0; error_index[i] != -1; i++) {
for (i = 0; i < errs; i++) {
if (error_index[i] == r) {
// true
return 1;
@ -88,7 +88,7 @@ int minio_init_decoder (int32_t *error_index,
uint32_t tmp_decode_index[k];
for (i = 0, r = 0; i < k; i++, r++) {
while (_minio_src_index_in_error(r, error_index))
while (_minio_src_index_in_error(r, error_index, errs))
r++;
for (j = 0; j < k; j++) {
input_matrix[k * i + j] = encode_matrix[k * r + j];

@ -63,11 +63,9 @@ func (e *Erasure) Decode(encodedDataBlocks [][]byte, dataLen int) (decodedData [
missingEncodedBlocksCount++
}
}
missingEncodedBlocks[missingEncodedBlocksCount] = -1
missingEncodedBlocksCount++
// Cannot reconstruct original data. Need at least M number of data or parity blocks.
if missingEncodedBlocksCount-1 > m {
if missingEncodedBlocksCount > m {
return nil, fmt.Errorf("Cannot reconstruct original data. Need at least [%d] data or parity blocks", m)
}
@ -86,7 +84,7 @@ func (e *Erasure) Decode(encodedDataBlocks [][]byte, dataLen int) (decodedData [
var decodeMatrix, decodeTbls *C.uchar
var decodeIndex *C.uint32_t
C.minio_init_decoder(missingEncodedBlocksC, C.int(k), C.int(n), C.int(missingEncodedBlocksCount-1),
C.minio_init_decoder(missingEncodedBlocksC, C.int(k), C.int(n), C.int(missingEncodedBlocksCount),
e.encodeMatrix, &decodeMatrix, &decodeTbls, &decodeIndex)
// cache this for future needs
@ -102,14 +100,14 @@ func (e *Erasure) Decode(encodedDataBlocks [][]byte, dataLen int) (decodedData [
}
// Get pointers to source "data" and target "parity" blocks from the output byte array.
ret := C.minio_get_source_target(C.int(missingEncodedBlocksCount-1), C.int(k), C.int(m), missingEncodedBlocksC,
ret := C.minio_get_source_target(C.int(missingEncodedBlocksCount), C.int(k), C.int(m), missingEncodedBlocksC,
e.decodeIndex, (**C.uchar)(unsafe.Pointer(&pointers[0])), &source, &target)
if int(ret) == -1 {
return nil, errors.New("Unable to decode data")
}
// Decode data
C.ec_encode_data(C.int(encodedBlockLen), C.int(k), C.int(missingEncodedBlocksCount-1), e.decodeTbls,
C.ec_encode_data(C.int(encodedBlockLen), C.int(k), C.int(missingEncodedBlocksCount), e.decodeTbls,
source, target)
// Allocate buffer to output buffer

Loading…
Cancel
Save