Skip to content

Commit

Permalink
add more detail info for metablk debug (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 authored May 30, 2024
1 parent 2c18e94 commit e9721a0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
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 = "6.4.9"
version = "6.4.10"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
51 changes: 34 additions & 17 deletions src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,14 @@ void MetaBlkService::format_ssb() {
// m_meta_lock should be while calling this function;
void MetaBlkService::write_ssb() {
// write current ovf blk to disk;
try {
m_sb_vdev->sync_write((const char*)m_ssb, block_size(), m_ssb->bid);
} catch (std::exception& e) { HS_REL_ASSERT(false, "exception happen during write {}", e.what()); }
auto error = m_sb_vdev->sync_write((const char*)m_ssb, block_size(), m_ssb->bid);
if (error.value()) {
// the offset and buffer length is printed in the error messages of iomgr.
// buf address here is to show whether the buffer is aligned or not.
// TODO: hanle this error properly
HS_REL_ASSERT(false, "error happens happen during write ssb: {}, buf address: {}", error.value(),
(const char*)m_ssb);
}

LOGINFO("Successfully write m_ssb to disk: {}", m_ssb->to_string());

Expand Down Expand Up @@ -436,9 +441,14 @@ void MetaBlkService::write_ovf_blk_to_disk(meta_blk_ovf_hdr* ovf_hdr, const uint
HS_DBG_ASSERT_LE(ovf_hdr->h.context_sz + offset, sz);

// write current ovf blk to disk;
try {
m_sb_vdev->sync_write((const char*)ovf_hdr, block_size(), ovf_hdr->h.bid);
} catch (std::exception& e) { HS_REL_ASSERT(false, "exception happen during write {}", e.what()); }
auto error = m_sb_vdev->sync_write((const char*)ovf_hdr, block_size(), ovf_hdr->h.bid);
if (error.value()) {
// the offset and buffer length is printed in the error messages of iomgr.
// buf address here is to show whether the buffer is aligned or not.
// TODO: hanle this error properly
HS_REL_ASSERT(false, "error happens happen during write: {}, buf address: {}", error.value(),
(const char*)ovf_hdr);
}

// NOTE: The start write pointer which is context data pointer plus offset must be dma boundary aligned
// TO DO: Might need to differentiate based on data or fast type
Expand Down Expand Up @@ -488,9 +498,14 @@ void MetaBlkService::write_ovf_blk_to_disk(meta_blk_ovf_hdr* ovf_hdr, const uint
size_written += (ovf_hdr->h.context_sz - size_written);
}

try {
m_sb_vdev->sync_write(r_cast< const char* >(cur_ptr), cur_size, data_bid[i]);
} catch (std::exception& e) { HS_REL_ASSERT(false, "exception happen during write {}", e.what()); }
auto error = m_sb_vdev->sync_write(r_cast< const char* >(cur_ptr), cur_size, data_bid[i]);
if (error.value()) {
// the offset and buffer length is printed in the error messages of iomgr.
// buf address here is to show whether the buffer is aligned or not.
// TODO: hanle this error properly
HS_REL_ASSERT(false, "error happens happen during write: {}, buf address: {}", error.value(),
r_cast< const char* >(cur_ptr));
}
}

if (data_buf) { hs_utils::iobuf_free(data_buf, sisl::buftag::metablk); }
Expand All @@ -501,9 +516,14 @@ void MetaBlkService::write_ovf_blk_to_disk(meta_blk_ovf_hdr* ovf_hdr, const uint

void MetaBlkService::write_meta_blk_to_disk(meta_blk* mblk) {
// write current ovf blk to disk;
try {
m_sb_vdev->sync_write((const char*)mblk, block_size(), mblk->hdr.h.bid);
} catch (std::exception& e) { HS_REL_ASSERT(false, "exception happen during write {}", e.what()); }
auto error = m_sb_vdev->sync_write((const char*)mblk, block_size(), mblk->hdr.h.bid);
if (error.value()) {
// the offset and buffer length is printed in the error messages of iomgr.
// buf address here is to show whether the buffer is aligned or not.
// TODO: hanle this error properly
HS_REL_ASSERT(false, "error happens happen during write_meta_blk_to_disk: {}, buf address: {}", error.value(),
(const char*)mblk);
}
}

//
Expand Down Expand Up @@ -1122,11 +1142,8 @@ void MetaBlkService::recover_meta_block(meta_blk* mblk) {
// if subsystem registered crc protection, verify crc before sending to subsystem;
if (itr->second.do_crc) {
const auto crc = crc32_ieee(init_crc32, buf->cbytes(), mblk->hdr.h.context_sz);

HS_REL_ASSERT_EQ(crc, uint32_cast(mblk->hdr.h.crc),
"[type={}], CRC mismatch: {}/{}, on mblk bid: {}, context_sz: {}", mblk->hdr.h.type, crc,
uint32_cast(mblk->hdr.h.crc), mblk->hdr.h.bid.to_string(),
uint64_cast(mblk->hdr.h.context_sz));
HS_REL_ASSERT_EQ(crc, uint32_cast(mblk->hdr.h.crc), "CRC mismatch: {}/{}, meta_blk details: {}", crc,
uint32_cast(mblk->hdr.h.crc), mblk->hdr.h.to_string());
} else {
HS_LOG(DEBUG, metablk, "[type={}] meta blk found with bypassing crc.", mblk->hdr.h.type);
}
Expand Down
9 changes: 5 additions & 4 deletions src/lib/meta/meta_sb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ struct meta_blk_hdr_s {
uint8_t pad[7];

std::string to_string() const {
return fmt::format("type: {}, version: {}, magic: {}, crc: {}, next_bid: {}, prev_bid: {}, ovf_bid: {}, "
"self_bid: {}, compressed: {}",
type, version, magic, crc, next_bid.to_string(), prev_bid.to_string(), ovf_bid.to_string(),
bid.to_string(), compressed);
return fmt::format(
"magic: {}, type: {}, version: {}, gen_cnt: {}, crc: {}, next_bid: {}, prev_bid: {}, "
"ovf_bid: {}, self_bid: {}, context_sz: {}, compressed_sz: {}, src_context_sz : {}, compressed: {} ",
magic, type, version, gen_cnt, crc, next_bid.to_string(), prev_bid.to_string(), ovf_bid.to_string(),
bid.to_string(), context_sz, compressed_sz, src_context_sz, compressed);
}
};
#pragma pack()
Expand Down

0 comments on commit e9721a0

Please sign in to comment.