diff --git a/src/include/homestore/chunk_selector.h b/src/include/homestore/chunk_selector.h index 54cb9bd9d..818ea5e69 100644 --- a/src/include/homestore/chunk_selector.h +++ b/src/include/homestore/chunk_selector.h @@ -23,7 +23,7 @@ class ChunkSelector { ChunkSelector() = default; virtual void add_chunk(VChunk chunk) = 0; virtual void foreach_chunks(std::function< void(VChunk&) >&& cb) = 0; - virtual Chunk* select(blk_count_t nblks, const blk_alloc_hints& hints) = 0; + virtual Chunk* select_chunk(blk_count_t nblks, const blk_alloc_hints& hints) = 0; virtual ~ChunkSelector() = default; }; diff --git a/src/include/homestore/vchunk.h b/src/include/homestore/vchunk.h index ed080cf17..8064d922b 100644 --- a/src/include/homestore/vchunk.h +++ b/src/include/homestore/vchunk.h @@ -27,11 +27,11 @@ class VChunk { ~VChunk() = default; - void set_user_private(const sisl::blob& data); - uint8_t* get_user_private(); - blk_cap_t available_blks(); - uint32_t getPdevID(); - cshared< Chunk > getInternalChunk(); + void set_user_private(const sisl::blob& data) const; + uint8_t* get_user_private() const; + blk_cap_t available_blks() const; + uint32_t get_pdev_id() const; + cshared< Chunk > get_internal_chunk () const; private: cshared< Chunk > internalChunk; diff --git a/src/lib/device/round_robin_chunk_selector.cpp b/src/lib/device/round_robin_chunk_selector.cpp index 53129015e..bd3701912 100644 --- a/src/lib/device/round_robin_chunk_selector.cpp +++ b/src/lib/device/round_robin_chunk_selector.cpp @@ -22,9 +22,9 @@ RoundRobinChunkSelector::RoundRobinChunkSelector(bool dynamic_chunk_add) : m_dyn void RoundRobinChunkSelector::add_chunk(VChunk chunk) { m_chunks.push_back(chunk); } -Chunk* RoundRobinChunkSelector::select(blk_count_t, const blk_alloc_hints&) { +Chunk* RoundRobinChunkSelector::select_chunk(blk_count_t, const blk_alloc_hints&) { if (*m_next_chunk_index >= m_chunks.size()) { *m_next_chunk_index = 0; } - return m_chunks[(*m_next_chunk_index)++].getInternalChunk().get(); + return m_chunks[(*m_next_chunk_index)++].get_internal_chunk().get(); } void RoundRobinChunkSelector::foreach_chunks(std::function< void(VChunk&) >&& cb) { diff --git a/src/lib/device/round_robin_chunk_selector.h b/src/lib/device/round_robin_chunk_selector.h index 1f0620c8f..cc916c9d3 100644 --- a/src/lib/device/round_robin_chunk_selector.h +++ b/src/lib/device/round_robin_chunk_selector.h @@ -36,7 +36,7 @@ class RoundRobinChunkSelector : public ChunkSelector { ~RoundRobinChunkSelector() = default; void add_chunk(VChunk chunk) override; - Chunk* select(blk_count_t nblks, const blk_alloc_hints& hints) override; + Chunk* select_chunk(blk_count_t nblks, const blk_alloc_hints& hints) override; void foreach_chunks(std::function< void(VChunk&) >&& cb) override; private: diff --git a/src/lib/device/vchunk.cpp b/src/lib/device/vchunk.cpp index 793159e82..fbd50c7aa 100644 --- a/src/lib/device/vchunk.cpp +++ b/src/lib/device/vchunk.cpp @@ -19,21 +19,21 @@ namespace homestore { VChunk::VChunk(cshared< Chunk >& chunk) : internalChunk(chunk){} - void VChunk::set_user_private(const sisl::blob& data){ + void VChunk::set_user_private(const sisl::blob& data) const{ internalChunk->set_user_private(data); } - uint8_t* VChunk::get_user_private() { + uint8_t* VChunk::get_user_private() const { return internalChunk->user_private(); }; - blk_cap_t VChunk::available_blks() { + blk_cap_t VChunk::available_blks() const { return internalChunk->blk_allocator()->available_blks(); } - uint32_t VChunk::getPdevID() { + uint32_t VChunk::get_pdev_id() const { return internalChunk->physical_dev()->pdev_id(); } - cshared< Chunk > VChunk::getInternalChunk() {return internalChunk;} + cshared< Chunk > VChunk::get_internal_chunk() const {return internalChunk;} }// namespace homestore diff --git a/src/lib/device/virtual_dev.cpp b/src/lib/device/virtual_dev.cpp index 4b80ad7b3..a7a0af6ae 100644 --- a/src/lib/device/virtual_dev.cpp +++ b/src/lib/device/virtual_dev.cpp @@ -175,7 +175,7 @@ BlkAllocStatus VirtualDev::do_alloc_blk(blk_count_t nblks, const blk_alloc_hints size_t attempt{0}; do { - chunk = m_chunk_selector->select(nblks, hints); + chunk = m_chunk_selector->select_chunk(nblks, hints); if (chunk == nullptr) { status = BlkAllocStatus::SPACE_FULL; } status = alloc_blk_from_chunk(nblks, hints, out_blkid, chunk); @@ -435,7 +435,7 @@ uint64_t VirtualDev::used_size() const { } void VirtualDev::cp_flush() { - m_chunk_selector->foreach_chunks([this](VChunk& vchunk) { vchunk.getInternalChunk()->cp_flush(); }); + m_chunk_selector->foreach_chunks([this](VChunk& vchunk) { vchunk.get_internal_chunk()->cp_flush(); }); } std::vector< shared< Chunk > > VirtualDev::get_chunks() const { return m_all_chunks; }