Partially corrupt fragment set and decode

Issue #22 new
Tushar Gohad repo owner created an issue

@kmgreen2 when partitioning available fragments into data and parity during decode, we seem to terminate the decode with -EBADHEADER .. should we not try harder? i.e., should we just skip the bad fragment and check in the end for -EINSUFFRAGS? That would make the "missing" calculations also valid .. with the current version of get_fragment_partition(), we'll never have anything in "missing" :)

int get_fragment_partition(
        int k, int m,
        char **fragments, int num_fragments,
        char **data, char **parity, int *missing)
{
    int i = 0;
    int num_missing = 0;
    int index;

    /*
     * Set all data and parity entries to NULL
     */
    for (i = 0; i < k; i++) {
        data[i] = NULL;
    }
    for (i = 0; i < m; i++) {
        parity[i] = NULL;
    }

    /*
     * Fill in data and parity with available fragments
     */ 
    for (i = 0; i < num_fragments; i++) {
        index = get_fragment_idx(fragments[i]);
        if (index < 0 || index > (k + m)) {
            return -EBADHEADER;
        }
        if (index < k) {
            data[index] = fragments[i];
        } else {
            parity[index - k] = fragments[i];
        }
    }

    /*
     * Fill in missing array with missing indexes
     */
    for (i = 0; i < k; i++) {
        if (NULL == data[i]) {
            missing[num_missing] = i;
            num_missing++;
        }
    }
    for (i = 0; i < m; i++) {
        if (NULL == parity[i]) {
            missing[num_missing] = i + k;
            num_missing++;
        }
    }
    // TODO: In general, it is possible to reconstruct one or more fragments
    // when more than m fragments are missing (e.g. flat XOR codes)
    return (num_missing > m) ? -EINSUFFFRAGS : 0;
}

Comments (4)

  1. Tushar Gohad reporter

    @kmgreen2 not sure if this is still an issue. Can you please take a look and comment?

  2. Tushar Gohad reporter

    @kmgreen2 yep and keep going forward with decode as long as we have at least k good fragments?

  3. Log in to comment