Loading ifs/include/global/blocks_calc_util.hpp→ifs/include/global/chunk_calc_util.hpp +88 −0 Original line number Diff line number Diff line Loading @@ -24,65 +24,65 @@ inline int log2(uint64_t n){ /** * Align an @offset to the closest left side block boundary * Align an @offset to the closest left side chunk boundary */ inline off64_t lalign(const off64_t offset, const size_t block_size) { return offset & ~(block_size - 1); inline off64_t chnk_lalign(const off64_t offset, const size_t chnk_size) { return offset & ~(chnk_size - 1); } /** * Align an @offset to the closest right side block boundary * Align an @offset to the closest right side chunk boundary */ inline off64_t ralign(const off64_t offset, const size_t block_size) { return lalign(offset + block_size, block_size); inline off64_t chnk_ralign(const off64_t offset, const size_t chnk_size) { return chnk_lalign(offset + chnk_size, chnk_size); } /** * Return the padding (bytes) that separates the @offset from the closest * left side block boundary * left side chunk boundary * * If @offset is a boundary the resulting padding will be 0 */ inline size_t lpad(const off64_t offset, const size_t block_size) { return offset % block_size; inline size_t chnk_lpad(const off64_t offset, const size_t chnk_size) { return offset % chnk_size; } /** * Return the padding (bytes) that separates the @offset from the closest * right side block boundary * right side chunk boundary * * If @offset is a boundary the resulting padding will be 0 */ inline size_t rpad(const off64_t offset, const size_t block_size) { return (-offset) % block_size; inline size_t chnk_rpad(const off64_t offset, const size_t chnk_size) { return (-offset) % chnk_size; } /** * Given an @offset calculates the block number to which the @offset belongs * Given an @offset calculates the chunk number to which the @offset belongs * * block_num(8,4) = 2; * block_num(7,4) = 1; * block_num(2,4) = 0; * block_num(0,4) = 0; * chunk_id(8,4) = 2; * chunk_id(7,4) = 1; * chunk_id(2,4) = 0; * chunk_id(0,4) = 0; */ inline uint64_t block_num(const off64_t offset, const size_t block_size){ return lalign(offset, block_size) >> log2(block_size); inline uint64_t chnk_id_for_offset(const off64_t offset, const size_t chnk_size) { return static_cast<uint64_t>(chnk_lalign(offset, chnk_size) >> log2(chnk_size)); } /** * Return the number of blocks involved in an operation that operates * Return the number of chunks involved in an operation that operates * from @offset for a certain amount of bytes (@count). */ inline uint64_t blocks_count(const off64_t offset, const size_t count, const size_t block_size) { inline uint64_t chnk_count_for_offset(const off64_t offset, const size_t count, const size_t chnk_size) { off64_t block_start = lalign(offset, block_size); off64_t block_end = lalign(offset + count - 1, block_size); off64_t chnk_start = chnk_lalign(offset, chnk_size); off64_t chnk_end = chnk_lalign(offset + count - 1, chnk_size); return (block_end >> log2(block_size)) - (block_start >> log2(block_size)) + 1; return static_cast<uint64_t>((chnk_end >> log2(chnk_size)) - (chnk_start >> log2(chnk_size)) + 1); } ifs/src/preload/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ set(PRELOAD_HEADERS ../../include/global/rpc/ipc_types.hpp ../../include/global/rpc/rpc_types.hpp ../../include/global/rpc/rpc_utils.hpp ../../include/global/blocks_calc_util.hpp ../../include/global/chunk_calc_util.hpp ../../include/preload/adafs_functions.hpp ../../include/preload/margo_ipc.hpp ../../include/preload/open_file_map.hpp Loading ifs/src/preload/rpc/ld_rpc_data_ws.cpp +11 −11 Original line number Diff line number Diff line #include <preload/rpc/ld_rpc_data_ws.hpp> #include <global/rpc/rpc_utils.hpp> #include <global/blocks_calc_util.hpp> #include <global/chunk_calc_util.hpp> using namespace std; Loading @@ -18,8 +18,8 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl if (append_flag) offset = updated_metadentry_size - write_size; auto chnk_start = block_num(offset, CHUNKSIZE); auto chnk_end = block_num((offset + write_size) - 1, CHUNKSIZE); auto chnk_start = chnk_id_for_offset(offset, CHUNKSIZE); auto chnk_end = chnk_id_for_offset((offset + write_size) - 1, CHUNKSIZE); // Collect all chunk ids within count that have the same destination so that those are send in one rpc bulk transfer map<uint64_t, vector<uint64_t>> target_chnks{}; Loading Loading @@ -68,12 +68,12 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl auto target = targets[i]; auto total_chunk_size = target_chnks[target].size() * CHUNKSIZE; // total chunk_size for target if (target == chnk_start_target) // receiver of first chunk must subtract the offset from first chunk total_chunk_size -= lpad(offset, CHUNKSIZE); total_chunk_size -= chnk_lpad(offset, CHUNKSIZE); if (target == chnk_end_target) // receiver of last chunk must subtract total_chunk_size -= rpad(offset + write_size, CHUNKSIZE); total_chunk_size -= chnk_rpad(offset + write_size, CHUNKSIZE); // Fill RPC input rpc_in[i].path = path.c_str(); rpc_in[i].offset = lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].offset = chnk_lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].chunk_n = target_chnks[target].size(); // number of chunks handled by that destination rpc_in[i].chunk_start = chnk_start; // chunk start id of this write rpc_in[i].chunk_end = chnk_end; // chunk end id of this write Loading Loading @@ -134,8 +134,8 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl */ ssize_t rpc_send_read(const string& path, void* buf, const off64_t offset, const size_t read_size) { // Calculate chunkid boundaries and numbers so that daemons know in which interval to look for chunks auto chnk_start = block_num(offset, CHUNKSIZE); // first chunk number auto chnk_end = block_num((offset + read_size - 1), CHUNKSIZE); auto chnk_start = chnk_id_for_offset(offset, CHUNKSIZE); // first chunk number auto chnk_end = chnk_id_for_offset((offset + read_size - 1), CHUNKSIZE); // Collect all chunk ids within count that have the same destination so that those are send in one rpc bulk transfer map<uint64_t, vector<uint64_t>> target_chnks{}; Loading Loading @@ -184,13 +184,13 @@ ssize_t rpc_send_read(const string& path, void* buf, const off64_t offset, const auto target = targets[i]; auto total_chunk_size = target_chnks[target].size() * CHUNKSIZE; if (target == chnk_start_target) // receiver of first chunk must subtract the offset from first chunk total_chunk_size -= lpad(offset, CHUNKSIZE); total_chunk_size -= chnk_lpad(offset, CHUNKSIZE); if (target == chnk_end_target) // receiver of last chunk must subtract total_chunk_size -= rpad(offset + read_size, CHUNKSIZE); total_chunk_size -= chnk_rpad(offset + read_size, CHUNKSIZE); // Fill RPC input rpc_in[i].path = path.c_str(); rpc_in[i].offset = lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].offset = chnk_lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].chunk_n = target_chnks[target].size(); // number of chunks handled by that destination rpc_in[i].chunk_start = chnk_start; // chunk start id of this write rpc_in[i].chunk_end = chnk_end; // chunk end id of this write Loading Loading
ifs/include/global/blocks_calc_util.hpp→ifs/include/global/chunk_calc_util.hpp +88 −0 Original line number Diff line number Diff line Loading @@ -24,65 +24,65 @@ inline int log2(uint64_t n){ /** * Align an @offset to the closest left side block boundary * Align an @offset to the closest left side chunk boundary */ inline off64_t lalign(const off64_t offset, const size_t block_size) { return offset & ~(block_size - 1); inline off64_t chnk_lalign(const off64_t offset, const size_t chnk_size) { return offset & ~(chnk_size - 1); } /** * Align an @offset to the closest right side block boundary * Align an @offset to the closest right side chunk boundary */ inline off64_t ralign(const off64_t offset, const size_t block_size) { return lalign(offset + block_size, block_size); inline off64_t chnk_ralign(const off64_t offset, const size_t chnk_size) { return chnk_lalign(offset + chnk_size, chnk_size); } /** * Return the padding (bytes) that separates the @offset from the closest * left side block boundary * left side chunk boundary * * If @offset is a boundary the resulting padding will be 0 */ inline size_t lpad(const off64_t offset, const size_t block_size) { return offset % block_size; inline size_t chnk_lpad(const off64_t offset, const size_t chnk_size) { return offset % chnk_size; } /** * Return the padding (bytes) that separates the @offset from the closest * right side block boundary * right side chunk boundary * * If @offset is a boundary the resulting padding will be 0 */ inline size_t rpad(const off64_t offset, const size_t block_size) { return (-offset) % block_size; inline size_t chnk_rpad(const off64_t offset, const size_t chnk_size) { return (-offset) % chnk_size; } /** * Given an @offset calculates the block number to which the @offset belongs * Given an @offset calculates the chunk number to which the @offset belongs * * block_num(8,4) = 2; * block_num(7,4) = 1; * block_num(2,4) = 0; * block_num(0,4) = 0; * chunk_id(8,4) = 2; * chunk_id(7,4) = 1; * chunk_id(2,4) = 0; * chunk_id(0,4) = 0; */ inline uint64_t block_num(const off64_t offset, const size_t block_size){ return lalign(offset, block_size) >> log2(block_size); inline uint64_t chnk_id_for_offset(const off64_t offset, const size_t chnk_size) { return static_cast<uint64_t>(chnk_lalign(offset, chnk_size) >> log2(chnk_size)); } /** * Return the number of blocks involved in an operation that operates * Return the number of chunks involved in an operation that operates * from @offset for a certain amount of bytes (@count). */ inline uint64_t blocks_count(const off64_t offset, const size_t count, const size_t block_size) { inline uint64_t chnk_count_for_offset(const off64_t offset, const size_t count, const size_t chnk_size) { off64_t block_start = lalign(offset, block_size); off64_t block_end = lalign(offset + count - 1, block_size); off64_t chnk_start = chnk_lalign(offset, chnk_size); off64_t chnk_end = chnk_lalign(offset + count - 1, chnk_size); return (block_end >> log2(block_size)) - (block_start >> log2(block_size)) + 1; return static_cast<uint64_t>((chnk_end >> log2(chnk_size)) - (chnk_start >> log2(chnk_size)) + 1); }
ifs/src/preload/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ set(PRELOAD_HEADERS ../../include/global/rpc/ipc_types.hpp ../../include/global/rpc/rpc_types.hpp ../../include/global/rpc/rpc_utils.hpp ../../include/global/blocks_calc_util.hpp ../../include/global/chunk_calc_util.hpp ../../include/preload/adafs_functions.hpp ../../include/preload/margo_ipc.hpp ../../include/preload/open_file_map.hpp Loading
ifs/src/preload/rpc/ld_rpc_data_ws.cpp +11 −11 Original line number Diff line number Diff line #include <preload/rpc/ld_rpc_data_ws.hpp> #include <global/rpc/rpc_utils.hpp> #include <global/blocks_calc_util.hpp> #include <global/chunk_calc_util.hpp> using namespace std; Loading @@ -18,8 +18,8 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl if (append_flag) offset = updated_metadentry_size - write_size; auto chnk_start = block_num(offset, CHUNKSIZE); auto chnk_end = block_num((offset + write_size) - 1, CHUNKSIZE); auto chnk_start = chnk_id_for_offset(offset, CHUNKSIZE); auto chnk_end = chnk_id_for_offset((offset + write_size) - 1, CHUNKSIZE); // Collect all chunk ids within count that have the same destination so that those are send in one rpc bulk transfer map<uint64_t, vector<uint64_t>> target_chnks{}; Loading Loading @@ -68,12 +68,12 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl auto target = targets[i]; auto total_chunk_size = target_chnks[target].size() * CHUNKSIZE; // total chunk_size for target if (target == chnk_start_target) // receiver of first chunk must subtract the offset from first chunk total_chunk_size -= lpad(offset, CHUNKSIZE); total_chunk_size -= chnk_lpad(offset, CHUNKSIZE); if (target == chnk_end_target) // receiver of last chunk must subtract total_chunk_size -= rpad(offset + write_size, CHUNKSIZE); total_chunk_size -= chnk_rpad(offset + write_size, CHUNKSIZE); // Fill RPC input rpc_in[i].path = path.c_str(); rpc_in[i].offset = lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].offset = chnk_lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].chunk_n = target_chnks[target].size(); // number of chunks handled by that destination rpc_in[i].chunk_start = chnk_start; // chunk start id of this write rpc_in[i].chunk_end = chnk_end; // chunk end id of this write Loading Loading @@ -134,8 +134,8 @@ ssize_t rpc_send_write(const string& path, const void* buf, const bool append_fl */ ssize_t rpc_send_read(const string& path, void* buf, const off64_t offset, const size_t read_size) { // Calculate chunkid boundaries and numbers so that daemons know in which interval to look for chunks auto chnk_start = block_num(offset, CHUNKSIZE); // first chunk number auto chnk_end = block_num((offset + read_size - 1), CHUNKSIZE); auto chnk_start = chnk_id_for_offset(offset, CHUNKSIZE); // first chunk number auto chnk_end = chnk_id_for_offset((offset + read_size - 1), CHUNKSIZE); // Collect all chunk ids within count that have the same destination so that those are send in one rpc bulk transfer map<uint64_t, vector<uint64_t>> target_chnks{}; Loading Loading @@ -184,13 +184,13 @@ ssize_t rpc_send_read(const string& path, void* buf, const off64_t offset, const auto target = targets[i]; auto total_chunk_size = target_chnks[target].size() * CHUNKSIZE; if (target == chnk_start_target) // receiver of first chunk must subtract the offset from first chunk total_chunk_size -= lpad(offset, CHUNKSIZE); total_chunk_size -= chnk_lpad(offset, CHUNKSIZE); if (target == chnk_end_target) // receiver of last chunk must subtract total_chunk_size -= rpad(offset + read_size, CHUNKSIZE); total_chunk_size -= chnk_rpad(offset + read_size, CHUNKSIZE); // Fill RPC input rpc_in[i].path = path.c_str(); rpc_in[i].offset = lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].offset = chnk_lpad(offset, CHUNKSIZE);// first offset in targets is the chunk with a potential offset rpc_in[i].chunk_n = target_chnks[target].size(); // number of chunks handled by that destination rpc_in[i].chunk_start = chnk_start; // chunk start id of this write rpc_in[i].chunk_end = chnk_end; // chunk end id of this write Loading