Skip to content

Commit

Permalink
add chunkid and operator== to VChunk
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Sep 18, 2023
1 parent b6c6a89 commit 152d923
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/include/homestore/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct blk_alloc_hints {
blk_alloc_hints() :
desired_temp{0},
dev_id_hint{INVALID_DEV_ID},
chunk_id_hint{INVALID_CHUNK_ID},
can_look_for_other_chunk{true},
is_contiguous{false},
multiplier{1},
Expand All @@ -178,8 +179,8 @@ struct blk_alloc_hints {
uint32_t dev_id_hint; // which physical device to pick (hint if any) -1 for don't care
bool can_look_for_other_chunk; // If alloc on device not available can I pick other device
bool is_contiguous;
uint32_t multiplier; // blks allocated in a blkid should be a multiple of multiplier
uint32_t max_blks_per_entry; // Number of blks on every entry
uint32_t multiplier; // blks allocated in a blkid should be a multiple of multiplier
uint32_t max_blks_per_entry; // Number of blks on every entry
uintptr_t stream_info;
#ifdef _PRERELEASE
bool error_simulate = false; // can error simulate happen
Expand Down
4 changes: 3 additions & 1 deletion src/include/homestore/vchunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class Chunk;
class VChunk {
public:
VChunk(cshared< Chunk > const&);

~VChunk() = default;

bool operator==(const VChunk&) const;

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;
uint16_t get_chunk_id() const;
cshared< Chunk > get_internal_chunk() const;

private:
Expand Down
6 changes: 5 additions & 1 deletion src/lib/device/vchunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ VChunk::VChunk(cshared< Chunk >& chunk) : m_internal_chunk(chunk) {}

void VChunk::set_user_private(const sisl::blob& data) { m_internal_chunk->set_user_private(data); }

const uint8_t* VChunk::get_user_private() const { return m_internal_chunk->user_private(); };
const uint8_t* VChunk::get_user_private() const { return m_internal_chunk->user_private(); }

uint16_t VChunk::get_chunk_id() const { return m_internal_chunk->chunk_id(); }

blk_cap_t VChunk::available_blks() const { return m_internal_chunk->blk_allocator()->available_blks(); }

uint32_t VChunk::get_pdev_id() const { return m_internal_chunk->physical_dev()->pdev_id(); }

cshared< Chunk > VChunk::get_internal_chunk() const { return m_internal_chunk; }

bool VChunk::operator==(const VChunk& vchunk) const { return vchunk.get_chunk_id() == get_chunk_id(); }
} // namespace homestore

0 comments on commit 152d923

Please sign in to comment.