Skip to content

Commit

Permalink
FIX oom and metablk corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
shosseinimotlagh committed Sep 18, 2024
1 parent 2a0cf2d commit e7453e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
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.7.1"
version = "3.7.2"

homepage = "https://github.corp.ebay.com/SDS/homestore"
description = "HomeStore"
Expand Down
1 change: 0 additions & 1 deletion src/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ AlignOperands: false
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: InlineOnly
# AllowShortLoopsOnASingleLine: false
Expand Down
11 changes: 7 additions & 4 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,7 +325,7 @@ 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);
const blk_count_t nblks{static_cast< blk_count_t >(size / m_pagesz)};
const uint32_t nblks{static_cast< uint32_t >(size / m_pagesz)};
hints.is_contiguous = true;
HS_DBG_ASSERT_LE(nblks, BlkId::max_blks_in_op(), "nblks {} more than max blks {}", nblks,
BlkId::max_blks_in_op());
Expand All @@ -336,14 +336,17 @@ 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));
} 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 uint32_t nblks_op{std::min(static_cast< uint32_t >(BlkId::max_blks_in_op()), nblks)};
const auto ret{m_vdev.alloc_blk(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)),
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

0 comments on commit e7453e4

Please sign in to comment.