diff --git a/src/include/homestore/vchunk.h b/src/include/homestore/vchunk.h index f34ed0f4a..a88f17361 100644 --- a/src/include/homestore/vchunk.h +++ b/src/include/homestore/vchunk.h @@ -30,6 +30,8 @@ class VChunk { void set_user_private(const sisl::blob& data); const uint8_t* get_user_private() const; blk_num_t available_blks() const; + blk_num_t get_freeable_nblks() const; + blk_num_t get_defrag_nblks() const; uint32_t get_pdev_id() const; uint16_t get_chunk_id() const; cshared< Chunk > get_internal_chunk() const; diff --git a/src/lib/blkalloc/blk_allocator.h b/src/lib/blkalloc/blk_allocator.h index 8f63aa0f8..172124b1b 100644 --- a/src/lib/blkalloc/blk_allocator.h +++ b/src/lib/blkalloc/blk_allocator.h @@ -157,6 +157,8 @@ class BlkAllocator { virtual void free_on_disk(BlkId const& bid) = 0; virtual blk_num_t available_blks() const = 0; + virtual blk_num_t get_freeable_nblks() const = 0; + virtual blk_num_t get_defrag_nblks() const = 0; virtual blk_num_t get_used_blks() const = 0; virtual bool is_blk_alloced(BlkId const& b, bool use_lock = false) const = 0; virtual bool is_blk_alloced_on_disk(BlkId const& b, bool use_lock = false) const = 0; diff --git a/src/lib/blkalloc/fixed_blk_allocator.cpp b/src/lib/blkalloc/fixed_blk_allocator.cpp index 3b1776d7c..2e9e5ae03 100644 --- a/src/lib/blkalloc/fixed_blk_allocator.cpp +++ b/src/lib/blkalloc/fixed_blk_allocator.cpp @@ -74,6 +74,19 @@ void FixedBlkAllocator::free(BlkId const& b) { } blk_num_t FixedBlkAllocator::available_blks() const { return m_blk_q.sizeGuess(); } + +blk_num_t FixedBlkAllocator::get_freeable_nblks() const { + // TODO: implement this + HS_DBG_ASSERT_EQ(false, true, "FixedBlkAllocator get_freeable_nblks Not implemented"); + return 0; +} + +blk_num_t FixedBlkAllocator::get_defrag_nblks() const { + // TODO: implement this + HS_DBG_ASSERT_EQ(false, true, "FixedBlkAllocator get_defrag_nblks Not implemented"); + return 0; +} + blk_num_t FixedBlkAllocator::get_used_blks() const { return get_total_blks() - available_blks(); } std::string FixedBlkAllocator::to_string() const { diff --git a/src/lib/blkalloc/varsize_blk_allocator.cpp b/src/lib/blkalloc/varsize_blk_allocator.cpp index ac44ab1bf..edc4dbbb9 100644 --- a/src/lib/blkalloc/varsize_blk_allocator.cpp +++ b/src/lib/blkalloc/varsize_blk_allocator.cpp @@ -716,6 +716,19 @@ bool VarsizeBlkAllocator::is_blk_alloced(BlkId const& bid, bool use_lock) const } blk_num_t VarsizeBlkAllocator::available_blks() const { return get_total_blks() - get_used_blks(); } + +blk_num_t VarsizeBlkAllocator::get_freeable_nblks() const { + // TODO: implement this + BLKALLOC_REL_ASSERT(false, "VarsizeBlkAllocator get_freeable_nblks Not implemented") + return 0; +} + +blk_num_t VarsizeBlkAllocator::get_defrag_nblks() const { + // TODO: implement this + BLKALLOC_REL_ASSERT(false, "VarsizeBlkAllocator get_defrag_nblks Not implemented") + return 0; +} + blk_num_t VarsizeBlkAllocator::get_used_blks() const { return get_alloced_blk_count(); } #ifdef _PRERELEASE diff --git a/src/lib/blkalloc/varsize_blk_allocator.h b/src/lib/blkalloc/varsize_blk_allocator.h index 09f13240a..c6c1aa1d1 100644 --- a/src/lib/blkalloc/varsize_blk_allocator.h +++ b/src/lib/blkalloc/varsize_blk_allocator.h @@ -217,6 +217,8 @@ class VarsizeBlkAllocator : public BitmapBlkAllocator { void free(BlkId const& blk_id) override; blk_num_t available_blks() const override; + blk_num_t get_freeable_nblks() const override; + blk_num_t get_defrag_nblks() const override; blk_num_t get_used_blks() const override; bool is_blk_alloced(BlkId const& in_bid, bool use_lock = false) const override; std::string to_string() const override; diff --git a/src/lib/device/vchunk.cpp b/src/lib/device/vchunk.cpp index 54dc54604..a154f39a9 100644 --- a/src/lib/device/vchunk.cpp +++ b/src/lib/device/vchunk.cpp @@ -25,6 +25,10 @@ const uint8_t* VChunk::get_user_private() const { return m_internal_chunk->user_ blk_num_t VChunk::available_blks() const { return m_internal_chunk->blk_allocator()->available_blks(); } +blk_num_t VChunk::get_freeable_nblks() const { return m_internal_chunk->blk_allocator()->get_freeable_nblks(); } + +blk_num_t VChunk::get_defrag_nblks() const { return m_internal_chunk->blk_allocator()->get_defrag_nblks(); } + uint32_t VChunk::get_pdev_id() const { return m_internal_chunk->physical_dev()->pdev_id(); } uint16_t VChunk::get_chunk_id() const { return m_internal_chunk->chunk_id(); }