diff --git a/kernel/include/kernel/Storage/NVMe/Namespace.h b/kernel/include/kernel/Storage/NVMe/Namespace.h index 635477ed96..d40852769d 100644 --- a/kernel/include/kernel/Storage/NVMe/Namespace.h +++ b/kernel/include/kernel/Storage/NVMe/Namespace.h @@ -11,7 +11,7 @@ namespace Kernel class NVMeNamespace : public StorageDevice { public: - static BAN::ErrorOr> create(NVMeController&, uint32_t nsid, uint64_t block_count, uint32_t block_size); + static BAN::ErrorOr> create(NVMeController&, uint32_t ns_index, uint32_t nsid, uint64_t block_count, uint32_t block_size); virtual uint32_t sector_size() const override { return m_block_size; } virtual uint64_t total_size() const override { return m_block_size * m_block_count; } @@ -20,7 +20,7 @@ namespace Kernel virtual BAN::StringView name() const { return m_name; } private: - NVMeNamespace(NVMeController&, uint32_t nsid, uint64_t block_count, uint32_t block_size); + NVMeNamespace(NVMeController&, uint32_t ns_index, uint32_t nsid, uint64_t block_count, uint32_t block_size); BAN::ErrorOr initialize(); virtual BAN::ErrorOr read_sectors_impl(uint64_t lba, uint64_t sector_count, BAN::ByteSpan) override; diff --git a/kernel/kernel/Storage/NVMe/Controller.cpp b/kernel/kernel/Storage/NVMe/Controller.cpp index d80cda8fe9..39d62ce176 100644 --- a/kernel/kernel/Storage/NVMe/Controller.cpp +++ b/kernel/kernel/Storage/NVMe/Controller.cpp @@ -213,7 +213,7 @@ namespace Kernel dprintln(" block size {} B", block_size); dprintln(" total {} MiB", block_count * block_size / (1 << 20)); - auto ns = TRY(NVMeNamespace::create(*this, nsid, block_count, block_size)); + auto ns = TRY(NVMeNamespace::create(*this, m_namespaces.size(), nsid, block_count, block_size)); TRY(m_namespaces.push_back(BAN::move(ns))); } diff --git a/kernel/kernel/Storage/NVMe/Namespace.cpp b/kernel/kernel/Storage/NVMe/Namespace.cpp index 866b656652..e6ea422bcd 100644 --- a/kernel/kernel/Storage/NVMe/Namespace.cpp +++ b/kernel/kernel/Storage/NVMe/Namespace.cpp @@ -14,9 +14,9 @@ namespace Kernel return minor++; } - BAN::ErrorOr> NVMeNamespace::create(NVMeController& controller, uint32_t nsid, uint64_t block_count, uint32_t block_size) + BAN::ErrorOr> NVMeNamespace::create(NVMeController& controller, uint32_t ns_index, uint32_t nsid, uint64_t block_count, uint32_t block_size) { - auto* namespace_ptr = new NVMeNamespace(controller, nsid, block_count, block_size); + auto* namespace_ptr = new NVMeNamespace(controller, ns_index, nsid, block_count, block_size); if (namespace_ptr == nullptr) return BAN::Error::from_errno(ENOMEM); auto ns = BAN::RefPtr::adopt(namespace_ptr); @@ -24,7 +24,7 @@ namespace Kernel return ns; } - NVMeNamespace::NVMeNamespace(NVMeController& controller, uint32_t nsid, uint64_t block_count, uint32_t block_size) + NVMeNamespace::NVMeNamespace(NVMeController& controller, uint32_t ns_index, uint32_t nsid, uint64_t block_count, uint32_t block_size) : m_controller(controller) , m_nsid(nsid) , m_block_size(block_size) @@ -35,7 +35,7 @@ namespace Kernel ASSERT(m_controller.name().size() + 2 < sizeof(m_name)); memcpy(m_name, m_controller.name().data(), m_controller.name().size()); m_name[m_controller.name().size() + 0] = 'n'; - m_name[m_controller.name().size() + 1] = '1' + minor(m_rdev); + m_name[m_controller.name().size() + 1] = '1' + ns_index; m_name[m_controller.name().size() + 2] = '\0'; }