erasure-code: move to ErasureCode::{encode,decode}{,chunk}

The bulk of ErasureCodeJerasure::encode and ErasureCodeJerasure::decode
is dealing with alignment and buffer allocation. This is moved to
ErasureCode::encode and ErasureCode::decode respectively.

The jerasure specific code is isolated in the new
ErasureCodeJerasure::encode_chunks and
ErasureCodeJerasure::decode_chunks virtual functions.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: move to ErasureCode::minimum_to_decode*

The ErasureCodeJerasure::minimum_to_decode and
ErasureCodeJerasure::minimum_to_decode_with_cost methods are moved
verbatim to the base class ErasureCodeJerasure.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: move to ErasureCode::to_{int,bool}

The parameter parser helpers to_int and to_bool are moved from
ErasureCodeJerasure to ErasureCode.

The prototype is modified to return a status instead of the value. An
error ostream is provided as the last argument because ErasureCode
cannot use dout() or derr().

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: ErasureCodeInterface::get_chunk_mapping()

Add support for erasure code plugins that do not sequentially map the
chunks encoded to the corresponding index. This is mostly transparent to
the caller, except when it comes to retrieving the data chunks when
reading. For this purpose there needs to be a remapping function so the
caller has a way to figure out which chunks actually contain the data
and reorder them.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: remap chunks if not sequential

If the remap vector is not empty, use it to figure out the sequence of
data chunks.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: parse function for the mapping parameter

Each upper case letter is a data chunk. For instance:

    _AAA_AAA

is going to parse into:

   [ 1, 2, 3, 5, 6, 7 ]

the 0 and 4 positions are not used by chunks and do not show in the
mapping. Implement ErasureCode::parse to support a reasonable default
for the mapping parameter.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: rework ErasureCode*::parse methods

The ErasureCode::parse virtual function is derived in
ErasureCodeJerasure. It is reworked to share parsing arguments the
various techniques have in common. The logic is otherwise unmodified.

Signed-off-by: Loic Dachary <loic@dachary.org>