143 Commits

Author SHA1 Message Date
Tim Burke
e1e11e42c7 Allow up to 256 total fragments
... rather than the current limit of 32.

Note that some backends have much lower limits, both before and after:

- jerasure_rs_cauchy caps out at 16 fragments
- the flat xor codes in general are much more prescriptive regarding
  number of data and parity fragments

Those limits are still in place, but the other publicly accessible
backends all seem to support up to the new limit.

Change-Id: Icbc7b2e505442e5b3eb2b844637d5270be6de4d1
Signed-off-by: Tim Burke <tim.burke@gmail.com>
2026-03-26 21:35:52 -07:00
aitassou
48c05f9da1 feature: LRC (locally repairable code) backend
This is similar to the isa_l_rs_vand_inv backend, but takes an additional
parameter l, the number of local parities. The first g := m - l parities
are "global" parities and computed exactly the same as for isa_l_rs_vand_inv.
The last l parities are "local" parities, whose coefficients may be combined
into one additional global parity. As a result, decoding will succeed for
all possible sets of k + l - 1 fragments. Each local parity is grouped
with a set of data fragments such that any one of them may be reconstructed
from the others, rather than requiring a full k fragments. For example,
given a scheme like k = 8, m = 4, l = 2, then

* fragments 0 through 7 are data fragments
* fragments 8 and 9 are global parities
* fragments 10 and 11 are local parities
* any set of 9 unique fragments will be able to decode the original data
* any set of 4 unique fragments from 0, 1, 2, 3, and 10 will be able to
  reconstruct the missing fragment and similarly
* any set of 4 unique fragments from 4, 5, 6, 7, and 11 will be able to
  reconstruct the missing fragment.

If k is not evenly divisible by l, groups are sized to be within one
fragment of each other, with the larger groups having earlier data
fragments. For example, given a scheme like k = 15, m = 5, l = 4, then
the local reconstruction groups are

* fragments {0, 1, 2, 3, 16}
* fragments {4, 5, 6, 7, 17}
* fragments {8, 9, 10, 11, 18}
* fragments {12, 13, 14, 19}

Co-Authored-By: Tim Burke <tim.burke@gmail.com>
Signed-off-by: Tim Burke <tim.burke@gmail.com>
Change-Id: I2884cda24ba72d4025b175f4357ccd7ffbb48c63
2026-02-27 14:13:39 -08:00
Tim Burke
a87ddc7071 Add optional check_reconstruct_fragments function
This function should return either 0 or -EINSUFFFRAGS and can be used
as a quick check ahead of actually attempting reconstruction. If not
provided, default to checking for at least k fragments.

Implement the new function for flat xor codes so they can reconstruct
in more cases.

Change-Id: Ifa373e4ef8ef3caedb709c40c2b2bfd6fdf6ff7e
Signed-off-by: Tim Burke <tim.burke@gmail.com>
2026-01-12 09:56:26 -08:00
Tim Burke
b4f0972b11 Get some backend-specific knowledge out of erasurecode.c
Use a flag in the backend's declared ops instead -- then if any new
backends get added that also need to go through the backend's decode
routine even when provided with nothing but "data" fragments, we don't
have to keep updating erasurecode.c

Change-Id: I10c9a369572ded43046e33f37bb9403b82f1b830
Signed-off-by: Tim Burke <tim.burke@gmail.com>
2025-11-27 18:52:42 -08:00
Tim Burke
7c7373b812 Make header files more stand-alone
If a header file references erasurecode_backend.h structures, it ought
to include the header file.

Note that the already-present

   #ifndef _ERASURECODE_BACKEND_H_
   #define _ERASURECODE_BACKEND_H_
   ...
   #endif  // _ERASURECODE_BACKEND_H_

guards ensure we don't get multiple definitions.

Change-Id: I5b8b63452b5751295cf89236693f98378f949e18
2025-08-29 14:00:20 -07:00
Tim Burke
edae314559 Release 1.7.1
Change-Id: I41d63eabdfebff29d453d0d060acc7d3cd58e40b
Signed-off-by: Tim Burke <tim.burke@gmail.com>
2025-08-21 21:48:47 +00:00
aitassou
5d25e4a663 Add new ISA-L backend for new encoding matrix
When parity is higher than 5, the rs_vand decoding matrix is not invertible
for some combinations of missing data and parity.
Add new backend with modified gen matrix that is suited when parity >=
5.
Use rs_cauchy or new modified matrix when parity >= 5.

Related-Bug: #1639691

Co-Authored-By: Tim Burke <tim.burke@gmail.com>

Change-Id: I09abfc619893da7fd3d0740fed3586fdd46791d9
2025-07-29 11:38:04 +02:00
Zuul
884154ab66 Merge "Slim down our exposed symbols" 2025-04-25 22:22:54 +00:00
Tim Burke
acd8fe60f9 Release 1.6.5
Change-Id: I0973498997bf384f8e6381d90040b4dfcb108749
2024-10-23 16:41:47 -07:00
Tim Burke
ea534c61a9 Slim down our exposed symbols
We put way too much stuff out there; we don't need to expose it all.

Change-Id: Ic1080a8c9747f044902b0f00d43cc241befa8b27
2024-09-23 08:29:35 -07:00
Tim Burke
412e2903a4 Fix Jerasurecode .so name
Some distributions (such as Ubuntu, and presumably Debian) provide only
libJerasure.so.2.0.0 and libJerasure.so.2 (as a symlink to the specific
version), with no libJerasure.so symlink. On those, some tests would
previously erroneously skip with

   Could not open Jerasure backend.  Install Jerasure or fix
   LD_LIBRARY_PATH.  Passing.

Change-Id: I778543e7c4cfb37d1baf1ee9a1823a809a343343
2024-09-13 13:10:55 -07:00
Zuul
bd3f46d87c Merge "Enforce strict prototypes" 2024-08-27 23:39:34 +00:00
Tim Burke
329537b549 Enforce strict prototypes
Related-Bug: #2027885
Change-Id: I81b518ff9a434b6a9cf43ee1578ab232a857f407
2024-08-15 13:52:31 -07:00
Tim Burke
e97809b89e Fix forward definition of liberasurecode_crc32_alt
It's always taken a size_t size, ever since it was introduced in
05b1a3bde1 as crc32

Closes-Bug: #2051613
Change-Id: Ic2aabb75c5e42ae4e6eeb3dd990a6093828f5615
2024-08-15 12:53:25 -07:00
Tim Burke
c65017d9b1 Release 1.6.4
Change-Id: I46df223542c22c460e6ed89a80d19d1cc4cb3452
2024-08-14 09:52:13 -07:00
Takashi Kajinami
ca2caab1ad Use spaces for code indent, instead of tabs
Some files use tabs instead of spaces for indent. Even some other
files use both of tabs and spaces which is quite confusing.

This updates all *.c files and *.h files to use spaces consistently.
Note that indent width is still inconsistent (2 vs 4), which may be
fixed later.

Change-Id: I7c0b2629785bfbaf3d0a06d8d81aa29c00168083
2024-01-27 17:03:16 +09:00
Takashi Kajinami
ee1d5548b4 Replace CRLF by LF
We use LF instead of CRLF in general.

Change-Id: I81b7e30394db32293d990adfb923541f405da7e1
2024-01-27 12:17:49 +09:00
Tim Burke
f592409bcc Release 1.6.3
Change-Id: I7214aeecc3c568d7b0be5db441d62ca7901ec855
2022-04-08 23:59:40 +00:00
Tim Burke
53b5c5649b Add build-time option to suffix library names sent to dlopen
This is useful when repacking libraries for python wheels, for example.

Change-Id: Ie7b36584de5054c14a9b77d87a5c5fa5cc7a3719
2021-10-26 15:20:10 -07:00
Tim Burke
9dccbc9ff1 Release 1.6.2
Change-Id: I733c4bcf28d845aa0413ef4af06cdab6bc25cc7b
2020-10-08 14:46:14 -07:00
Tim Burke
917859e239 1.6.1 release
Change-Id: Iaa6cc5bb06e715aafb3ecab86ae7cde6ef30413d
2019-05-23 16:03:58 -07:00
Thiago da Silva
7df6c25191 Release 1.6.0
Change-Id: I97b85f1b37952aaede168e274d2f4a74d3b9aaa8
2018-09-21 10:28:15 -04:00
Tim Burke
7b547e0e46 Allow reading of little-endian frags on big-endian
... and vice-versa. We'll fix up frag header values for our output
parameter from liberasurecode_get_fragment_metadata but otherwise
avoid manipulating the in-memory fragment much.

