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

handle missing pdev when reading #405

Merged
merged 2 commits into from
May 8, 2024

Conversation

JacksonYao287
Copy link
Contributor

#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 .

src/lib/device/device.h Outdated Show resolved Hide resolved
xiaoxichen
xiaoxichen previously approved these changes May 7, 2024
Copy link
Collaborator

@xiaoxichen xiaoxichen left a 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

return uint64_cast(b.blk_num()) * block_size() + uint64_cast((*chunk)->start_offset());
}

bool VirtualDev::is_chunk_loaded(cshared< Chunk >& chunk) const {
Copy link
Collaborator

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?

Copy link
Contributor Author

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 Show resolved Hide resolved
}

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;
Copy link
Collaborator

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)?

@@ -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;
Copy link
Collaborator

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:)

@JacksonYao287
Copy link
Contributor Author

@xiaoxichen I address your comment, PTAL

@xiaoxichen
Copy link
Collaborator

pls add some commit message when merging

@JacksonYao287 JacksonYao287 merged commit 97cba11 into eBay:master May 8, 2024
21 checks passed
@JacksonYao287 JacksonYao287 deleted the fix-missing-pdev branch August 21, 2024 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants