Skip to content
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
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 = "7.3.1"
version = "7.3.2"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
16 changes: 16 additions & 0 deletions src/include/homestore/blkdata_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ class BlkDataService {
*/
folly::Future< std::error_code > async_free_blk(MultiBlkId const& bid);

/**
* @brief Frees the specified block IDs immediately. Used during log replay on commit only.
*
* @param bid The block ID to free.
* @return An error code indicating the result of the operation.
*/
std::error_code free_blk_now(MultiBlkId const& bid);

/**
* @brief Check if the blk id is free or not.
*
* @param bid The block ID to check.
* @return Return whether blkid is alloced or not.
*/
bool is_blk_alloced(BlkId const& blkid) const;

/**
* @brief : get the blk size of this data service;
*
Expand Down
4 changes: 3 additions & 1 deletion src/lib/blkalloc/bitmap_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ sisl::byte_array BitmapBlkAllocator::acquire_underlying_buffer() {
synchronize_rcu();

BLKALLOC_REL_ASSERT(old_alloc_list_ptr == nullptr, "Multiple acquires concurrently?");
return (m_disk_bm->serialize(m_align_size));
// Copy the serialized buffer as cp flush can interefere with incoming I/O's.
// Cp flush happens not only during restart but also during normal I/O's.
return (m_disk_bm->serialize(m_align_size, true /* force_copy */));
}

void BitmapBlkAllocator::release_underlying_buffer() {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/blkalloc/varsize_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ blk_count_t VarsizeBlkAllocator::free_blks_direct(MultiBlkId const& bid) {
auto const do_free = [this](BlkId const& b) {
BlkAllocPortion& portion = blknum_to_portion(b.blk_num());
{
BLKALLOC_LOG(TRACE, "Freeing directly to portion={} blkid={} set_bits_count={}",
blknum_to_portion_num(b.blk_num()), b.to_string(), get_alloced_blk_count());
auto const start_blk_id = portion.get_portion_num() * get_blks_per_portion();
auto const end_blk_id = start_blk_id + get_blks_per_portion() - 1;
auto lock{portion.portion_auto_lock()};
Expand All @@ -707,8 +709,6 @@ blk_count_t VarsizeBlkAllocator::free_blks_direct(MultiBlkId const& bid) {
BLKALLOC_REL_ASSERT(m_cache_bm->is_bits_set(b.blk_num(), b.blk_count()), "Expected bits to be set");
m_cache_bm->reset_bits(b.blk_num(), b.blk_count());
}
BLKALLOC_LOG(TRACE, "Freeing directly to portion={} blkid={} set_bits_count={}",
blknum_to_portion_num(b.blk_num()), b.to_string(), get_alloced_blk_count());
return b.blk_count();
};

Expand Down
17 changes: 17 additions & 0 deletions src/lib/blkdata_svc/blkdata_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,23 @@ folly::Future< std::error_code > BlkDataService::async_free_blk(MultiBlkId const
return f;
}

std::error_code BlkDataService::free_blk_now(MultiBlkId const& bids) {
if (is_stopping()) return std::make_error_code(std::errc::operation_canceled);
incr_pending_request_num();

if (!m_vdev->is_blk_exist(bids)) {
decr_pending_request_num();
return std::make_error_code(std::errc::resource_unavailable_try_again);
} else {
auto cpg = hs()->cp_mgr().cp_guard();
m_vdev->free_blk(bids, s_cast< VDevCPContext* >(cpg.context(cp_consumer_t::BLK_DATA_SVC)), true /* free_now */);
}
decr_pending_request_num();
return std::error_code{};
}

bool BlkDataService::is_blk_alloced(BlkId const& blkid) const { return m_vdev->is_blk_alloced(blkid); }

void BlkDataService::start() {
// Register to CP for flush dirty buffers underlying virtual device layer;
hs()->cp_mgr().register_consumer(cp_consumer_t::BLK_DATA_SVC,
Expand Down
17 changes: 11 additions & 6 deletions src/lib/device/virtual_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ BlkAllocStatus VirtualDev::commit_blk(BlkId const& blkid) {
HS_LOG(ERROR, device, "fail to commit_blk: bid {}", blkid.to_string());
return BlkAllocStatus::INVALID_DEV;
}
HS_LOG(DEBUG, device, "commit_blk: bid {}", blkid.to_string());

for (int i = 0; i < blkid.blk_count(); i++) {
auto t = BlkId{blkid.blk_num() + i, 1 /* nblks */, blkid.chunk_num()};
HS_LOG(DEBUG, device, "commit_blk: bid {}", t.to_string());
}

auto const recovering = homestore::hs()->is_initializing();
if (!recovering) {
// in non-recovery mode, if a blk is committed without allocating, it will cause data corruption
Expand Down Expand Up @@ -328,9 +333,9 @@ BlkAllocStatus VirtualDev::alloc_blks_from_chunk(blk_count_t nblks, blk_alloc_hi
return status;
}

void VirtualDev::free_blk(BlkId const& bid, VDevCPContext* vctx) {
auto do_free_action = [this](auto const& b, VDevCPContext* vctx) {
if (vctx && (m_allocator_type != blk_allocator_type_t::append)) {
void VirtualDev::free_blk(BlkId const& bid, VDevCPContext* vctx, bool free_now) {
auto do_free_action = [this](auto const& b, VDevCPContext* vctx, bool free_now) {
if (vctx && (m_allocator_type != blk_allocator_type_t::append) && !free_now) {
// We don't want to accumulate here for append blk allocator.
vctx->m_free_blkid_list.push_back(b);
} else {
Expand All @@ -348,10 +353,10 @@ void VirtualDev::free_blk(BlkId const& bid, VDevCPContext* vctx) {
MultiBlkId const& mbid = r_cast< MultiBlkId const& >(bid);
auto it = mbid.iterate();
while (auto const b = it.next()) {
do_free_action(*b, vctx);
do_free_action(*b, vctx, free_now);
}
} else {
do_free_action(bid, vctx);
do_free_action(bid, vctx, free_now);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/device/virtual_dev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class VirtualDev {
/// @return Allocation Status
virtual BlkAllocStatus commit_blk(BlkId const& blkid);

virtual void free_blk(BlkId const& b, VDevCPContext* vctx = nullptr);
virtual void free_blk(BlkId const& b, VDevCPContext* vctx = nullptr, bool free_now = false);

/////////////////////// Write API related methods /////////////////////////////
/// @brief Asynchornously write the buffer to the device on a given blkid
Expand Down
Loading