Loading include/global/arithmetic/arithmetic.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ align_right(const uint64_t offset, const size_t block_size) { * @returns the distance in bytes between the left-side boundary of @offset */ constexpr size_t chnk_lpad(const uint64_t offset, const size_t block_size) { block_overrun(const uint64_t offset, const size_t block_size) { // This check is automatically removed in release builds assert(is_power_of_2(block_size)); return static_cast<uint64_t>(offset) & (block_size - 1u); Loading src/client/rpc/forward_data.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -127,7 +127,8 @@ forward_write(const string& path, const void* buf, const bool append_flag, // receiver of first chunk must subtract the offset from first chunk if(target == chnk_start_target) { total_chunk_size -= chnk_lpad(offset, gkfs::config::rpc::chunksize); total_chunk_size -= block_overrun(offset, gkfs::config::rpc::chunksize); } // receiver of last chunk must subtract Loading @@ -146,7 +147,7 @@ forward_write(const string& path, const void* buf, const bool append_flag, path, // first offset in targets is the chunk with // a potential offset chnk_lpad(offset, gkfs::config::rpc::chunksize), target, block_overrun(offset, gkfs::config::rpc::chunksize), target, CTX->hosts().size(), // number of chunks handled by that destination target_chnks[target].size(), Loading Loading @@ -303,7 +304,8 @@ forward_read(const string& path, void* buf, const off64_t offset, // receiver of first chunk must subtract the offset from first chunk if(target == chnk_start_target) { total_chunk_size -= chnk_lpad(offset, gkfs::config::rpc::chunksize); total_chunk_size -= block_overrun(offset, gkfs::config::rpc::chunksize); } // receiver of last chunk must subtract Loading @@ -322,7 +324,7 @@ forward_read(const string& path, void* buf, const off64_t offset, path, // first offset in targets is the chunk with // a potential offset chnk_lpad(offset, gkfs::config::rpc::chunksize), target, block_overrun(offset, gkfs::config::rpc::chunksize), target, CTX->hosts().size(), // number of chunks handled by that destination target_chnks[target].size(), Loading src/daemon/ops/data.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ ChunkTruncateOperation::truncate_abt(void* _arg) { auto chunk_id_start = chnk_id_for_offset(size, gkfs::config::rpc::chunksize); // do not last delete chunk if it is in the middle of a chunk auto left_pad = chnk_lpad(size, gkfs::config::rpc::chunksize); auto left_pad = block_overrun(size, gkfs::config::rpc::chunksize); if(left_pad != 0) { GKFS_DATA->storage()->truncate_chunk_file(path, chunk_id_start, left_pad); Loading tests/unit/test_utils_arithmetic.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -221,7 +221,7 @@ SCENARIO(" offsets can be right-aligned to block size boundaries ", } SCENARIO(" overrun distance can be computed correctly ", "[utils][numeric][chnk_lpad]") { "[utils][numeric][block_overrun]") { GIVEN(" a block size ") { Loading @@ -237,7 +237,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals 0 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = 0; REQUIRE(overrun == expected_overrun); } Loading @@ -251,7 +251,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals offset ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = offset; REQUIRE(overrun == expected_overrun); } Loading @@ -264,7 +264,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals block_size - 1 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = block_size - 1; REQUIRE(overrun == expected_overrun); } Loading @@ -278,7 +278,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals 0 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = 0; REQUIRE(overrun == expected_overrun); } Loading @@ -293,7 +293,7 @@ SCENARIO(" overrun distance can be computed correctly ", THEN(" the computed overrun distance equals the difference between " "offset and its closest block's left boundary ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = offset - static_cast<uint64_t>(offset / block_size) * block_size; Loading Loading
include/global/arithmetic/arithmetic.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ align_right(const uint64_t offset, const size_t block_size) { * @returns the distance in bytes between the left-side boundary of @offset */ constexpr size_t chnk_lpad(const uint64_t offset, const size_t block_size) { block_overrun(const uint64_t offset, const size_t block_size) { // This check is automatically removed in release builds assert(is_power_of_2(block_size)); return static_cast<uint64_t>(offset) & (block_size - 1u); Loading
src/client/rpc/forward_data.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -127,7 +127,8 @@ forward_write(const string& path, const void* buf, const bool append_flag, // receiver of first chunk must subtract the offset from first chunk if(target == chnk_start_target) { total_chunk_size -= chnk_lpad(offset, gkfs::config::rpc::chunksize); total_chunk_size -= block_overrun(offset, gkfs::config::rpc::chunksize); } // receiver of last chunk must subtract Loading @@ -146,7 +147,7 @@ forward_write(const string& path, const void* buf, const bool append_flag, path, // first offset in targets is the chunk with // a potential offset chnk_lpad(offset, gkfs::config::rpc::chunksize), target, block_overrun(offset, gkfs::config::rpc::chunksize), target, CTX->hosts().size(), // number of chunks handled by that destination target_chnks[target].size(), Loading Loading @@ -303,7 +304,8 @@ forward_read(const string& path, void* buf, const off64_t offset, // receiver of first chunk must subtract the offset from first chunk if(target == chnk_start_target) { total_chunk_size -= chnk_lpad(offset, gkfs::config::rpc::chunksize); total_chunk_size -= block_overrun(offset, gkfs::config::rpc::chunksize); } // receiver of last chunk must subtract Loading @@ -322,7 +324,7 @@ forward_read(const string& path, void* buf, const off64_t offset, path, // first offset in targets is the chunk with // a potential offset chnk_lpad(offset, gkfs::config::rpc::chunksize), target, block_overrun(offset, gkfs::config::rpc::chunksize), target, CTX->hosts().size(), // number of chunks handled by that destination target_chnks[target].size(), Loading
src/daemon/ops/data.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ ChunkTruncateOperation::truncate_abt(void* _arg) { auto chunk_id_start = chnk_id_for_offset(size, gkfs::config::rpc::chunksize); // do not last delete chunk if it is in the middle of a chunk auto left_pad = chnk_lpad(size, gkfs::config::rpc::chunksize); auto left_pad = block_overrun(size, gkfs::config::rpc::chunksize); if(left_pad != 0) { GKFS_DATA->storage()->truncate_chunk_file(path, chunk_id_start, left_pad); Loading
tests/unit/test_utils_arithmetic.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -221,7 +221,7 @@ SCENARIO(" offsets can be right-aligned to block size boundaries ", } SCENARIO(" overrun distance can be computed correctly ", "[utils][numeric][chnk_lpad]") { "[utils][numeric][block_overrun]") { GIVEN(" a block size ") { Loading @@ -237,7 +237,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals 0 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = 0; REQUIRE(overrun == expected_overrun); } Loading @@ -251,7 +251,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals offset ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = offset; REQUIRE(overrun == expected_overrun); } Loading @@ -264,7 +264,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals block_size - 1 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = block_size - 1; REQUIRE(overrun == expected_overrun); } Loading @@ -278,7 +278,7 @@ SCENARIO(" overrun distance can be computed correctly ", CAPTURE(offset, block_size); THEN(" the computed overrun distance equals 0 ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = 0; REQUIRE(overrun == expected_overrun); } Loading @@ -293,7 +293,7 @@ SCENARIO(" overrun distance can be computed correctly ", THEN(" the computed overrun distance equals the difference between " "offset and its closest block's left boundary ") { const uint64_t overrun = chnk_lpad(offset, block_size); const uint64_t overrun = block_overrun(offset, block_size); const uint64_t expected_overrun = offset - static_cast<uint64_t>(offset / block_size) * block_size; Loading