Change-Id: Idd6833bdea60e27c9a0148ee28b4a2c1070be148
2018-09-11 21:58:34 -06:00
Tim Burke
e426aee95b Un-inline get/set_metatdata_chksum
Each was only really used in one place, they had some strange return types,
and recent versions of clang on OS X would refuse to compile with

erasurecode_helpers.c:531:26: error: taking address of packed member 'metadata_chksum' of
      class or structure 'fragment_header_s' may result in an unaligned pointer value
      [-Werror,-Waddress-of-packed-member]
    return (uint32_t *) &header->metadata_chksum;
                         ^~~~~~~~~~~~~~~~~~~~~~~

We don't really *care* about the pointer; we just want the value!

Change-Id: I8a5e42312948a75f5dd8b23b6f5ccfa7bd22eb1d
2017-07-06 18:02:02 +00:00
Tim Burke
a9b20ae6a3 Use zlib for CRC-32
Previously, we had our own CRC that was almost but not quite like
zlib's implementation. However,

* it hasn't been subjected to the same rigor with regard to error-detection
  properties and
* it may not even get used, depending upon whether zlib happens to get
  loaded before or after liberasurecode.

Now, we'll use zlib's CRC-32 when writing new frags, while still
tolerating frags that were created with the old implementation.

Change-Id: Ib5ea2a830c7c23d66bf2ca404a3eb84ad00c5bc5
Closes-Bug: 1666320
2017-07-06 17:40:38 +00:00
Jenkins
24038b3588 Merge "Release 1.5.0" 2017-06-29 17:36:37 +00:00
Pete Zaitcev
960cdd09dc Stop using ceill() to compute padded data size
The well-known idiom to compute a required number of data blocks
of size B to contain data of length d is:

     (d + (B-1))/B

The code we use, with ceill(), computes the same value, but does
it in an unorthodox way. This makes a reviewer to doubt himself
and even run tests to make sure we're really computing the
obvious thing.

Apropos the reviewer confusion, the code in Phazr.IO looks weird.
It uses (word_size - hamming_distance) to compute the necessary
number of blocks... but then returns the amount of memory needed
to store blocks of a different size (word_size). We left all of it
alone and return exactly the same values that the old computation
returned.

All these computations were the only thing in the code that used
-lm, so drop that too.

