Skip to content

Commit

Permalink
Fix read_io in dataservice test.
Browse files Browse the repository at this point in the history
Previous code can overflow the io_size, i.e

remaining_io_size -= sub_io_size;

where sub_io_size > remaining_io_size, and
remaining_io_size is unsigned which will be
a huge number, takes ages to finish.

Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Oct 18, 2024
1 parent 9be2a49 commit d90b54d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.4.64"
version = "6.4.65"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
5 changes: 3 additions & 2 deletions src/tests/test_data_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class BlkDataServiceTest : public testing::Test {
void read_io(uint32_t io_size) {
auto remaining_io_size = io_size;
while (remaining_io_size > 0) {
auto const bid = get_rand_blkid_to_read(io_size);
auto const bid = get_rand_blkid_to_read(remaining_io_size);
if (!bid.is_valid()) {
// didn't find any block to read, either write blk map is empty or
// all blks are pending on free.
Expand All @@ -456,6 +456,7 @@ class BlkDataServiceTest : public testing::Test {
// every piece in bid is a single block, e.g. nblks = 1
auto const nbids = bid.num_pieces();
auto sub_io_size = nbids * inst().get_blk_size();
HS_REL_ASSERT_LE(sub_io_size, remaining_io_size, "not expecting sub_io_size to exceed remaining_io_size");

// we pass crc from lambda becaues if there is any async_free_blk, the written blks in the blkcrc map will
// be removed by the time read thenVlue is called;
Expand Down Expand Up @@ -582,7 +583,7 @@ class BlkDataServiceTest : public testing::Test {
auto nbids = io_size / inst().get_blk_size(); // number of blks to read;

// nbids should not exceed max pieces that MultiBlkId can hold;
nbids = std::max(nbids, MultiBlkId::max_addln_pieces);
nbids = std::min(nbids, MultiBlkId::max_addln_pieces);

// make sure skip + nbids are in the range of m_blk_crc_map;
if (skip_nbids + nbids > m_blk_crc_map.size()) { skip_nbids = m_blk_crc_map.size() - nbids; }
Expand Down

0 comments on commit d90b54d

Please sign in to comment.