-
Notifications
You must be signed in to change notification settings - Fork 21
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
handle missing pdev when reading #405
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, a few nit FYI
src/lib/device/virtual_dev.cpp
Outdated
return uint64_cast(b.blk_num()) * block_size() + uint64_cast((*chunk)->start_offset()); | ||
} | ||
|
||
bool VirtualDev::is_chunk_loaded(cshared< Chunk >& chunk) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only chunk id is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wanted to set the parameter to only chunk_id. but if that, we need to get the chunk_id before
if (sisl_unlikely(!is_chunk_available(chunk)))
so , puttingthe action of getting chunk id inside is_chunk_available
itself seems more clean.
since it generates no impact to the logic, we can keep it like this and change it if necessary in the future.
src/lib/device/device.h
Outdated
} | ||
|
||
Chunk* get_chunk_mutable(uint32_t chunk_id) { | ||
std::unique_lock lg{m_vdev_mutex}; | ||
return (chunk_id == INVALID_CHUNK_ID) ? nullptr : m_chunks[chunk_id].get(); | ||
// if a pdev is misssing when restart, chunk_id from client might be larger than m_chunks.size() | ||
if (chunk_id == INVALID_CHUNK_ID || chunk_id >= m_chunks.size()) return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe m_chunks.index_exists(chunk_id)
?
src/lib/device/virtual_dev.hpp
Outdated
@@ -299,6 +299,7 @@ class VirtualDev { | |||
|
|||
private: | |||
uint64_t to_dev_offset(BlkId const& b, Chunk** chunk) const; | |||
bool is_chunk_loaded(cshared< Chunk >& chunk) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe is_chunk_exists or is_chunk_available is a better naming? loaded sounds like if not you can load again:)
df70eec
to
a7de024
Compare
a7de024
to
e9c0b4c
Compare
@xiaoxichen I address your comment, PTAL |
pls add some commit message when merging |
#400
in some scenarios, homestore might be restarted with missing pdev(for example, breakfix), thus all the chunks in that pdev will not be loaded. so we need to deal with this case.
1 for read from client, we need to check whether the chunk in the provided blkid is loaded and proceed accordingly.
2 for write , we will almost not encounter this case since we will never allocate blk for a missing pdev. but for the sake of completeness, check is also added .