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.5.11"
version = "7.5.12"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
7 changes: 6 additions & 1 deletion src/include/homestore/blkdata_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,13 @@ class BlkDataService {
* @brief Commits the block with the given MultiBlkId.
*
* @param bid The MultiBlkId of the block to commit.
* @param recommit If true, skip the allocation check and commit the blk unconditionally.
* Use this when re-committing a blk that is known to be live but whose allocator state
* may have been lost (e.g. after a crash where the blk exists in the index but the
* allocator watermarks were not yet persisted). Safe to pass when the allocator already
* tracks the blk, as the underlying operations are monotonically advancing.
*/
BlkAllocStatus commit_blk(MultiBlkId const& bid);
BlkAllocStatus commit_blk(MultiBlkId const& bid, bool recommit = false);

/**
* @brief Allocates a contiguous block of disk space of the given size. This API should be called that when consumer
Expand Down
6 changes: 3 additions & 3 deletions src/lib/blkdata_svc/blkdata_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ BlkAllocStatus BlkDataService::alloc_blks(uint32_t size, const blk_alloc_hints&
return ret;
}

BlkAllocStatus BlkDataService::commit_blk(MultiBlkId const& blkid) {
BlkAllocStatus BlkDataService::commit_blk(MultiBlkId const& blkid, bool recommit) {
if (is_stopping()) return BlkAllocStatus::FAILED;
incr_pending_request_num();

if (blkid.num_pieces() == 1) {
// Shortcut to most common case
auto ret = m_vdev->commit_blk(blkid);
auto ret = m_vdev->commit_blk(blkid, recommit);
decr_pending_request_num();
return ret;
}
auto it = blkid.iterate();
while (auto const bid = it.next()) {
auto alloc_status = m_vdev->commit_blk(*bid);
auto alloc_status = m_vdev->commit_blk(*bid, recommit);
if (alloc_status != BlkAllocStatus::SUCCESS) {
decr_pending_request_num();
return alloc_status;
Expand Down
10 changes: 6 additions & 4 deletions src/lib/device/virtual_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool VirtualDev::is_blk_alloced(BlkId const& blkid) const {
return m_dmgr.get_chunk(blkid.chunk_num())->blk_allocator()->is_blk_alloced(blkid, true /* lock */);
}

BlkAllocStatus VirtualDev::commit_blk(BlkId const& blkid) {
BlkAllocStatus VirtualDev::commit_blk(BlkId const& blkid, bool recommit) {
Chunk* chunk = m_dmgr.get_chunk_mutable(blkid.chunk_num());
// if we start with missing drive, we will have no chunk for this blkid;
if (!chunk) {
Expand All @@ -188,12 +188,14 @@ BlkAllocStatus VirtualDev::commit_blk(BlkId const& blkid) {
}

auto const recovering = homestore::hs()->is_initializing();
if (!recovering) {
if (recovering || recommit) {
// Also advance the in-memory watermark so the allocator considers this blk allocated;
// required both during normal recovery and on an explicit recommit by the caller.
chunk->blk_allocator_mutable()->reserve_on_cache(blkid);
} else {
// in non-recovery mode, if a blk is committed without allocating, it will cause data corruption
HS_REL_ASSERT(is_blk_alloced(blkid), "commiting blkid {} is not allocated in non-recovery mode",
blkid.to_string());
} else {
chunk->blk_allocator_mutable()->reserve_on_cache(blkid);
}
return chunk->blk_allocator_mutable()->reserve_on_disk(blkid);
}
Expand Down
8 changes: 5 additions & 3 deletions src/lib/device/virtual_dev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ class VirtualDev {
/// @brief Commits the blkid in on-disk version of the blk allocator. The blkid is assumed to be allocated using
/// alloc_blk or alloc_contiguous_blk method earlier (either after reboot or prior to reboot). It is not required
/// to call this method if alloc_blk is called and system is not restarted. Typical use case of this method is
/// during recovery where alloc_blk is called but before it was checkpointed, it crashed and we are trying to
/// recover Please note that even calling this method is not guaranteed to persisted until checkpoint is taken.
/// during recovery where alloc_blk is called, but before it was checkpointed, it crashed, and we are trying to
/// recover. Please note that even calling this method is not guaranteed to be persisted until checkpoint is taken.
/// @param blkid BlkId to commit explicitly.
/// @param recommit If true, skip the allocation check and commit unconditionally.
/// See BlkDataService::commit_blk for details.
/// @return Allocation Status
virtual BlkAllocStatus commit_blk(BlkId const& blkid);
virtual BlkAllocStatus commit_blk(BlkId const& blkid, bool recommit = false);

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

Expand Down
Loading