Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/importers/debezium_cdc_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ ImportStats DebeziumCDCImporter::importData(
ImportStats DebeziumCDCImporter::streamEvents(const ImportOptions& options,
CDCEventCallback callback) {
ImportStats stats{};
const auto start_time = std::chrono::steady_clock::now();

const auto deadline = (options.deadline_ms > 0)
? std::optional<std::chrono::steady_clock::time_point>(
Expand Down
20 changes: 16 additions & 4 deletions src/storage/nvme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ bool NVMeManager::resetZone(uint64_t zone_offset) {
if (!config_.enable_zns || config_.device_path.empty()) {
return false;
}
constexpr uint64_t SECTOR_SIZE = 512;
if (config_.zone_capacity_bytes == 0 || (zone_offset % SECTOR_SIZE) != 0) {
THEMIS_WARN("NVMeManager::resetZone: invalid zone offset={} or capacity={}",
zone_offset, config_.zone_capacity_bytes);
return false;
}
std::lock_guard<std::mutex> lock(zone_mutex_);
#ifdef __linux__
int fd = ::open(config_.device_path.c_str(), O_RDWR | O_CLOEXEC);
Expand All @@ -528,8 +534,6 @@ bool NVMeManager::resetZone(uint64_t zone_offset) {
config_.device_path, std::strerror(errno));
return false;
}
// Sector size is 512 bytes on most ZNS drives
constexpr uint64_t SECTOR_SIZE = 512;
struct blk_zone_range range{};
range.sector = zone_offset / SECTOR_SIZE;
range.nr_sectors = config_.zone_capacity_bytes / SECTOR_SIZE;
Expand All @@ -549,6 +553,12 @@ bool NVMeManager::finishZone(uint64_t zone_offset) {
if (!config_.enable_zns || config_.device_path.empty()) {
return false;
}
constexpr uint64_t SECTOR_SIZE = 512;
if (config_.zone_capacity_bytes == 0 || (zone_offset % SECTOR_SIZE) != 0) {
THEMIS_WARN("NVMeManager::finishZone: invalid zone offset={} or capacity={}",
zone_offset, config_.zone_capacity_bytes);
return false;
}
std::lock_guard<std::mutex> lock(zone_mutex_);
#ifdef __linux__
int fd = ::open(config_.device_path.c_str(), O_RDWR | O_CLOEXEC);
Expand All @@ -557,7 +567,6 @@ bool NVMeManager::finishZone(uint64_t zone_offset) {
config_.device_path, std::strerror(errno));
return false;
}
constexpr uint64_t SECTOR_SIZE = 512;
struct blk_zone_range range{};
range.sector = zone_offset / SECTOR_SIZE;
range.nr_sectors = config_.zone_capacity_bytes / SECTOR_SIZE;
Expand All @@ -577,9 +586,12 @@ uint64_t NVMeManager::getZoneWritePointer(uint64_t zone_offset) const {
if (!config_.enable_zns || config_.device_path.empty()) {
return UINT64_MAX;
}
constexpr uint64_t SECTOR_SIZE = 512;
if (config_.zone_capacity_bytes == 0 || (zone_offset % SECTOR_SIZE) != 0) {
return UINT64_MAX;
}
std::lock_guard<std::mutex> lock(zone_mutex_);
#ifdef __linux__
constexpr uint64_t SECTOR_SIZE = 512;
int fd = ::open(config_.device_path.c_str(), O_RDONLY | O_CLOEXEC);
if (fd < 0) {
return UINT64_MAX;
Expand Down
15 changes: 15 additions & 0 deletions tests/test_nvme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <filesystem>
#include <fstream>
#include <cstring>
#include <limits>
#include <string>
#include <thread>

Expand Down Expand Up @@ -185,6 +186,20 @@ TEST_F(NVMeBackgroundThreadsTest, AtMostSixteen) {
EXPECT_LE(mgr.recommendedBackgroundThreads(), 16u);
}

class NVMeZoneValidationTest : public ::testing::Test {};

TEST_F(NVMeZoneValidationTest, RejectsMisalignedZoneOffsets) {
NVMeConfig cfg;
cfg.enable_zns = true;
cfg.device_path = "/dev/nvme0n1";
cfg.zone_capacity_bytes = 512u * 1024u;

NVMeManager mgr(cfg);
EXPECT_FALSE(mgr.resetZone(7));
EXPECT_FALSE(mgr.finishZone(511));
EXPECT_EQ(mgr.getZoneWritePointer(13), std::numeric_limits<uint64_t>::max());
}

// ─────────────────────────────────────────────────────────────────────────────
// NVMeIoUringTest – io_uring disabled → isIoUringActive() == false
// ─────────────────────────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 1214 files
Loading