Skip to content

Commit

Permalink
crimson/os/seastore: convert offset/length in segment logs to hex format
Browse files Browse the repository at this point in the history
Signed-off-by: Yingxin Cheng <[email protected]>
  • Loading branch information
cyx1231st committed Dec 3, 2024
1 parent b053ad5 commit 0c65b41
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/crimson/os/seastore/journal/record_submitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RecordBatch::add_pending(
LOG_PREFIX(RecordBatch::add_pending);
auto new_size = get_encoded_length_after(record, block_size);
auto dlength_offset = pending.size.dlength;
TRACE("{} batches={}, write_size={}, dlength_offset={} ...",
TRACE("{} batches={}, write_size=0x{:x}, dlength_offset=0x{:x} ...",
name,
pending.get_size() + 1,
new_size.get_encoded_length(),
Expand Down Expand Up @@ -144,7 +144,7 @@ RecordSubmitter::RecordSubmitter(
batches(new RecordBatch[io_depth + 1])
{
LOG_PREFIX(RecordSubmitter);
INFO("{} io_depth_limit={}, batch_capacity={}, batch_flush_size={}, "
INFO("{} io_depth_limit={}, batch_capacity={}, batch_flush_size=0x{:x}, "
"preferred_fullness={}",
get_name(), io_depth, batch_capacity,
batch_flush_size, preferred_fullness);
Expand Down
4 changes: 2 additions & 2 deletions src/crimson/os/seastore/journal/segment_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ SegmentAllocator::write(ceph::bufferlist&& to_write)
auto write_length = to_write.length();
auto write_start_offset = written_to;
if (unlikely(LOCAL_LOGGER.is_enabled(seastar::log_level::trace))) {
TRACE("{} {}~{}", print_name, get_written_to(), write_length);
TRACE("{} {}~0x{:x}", print_name, get_written_to(), write_length);
}
assert(write_length > 0);
assert((write_length % get_block_size()) == 0);
Expand Down Expand Up @@ -250,7 +250,7 @@ SegmentAllocator::close_segment()
close_seg_info.num_extents};
ceph::bufferlist bl;
encode(tail, bl);
INFO("{} close segment {}, written_to={}",
INFO("{} close segment {}, written_to=0x{:x}",
print_name,
tail,
written_to);
Expand Down
2 changes: 1 addition & 1 deletion src/crimson/os/seastore/journal/segmented_journal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ SegmentedJournal::submit_record(
).get_encoded_length();
auto max_record_length = journal_segment_allocator.get_max_write_length();
if (expected_size > max_record_length) {
ERROR("H{} {} exceeds max record size {}",
ERROR("H{} {} exceeds max record size 0x{:x}",
(void*)&handle, record, max_record_length);
return crimson::ct_error::erange::make();
}
Expand Down
12 changes: 6 additions & 6 deletions src/crimson/os/seastore/segment_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ namespace crimson::os::seastore {
std::ostream& operator<<(std::ostream& out, const block_shard_info_t& sf)
{
out << "("
<< "size=" << sf.size
<< ", segments=" <<sf.segments
<< ", tracker_offset=" <<sf.tracker_offset
<< ", first_segment_offset=" <<sf.first_segment_offset
<< "size=0x" << std::hex << sf.size << std::dec
<< ", segments=" << sf.segments
<< ", tracker_offset=0x" << std::hex << sf.tracker_offset
<< ", first_segment_offset=0x" << sf.first_segment_offset << std::dec
<<")";
return out;
}
Expand All @@ -28,8 +28,8 @@ std::ostream& operator<<(std::ostream& out, const block_sm_superblock_t& sb)
{
out << "superblock("
<< "shard_num=" << sb.shard_num
<< ", segment_size=" << sb.segment_size
<< ", block_size=" << sb.block_size
<< ", segment_size=0x" << std::hex << sb.segment_size
<< ", block_size=0x" << sb.block_size << std::dec
<< ", shard_info:";
for (auto &sf : sb.shard_infos) {
out << sf
Expand Down
58 changes: 29 additions & 29 deletions src/crimson/os/seastore/segment_manager/block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ static write_ertr::future<> do_write(
{
LOG_PREFIX(block_do_write);
auto len = bptr.length();
TRACE("{} poffset={}~{} ...",
TRACE("{} poffset=0x{:x}~0x{:x} ...",
device_id_printer_t{device_id}, offset, len);
return device.dma_write(
offset,
bptr.c_str(),
len
).handle_exception(
[FNAME, device_id, offset, len](auto e) -> write_ertr::future<size_t> {
ERROR("{} poffset={}~{} got error -- {}",
ERROR("{} poffset=0x{:x}~0x{:x} got error -- {}",
device_id_printer_t{device_id}, offset, len, e);
return crimson::ct_error::input_output_error::make();
}).then([FNAME, device_id, offset, len](auto result) -> write_ertr::future<> {
if (result != len) {
ERROR("{} poffset={}~{} write len={} inconsistent",
ERROR("{} poffset=0x{:x}~0x{:x} write len=0x{:x} inconsistent",
device_id_printer_t{device_id}, offset, len, result);
return crimson::ct_error::input_output_error::make();
}
TRACE("{} poffset={}~{} done", device_id_printer_t{device_id}, offset, len);
TRACE("{} poffset=0x{:x}~0x{:x} done", device_id_printer_t{device_id}, offset, len);
return write_ertr::now();
});
}
Expand All @@ -90,7 +90,7 @@ static write_ertr::future<> do_writev(
size_t block_size)
{
LOG_PREFIX(block_do_writev);
TRACE("{} poffset={}~{}, {} buffers",
TRACE("{} poffset=0x{:x}~0x{:x}, {} buffers",
device_id_printer_t{device_id}, offset, bl.length(), bl.get_num_buffers());

// writev requires each buffer to be aligned to the disks' block
Expand All @@ -109,22 +109,22 @@ static write_ertr::future<> do_writev(
auto off = offset + p.offset;
auto len = p.length;
auto& iov = p.iov;
TRACE("{} poffset={}~{} dma_write ...",
TRACE("{} poffset=0x{:x}~0x{:x} dma_write ...",
device_id_printer_t{device_id}, off, len);
return device.dma_write(off, std::move(iov)
).handle_exception(
[FNAME, device_id, off, len](auto e) -> write_ertr::future<size_t>
{
ERROR("{} poffset={}~{} dma_write got error -- {}",
ERROR("{} poffset=0x{:x}~0x{:x} dma_write got error -- {}",
device_id_printer_t{device_id}, off, len, e);
return crimson::ct_error::input_output_error::make();
}).then([FNAME, device_id, off, len](size_t written) -> write_ertr::future<> {
if (written != len) {
ERROR("{} poffset={}~{} dma_write len={} inconsistent",
ERROR("{} poffset=0x{:x}~0x{:x} dma_write len=0x{:x} inconsistent",
device_id_printer_t{device_id}, off, len, written);
return crimson::ct_error::input_output_error::make();
}
TRACE("{} poffset={}~{} dma_write done",
TRACE("{} poffset=0x{:x}~0x{:x} dma_write done",
device_id_printer_t{device_id}, off, len);
return write_ertr::now();
});
Expand All @@ -140,7 +140,7 @@ static read_ertr::future<> do_read(
bufferptr &bptr)
{
LOG_PREFIX(block_do_read);
TRACE("{} poffset={}~{} ...", device_id_printer_t{device_id}, offset, len);
TRACE("{} poffset=0x{:x}~0x{:x} ...", device_id_printer_t{device_id}, offset, len);
assert(len <= bptr.length());
return device.dma_read(
offset,
Expand All @@ -153,16 +153,16 @@ static read_ertr::future<> do_read(
// once seastar::future<T>::handle_exception() returns seastar::futurize_t<T>
[FNAME, device_id, offset, len](auto e) -> read_ertr::future<size_t>
{
ERROR("{} poffset={}~{} got error -- {}",
ERROR("{} poffset=0x{:x}~0x{:x} got error -- {}",
device_id_printer_t{device_id}, offset, len, e);
return crimson::ct_error::input_output_error::make();
}).then([FNAME, device_id, offset, len](auto result) -> read_ertr::future<> {
if (result != len) {
ERROR("{} poffset={}~{} read len={} inconsistent",
ERROR("{} poffset=0x{:x}~0x{:x} read len=0x{:x} inconsistent",
device_id_printer_t{device_id}, offset, len, result);
return crimson::ct_error::input_output_error::make();
}
TRACE("{} poffset={}~{} done", device_id_printer_t{device_id}, offset, len);
TRACE("{} poffset=0x{:x}~0x{:x} done", device_id_printer_t{device_id}, offset, len);
return read_ertr::now();
});
}
Expand All @@ -174,7 +174,7 @@ SegmentStateTracker::write_out(
uint64_t offset)
{
LOG_PREFIX(SegmentStateTracker::write_out);
DEBUG("{} poffset={}~{}",
DEBUG("{} poffset=0x{:x}~0x{:x}",
device_id_printer_t{device_id}, offset, bptr.length());
return do_write(device_id, device, offset, bptr);
}
Expand All @@ -186,7 +186,7 @@ SegmentStateTracker::read_in(
uint64_t offset)
{
LOG_PREFIX(SegmentStateTracker::read_in);
DEBUG("{} poffset={}~{}",
DEBUG("{} poffset=0x{:x}~0x{:x}",
device_id_printer_t{device_id}, offset, bptr.length());
return do_read(
device_id,
Expand Down Expand Up @@ -230,7 +230,7 @@ block_sm_superblock_t make_superblock(
+ i * segments_per_shard * config_segment_size;
}

INFO("{} disk_size={}, segment_size={}, block_size={}",
INFO("{} disk_size=0x{:x}, segment_size=0x{:x}, block_size=0x{:x}",
device_id_printer_t{device_id},
size,
uint64_t(config_segment_size),
Expand All @@ -255,7 +255,7 @@ static check_create_device_ret check_create_device(
size_t size)
{
LOG_PREFIX(block_check_create_device);
INFO("path={}, size={}", path, size);
INFO("path={}, size=0x{:x}", path, size);
return seastar::open_file_dma(
path,
seastar::open_flags::exclusive |
Expand All @@ -266,7 +266,7 @@ static check_create_device_ret check_create_device(
file,
[size, FNAME, &path](auto &f) -> seastar::future<>
{
DEBUG("path={} created, truncating to {}", path, size);
DEBUG("path={} created, truncating to 0x{:x}", path, size);
ceph_assert(f);
return f.truncate(
size
Expand Down Expand Up @@ -318,8 +318,8 @@ open_device_ret open_device(
).then([stat, &path, FNAME](auto file) mutable {
return file.size().then([stat, file, &path, FNAME](auto size) mutable {
stat.size = size;
INFO("path={} successful, size={}, block_size={}",
path, stat.size, stat.block_size);
INFO("path={} successful, size=0x{:x}, block_size=0x{:x}",
path, stat.size, stat.block_size);
return std::make_pair(file, stat);
});
});
Expand Down Expand Up @@ -410,19 +410,19 @@ Segment::write_ertr::future<> BlockSegment::write(
{
LOG_PREFIX(BlockSegment::write);
auto paddr = paddr_t::make_seg_paddr(id, offset);
DEBUG("{} offset={}~{} poffset={} ...",
DEBUG("{} offset=0x{:x}~0x{:x} poffset=0x{:x} ...",
id, offset, bl.length(), manager.get_offset(paddr));

if (offset < write_pointer ||
offset % manager.superblock.block_size != 0 ||
bl.length() % manager.superblock.block_size != 0) {
ERROR("{} offset={}~{} poffset={} invalid write",
ERROR("{} offset=0x{:x}~0x{:x} poffset=0x{:x} invalid write",
id, offset, bl.length(), manager.get_offset(paddr));
return crimson::ct_error::invarg::make();
}

if (offset + bl.length() > manager.superblock.segment_size) {
ERROR("{} offset={}~{} poffset={} write out of the range {}",
ERROR("{} offset=0x{:x}~0x{:x} poffset=0x{:x} write out of the range 0x{:x}",
id, offset, bl.length(), manager.get_offset(paddr),
manager.superblock.segment_size);
return crimson::ct_error::enospc::make();
Expand All @@ -443,7 +443,7 @@ Segment::close_ertr::future<> BlockSegmentManager::segment_close(
LOG_PREFIX(BlockSegmentManager::segment_close);
auto s_id = id.device_segment_id();
int unused_bytes = get_segment_size() - write_pointer;
INFO("{} unused_bytes={} ...", id, unused_bytes);
INFO("{} unused_bytes=0x{:x} ...", id, unused_bytes);

assert(unused_bytes >= 0);
assert(id.device_id() == get_device_id());
Expand Down Expand Up @@ -693,32 +693,32 @@ SegmentManager::read_ertr::future<> BlockSegmentManager::read(
auto s_id = id.device_segment_id();
auto s_off = seg_addr.get_segment_off();
auto p_off = get_offset(addr);
DEBUG("{} offset={}~{} poffset={} ...", id, s_off, len, p_off);
DEBUG("{} offset=0x{:x}~0x{:x} poffset=0x{:x} ...", id, s_off, len, p_off);

assert(addr.get_device_id() == get_device_id());

if (s_off % superblock.block_size != 0 ||
len % superblock.block_size != 0) {
ERROR("{} offset={}~{} poffset={} invalid read", id, s_off, len, p_off);
ERROR("{} offset=0x{:x}~0x{:x} poffset=0x{:x} invalid read", id, s_off, len, p_off);
return crimson::ct_error::invarg::make();
}

if (s_id >= get_num_segments()) {
ERROR("{} offset={}~{} poffset={} segment-id out of range {}",
ERROR("{} offset=0x{:x}~0x{:x} poffset=0x{:x} segment-id out of range {}",
id, s_off, len, p_off, get_num_segments());
return crimson::ct_error::invarg::make();
}

if (s_off + len > superblock.segment_size) {
ERROR("{} offset={}~{} poffset={} read out of range {}",
ERROR("{} offset=0x{:x}~0x{:x} poffset=0x{:x} read out of range 0x{:x}",
id, s_off, len, p_off, superblock.segment_size);
return crimson::ct_error::invarg::make();
}

if (tracker->get(s_id) == segment_state_t::EMPTY) {
// XXX: not an error during scanning,
// might need refactor to increase the log level
DEBUG("{} offset={}~{} poffset={} invalid state {}",
DEBUG("{} offset=0x{:x}~0x{:x} poffset=0x{:x} invalid state {}",
id, s_off, len, p_off, tracker->get(s_id));
return crimson::ct_error::enoent::make();
}
Expand Down
15 changes: 10 additions & 5 deletions src/crimson/os/seastore/segment_manager/ephemeral.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ namespace {
namespace crimson::os::seastore::segment_manager {

std::ostream &operator<<(std::ostream &lhs, const ephemeral_config_t &c) {
return lhs << "ephemeral_config_t(size=" << c.size << ", block_size=" << c.block_size
<< ", segment_size=" << c.segment_size << ")";
return lhs << "ephemeral_config_t(size=0x"
<< std::hex << c.size
<< ", block_size=0x" << c.block_size
<< ", segment_size=0x" << c.segment_size
<< std::dec << ")";
}

EphemeralSegmentManagerRef create_test_ephemeral() {
Expand Down Expand Up @@ -141,7 +144,8 @@ Segment::write_ertr::future<> EphemeralSegmentManager::segment_write(
{
auto& seg_addr = addr.as_seg_paddr();
logger().debug(
"segment_write to segment {} at offset {}, physical offset {}, len {}, crc {}",
"segment_write to segment {} at offset 0x{:x}, "
"physical offset 0x{:x}, len 0x{:x}, crc 0x{:x}",
seg_addr.get_segment_id(),
seg_addr.get_segment_off(),
get_offset(addr),
Expand Down Expand Up @@ -268,7 +272,7 @@ SegmentManager::read_ertr::future<> EphemeralSegmentManager::read(

if (seg_addr.get_segment_off() + len > config.segment_size) {
logger().error(
"EphemeralSegmentManager::read: invalid offset {}~{}!",
"EphemeralSegmentManager::read: invalid offset {}~0x{:x}!",
addr,
len);
return crimson::ct_error::invarg::make();
Expand All @@ -279,7 +283,8 @@ SegmentManager::read_ertr::future<> EphemeralSegmentManager::read(
bufferlist bl;
bl.push_back(out);
logger().debug(
"segment_read to segment {} at offset {}, physical offset {}, length {}, crc {}",
"segment_read to segment {} at offset 0x{:x}, "
"physical offset 0x{:x}, length 0x{:x}, crc 0x{:x}",
seg_addr.get_segment_id().device_segment_id(),
seg_addr.get_segment_off(),
get_offset(addr),
Expand Down
Loading

0 comments on commit 0c65b41

Please sign in to comment.