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

Add get_freeable_nblks and get_defrag_nblks api to Vchunk #216

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "4.5.8"
version = "4.5.9"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
2 changes: 2 additions & 0 deletions src/include/homestore/vchunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/blkalloc/blk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class BlkAllocator {
virtual BlkAllocStatus alloc(blk_count_t nblks, blk_alloc_hints const& hints, BlkId& out_blkid) = 0;
virtual void free(BlkId const& id) = 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 std::string to_string() const = 0;
Expand Down Expand Up @@ -319,6 +321,8 @@ class FixedBlkAllocator : public BlkAllocator {
void inited() 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;
Expand Down
11 changes: 11 additions & 0 deletions src/lib/blkalloc/fixed_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ 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
return 0;
}

blk_num_t FixedBlkAllocator::get_defrag_nblks() const {
// TODO: implement this
return 0;
}

blk_num_t FixedBlkAllocator::get_used_blks() const { return get_total_blks() - available_blks(); }

std::string FixedBlkAllocator::to_string() const {
Expand Down
11 changes: 11 additions & 0 deletions src/lib/blkalloc/varsize_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,17 @@ 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
JacksonYao287 marked this conversation as resolved.
Show resolved Hide resolved
return 0;
}

blk_num_t VarsizeBlkAllocator::get_defrag_nblks() const {
// TODO: implement this
return 0;
}

blk_num_t VarsizeBlkAllocator::get_used_blks() const { return get_alloced_blk_count(); }

#ifdef _PRERELEASE
Expand Down
2 changes: 2 additions & 0 deletions src/lib/blkalloc/varsize_blk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class VarsizeBlkAllocator : public BlkAllocator {
void inited() 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;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/device/vchunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
Loading