mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-07-08 18:06:18 +00:00
Write EC when writing data blocks.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
52
include/erasure_internal.h
Normal file
52
include/erasure_internal.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2026 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBAARUFORMAT_ERASURE_INTERNAL_H
|
||||
#define LIBAARUFORMAT_ERASURE_INTERNAL_H
|
||||
|
||||
#include "aaruformat/context.h"
|
||||
#include "aaruformat/structs/data.h"
|
||||
|
||||
/**
|
||||
* @brief Accumulate parity for a data block just written to disk.
|
||||
*
|
||||
* Called from aaruf_close_current_block() after writing header + payload.
|
||||
*/
|
||||
void ec_accumulate_data_block(aaruformat_context *ctx, const BlockHeader *block_header, const uint8_t *lzma_props,
|
||||
const uint8_t *payload, uint32_t payload_size, uint64_t file_offset);
|
||||
|
||||
/**
|
||||
* @brief Flush a completed data stripe slot: write parity blocks and record descriptor.
|
||||
*/
|
||||
void ec_flush_data_stripe(aaruformat_context *ctx, uint32_t slot);
|
||||
|
||||
/**
|
||||
* @brief Flush partial stripes, write ECMB and recovery footer.
|
||||
*
|
||||
* Called from aaruf_finalize_write() after index is written.
|
||||
*/
|
||||
void ec_finalize(aaruformat_context *ctx);
|
||||
|
||||
/**
|
||||
* @brief Free all erasure coding state.
|
||||
*
|
||||
* Called from aaruf_close().
|
||||
*/
|
||||
void ec_free(aaruformat_context *ctx);
|
||||
|
||||
#endif /* LIBAARUFORMAT_ERASURE_INTERNAL_H */
|
||||
Reference in New Issue
Block a user