Write EC when writing data blocks.

This commit is contained in:
2026-04-11 20:28:48 +01:00
parent eb188f48d2
commit af4503f376
8 changed files with 686 additions and 3 deletions

View File

@@ -374,6 +374,21 @@ typedef struct aaruformat_context
uint64_t wii_cached_physical_group; ///< Physical group number of cached block
bool wii_cache_valid; ///< Whether the encrypted group cache is valid
bool wii_building_crypto_block; ///< True while gathering sectors for re-encryption (suppresses recursion)
/* Erasure coding (write path) */
uint8_t ec_algorithm; ///< ErasureCodingAlgorithm (0=XOR, 1=RS-Vandermonde).
uint16_t ec_K; ///< Data blocks per stripe.
uint16_t ec_M; ///< Parity blocks per stripe.
uint32_t ec_data_shard_size; ///< Max on-disk block size for data blocks (fixed at creation).
void *ec_rs_ctx; ///< rs_context* (opaque RS codec), NULL if EC disabled.
uint8_t **ec_data_parity; ///< Array of K * M parity buffers (interleaved stripe slots).
uint64_t *ec_data_block_offsets; ///< Array of K * K file offsets for blocks in active stripes.
uint32_t *ec_data_block_sizes; ///< Array of K * K actual on-disk sizes for blocks in active stripes.
uint64_t *ec_data_shard_crcs; ///< Array of K * K CRC64 values for blocks in active stripes.
uint16_t *ec_data_stripe_counts; ///< Array of K: blocks accumulated per stripe slot.
uint32_t ec_total_data_blocks; ///< Total data blocks written (counter for round-robin assignment).
UT_array *ec_data_stripes; ///< Completed data stripe descriptors (serialized to ECMB).
bool ec_enabled; ///< True if erasure coding is active.
} aaruformat_context;
#ifndef AARUFORMAT_CONTEXT_DECLARED

View File

@@ -292,4 +292,7 @@ AARU_EXPORT int have_arm_crypto();
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t *data, long len);
#endif
/* Erasure coding */
AARU_EXPORT int32_t AARU_CALL aaruf_set_erasure_coding(void *context, uint8_t algorithm, uint16_t K, uint16_t M);
#endif // LIBAARUFORMAT_DECLS_H