Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 3.x #558

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/merge_build_3x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
workflow_dispatch:
push:
branches:
- stable/v3.x
- master
- stable/**

jobs:
Build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_conan_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- master
- stable/v3.x
- stable/**

jobs:
Build:
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "3.8.3"
version = "3.8.4"

homepage = "https://github.corp.ebay.com/SDS/homestore"
description = "HomeStore"
Expand Down
6 changes: 5 additions & 1 deletion src/engine/blkalloc/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ struct BlkId {
static constexpr uint64_t s_chunk_num_mask{(static_cast< uint64_t >(1) << CHUNK_NUM_BITS) - 1};

public:
[[nodiscard]] static constexpr blk_count_t max_blks_in_op() { return (1 << NBLKS_BITS); }
[[nodiscard]] static constexpr blk_count_t max_blks_in_op() {
static_assert(NBLKS_BITS <= std::numeric_limits< blk_count_t >::digits,
"NBLKS_BITS is too large and may cause overflow in blk_count_t");
return (1 << NBLKS_BITS);
}
[[nodiscard]] static constexpr uint64_t max_id_int() {
return (1ull << (BLK_NUM_BITS + NBLKS_BITS + CHUNK_NUM_BITS)) - 1;
}
Expand Down
16 changes: 11 additions & 5 deletions src/engine/blkstore/blkstore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ VENUM(BlkStoreCacheType, uint8_t, PASS_THRU = 0, WRITEBACK_CACHE = 1, WRITETHRU_
* be either be discarded or copied into new buffer. This threshold dictates whats the value of (64K - N) upto which
* it will copy. In other words ((64K - N) <= CACHE_DISCARD_THRESHOLD_SIZE) ? copy : discard
*/
//#define CACHE_DISCARD_THRESHOLD_SIZE 16384
// #define CACHE_DISCARD_THRESHOLD_SIZE 16384

class BlkStoreConfig {
public:
Expand Down Expand Up @@ -325,6 +325,9 @@ class BlkStore {
BlkAllocStatus alloc_contiguous_blk(const uint32_t size, blk_alloc_hints& hints, BlkId* const out_blkid) {
// Allocate a block from the device manager
assert(size % m_pagesz == 0);
static uint32_t max_suppoted_size = m_pagesz * std::numeric_limits< blk_count_t >::max();
HS_REL_ASSERT_LE(size, max_suppoted_size, "size {} more than max size limit of {}", size, max_suppoted_size);

const blk_count_t nblks{static_cast< blk_count_t >(size / m_pagesz)};
hints.is_contiguous = true;
HS_DBG_ASSERT_LE(nblks, BlkId::max_blks_in_op(), "nblks {} more than max blks {}", nblks,
Expand All @@ -336,15 +339,18 @@ class BlkStore {
BlkAllocStatus alloc_blk(const uint32_t size, blk_alloc_hints& hints, std::vector< BlkId >& out_blkid) {
// Allocate a block from the device manager
assert(size % m_pagesz == 0);
blk_count_t nblks{static_cast< blk_count_t >(size / m_pagesz)};
// Using a 16-bit value (blk_count_t) for page counts can lead to overflow issues when managing large storage
// devices. With a page size of 4096 bytes, a 16-bit value limits the addressable storage to 256 MB (65,536
// pages * 4096 bytes/page).
uint32_t nblks{static_cast< uint32_t >(size / m_pagesz)};
if (nblks <= BlkId::max_blks_in_op()) {
return (m_vdev.alloc_blk(nblks, hints, out_blkid));
return (m_vdev.alloc_blk(static_cast< blk_count_t >(nblks), hints, out_blkid));
} else {
while (nblks != 0) {
static thread_local std::vector< BlkId > result_blkid{};
result_blkid.clear();
const blk_count_t nblks_op{std::min(static_cast< blk_count_t >(BlkId::max_blks_in_op()), nblks)};
const auto ret{m_vdev.alloc_blk(nblks_op, hints, result_blkid)};
const uint32_t nblks_op{std::min(static_cast< uint32_t >(BlkId::max_blks_in_op()), nblks)};
const auto ret{m_vdev.alloc_blk(static_cast< blk_count_t >(nblks_op), hints, result_blkid)};
if (ret != BlkAllocStatus::SUCCESS) { return ret; }
out_blkid.insert(std::end(out_blkid), std::make_move_iterator(std::begin(result_blkid)),
std::make_move_iterator(std::end(result_blkid)));
Expand Down
1 change: 1 addition & 0 deletions src/engine/meta/meta_blks_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ void MetaBlkMgr::alloc_meta_blk(const uint64_t size, std::vector< BlkId >& bid)
try {
const auto ret{m_sb_blk_store->alloc_blk(size, hints, bid)};
HS_REL_ASSERT_EQ(ret, BlkAllocStatus::SUCCESS);
HS_REL_ASSERT_NE(bid.size(), 0);
#ifndef NDEBUG
uint64_t debug_size{0};
for (size_t i{0}; i < bid.size(); ++i) {
Expand Down
Loading