Verified Commit 3cf492aa authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Rename: chnk_lpad() -> block_overrun()

parent 4eef12e5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+6 −4
Original line number Diff line number Diff line
@@ -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
@@ -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(),
@@ -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
@@ -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(),
+1 −1
Original line number Diff line number Diff line
@@ -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);
+6 −6
Original line number Diff line number Diff line
@@ -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 ") {

@@ -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);
                }
@@ -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);
                }
@@ -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);
                }
@@ -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);
            }
@@ -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;