Coincidentially, this patch solves the crash of distro-built
packages of liberasurecode (see Red Hat bug #1454543). But it's
a side effect. Expect a proper patch soon.

Change-Id: Ib297f6df304abf5ca8c27d3392b1107a525e0be0
2017-06-06 14:53:45 -04:00
Thiago da Silva
063885cc3c Release 1.5.0
Change-Id: I6903e11a24f548a07f924cef8f0bc8ba3c456ef0
2017-06-05 14:32:32 -04:00
Jim Cheung
06e50ea86b Add Phazr.IO libphazr backend to liberasurecode
Currently, there are several implementations of erasure codes that are
available within OpenStack Swift.  Most, if not all, of which are based
on the Reed Solomon coding algorithm.

Phazr.IO’s Erasure Coding technology uses a patented algorithm which are
significantly more efficient and improves the speed of coding, decoding
and reconstruction.  In addition, Phazr.IO Erasure Code use a non-systematic
algorithm which provides data protection at rest and in transport without
the need to use encryption.

Please contact support@phazr.io for more info on our technology.

Change-Id: I4e40d02a8951e38409ad3c604c5dd6f050fa7ea0
2017-02-28 11:14:11 -08:00
Jenkins
0794b31c62 Merge "1.4.0 release" 2016-12-08 20:31:18 +00:00
Thiago da Silva
448c7d0d1c 1.4.0 release
Change-Id: I1d8d6b5711a503eaa7c57c70b4c20a329f572af2
Signed-off-by: Thiago da Silva <thiago@redhat.com>
2016-12-08 19:57:09 +00:00
Jenkins
dc77b681aa Merge "Add get_version functionality to liberasurecode lib" 2016-12-08 19:54:37 +00:00
Kota Tsuyuzaki
8d067ab2f6 ISA-L Cauchy support
This is for supporting ISA-L cauchy based matrix. The difference
from isa_l_rs_vand is only the matrix to use the encode/decode calculation.

As a known issue, isa_l_rs_vand backend has constraint for the
combinations of the available fragment to be able to decode/reconstuct.
(See related change in detail)

To avoid the constraint, this patch adds another isa-l backend to use
cauchy matrix and keep the backward compatibility, this is in
another isa_l_rs_cauchy namespace.

For implementation consieration, the code is almost same except the matrix
generation fucntion so that this patch makes isa_l_common.c file for
gathering common fucntions like init/encode/decode/reconstruct. And then the
common init funciton takes an extra args "gen_matrix_func_name" for entry
point to load the fucntion by dlsym from isa-l .so file.

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>

Related-Change: Icee788a0931fe692fe0de31fabc4ba450e338a87
Change-Id: I6eb150d9d0c3febf233570fa7729f9f72df2e9be
2016-12-06 17:08:55 -08:00
Kota Tsuyuzaki
09d8bbf361 Add get_version functionality to liberasurecode lib
Currently, we have liberasurecode version info in the header and pyeclib
is using the info to detect the version. However it's a bit painful
because it requires to rebuild pyeclib c code for you to see the actual
installed version.

This addition for liberasurecode_get_version enables caller to get the
version integer from compiled shared library file (.so) and it will
rescure to re-compiled operation from pyeclib.

Change-Id: I8161ea7da3b069e83c93e11cb41ce12fa60c6f32
2016-12-04 20:56:24 -08:00
John Dickinson
0a2c06b8b4 Version bump to 1.3.1
Change-Id: Ia45c7b46ea45dee6f306afe291fe6a908eb41d70
2016-11-09 22:43:35 -08:00
Kota Tsuyuzaki
cb0daba975 Add get_by_desc ret val handling to get_fragment_size
As well as any other callers, libersurecode_get_fragment_size should
handle the return value of liberasurecode_get_backend_instance_by_desc.

Otherwise, get_by_desc can return NULL and it causes an invalid memory
access in librerasurecode_get_fragment_size.

Change-Id: I489f8b5d049610863b5e0b477b6ff70ead245b55
2016-09-07 20:22:47 -07:00
Tushar Gohad
a6a8d2018d Fragment metadata checksumming support 2016-03-10 07:33:16 +00:00
Timur Alperovich
c7a94df072 Add a method to check if a backend is present.
Uses dlopen to check if a backend is present. This may be used by
consumers who need to check which backends are present on a system.

Issue #23
2016-03-08 22:06:19 -08:00
Ondřej Nový
9f10068e3e Don't use PATH_MAX const.
There are systems, for example Hurd, which doesn't define this constant
because there are no such limit. See [1] link for explanation.

[1] http://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
2016-02-28 10:54:23 -07:00
Tushar Gohad
8788462b7e Fix minor rev 2015-12-10 04:14:37 -07:00
Tushar Gohad
398c48c95d Split helpers.h include for backward compatibility
Users of liberasurecode <= 1.0.7 used alloc/free helpers
(which they shouldn't have).  This change is to make sure
we are still able to those older revs of programs and they
work with newer liberasurecode.
2015-09-22 21:47:15 +00:00
Tushar Gohad
dc11fba685 Eliminate erasurecode_stdinc.h dependency on log.h 2015-09-18 16:42:43 +00:00
Tushar Gohad
5ac6ae9c12 Move fragment_header defn to main erasurecode header 2015-09-17 23:23:01 +00:00
Tushar Gohad
0c703b047a Release 1.0.9 2015-09-06 06:26:28 +00:00
Kota Tsuyuzaki
c9ce822825 Enforce the (k + m < 32) limit, add unit tests 2015-08-18 08:30:34 +00:00
Tushar Gohad
63829197d5 Rename MAJOR, MINOR version macros 2015-08-06 19:46:09 +00:00
Tushar Gohad
fdb36f1e7a Rename remaining INTERNAL_RS_VAND instances
... to LIBERASURECODE_RS_VAND
2015-07-20 04:19:09 +00:00
Kevin Greenan
e9ca485c7c Plugging new internal RS backend into liberasurecode. 2015-06-18 12:31:17 -07:00
Tushar Gohad
e46c434e36 Add missing #ifdef __cplusplus closure, Fixes #14 (take 2) 2015-05-01 07:10:24 -07:00
Tushar Gohad
7e3b245b77 Add missing #ifdef __cplusplus closure, Fixes #14 2015-04-30 14:28:23 -07:00