-
Notifications
You must be signed in to change notification settings - Fork 133
nvme: Pass controller instance ID to NvmeDriver for better tracing #1661
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
be125d2
746da07
e76bedf
02fbdbc
a9818bd
bdc7dd1
38bc76e
e83946a
f12f10a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,9 @@ impl NvmeManager { | |
enum Request { | ||
Inspect(inspect::Deferred), | ||
ForceLoadDriver(inspect::DeferredUpdate), | ||
GetNamespace(Rpc<(String, u32), Result<nvme_driver::Namespace, NamespaceError>>), | ||
GetNamespace( | ||
Rpc<(Option<String>, String, u32), Result<nvme_driver::Namespace, NamespaceError>>, | ||
), | ||
Save(Rpc<(), Result<NvmeManagerSavedState, anyhow::Error>>), | ||
Shutdown { | ||
span: tracing::Span, | ||
|
@@ -191,13 +193,22 @@ pub struct NvmeManagerClient { | |
impl NvmeManagerClient { | ||
pub async fn get_namespace( | ||
&self, | ||
controller_instance_id: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this mandatory (a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made the parameter mandatory by changing from |
||
pci_id: String, | ||
nsid: u32, | ||
) -> anyhow::Result<nvme_driver::Namespace> { | ||
Ok(self | ||
.sender | ||
.call(Request::GetNamespace, (pci_id.clone(), nsid)) | ||
.instrument(tracing::info_span!("nvme_get_namespace", pci_id, nsid)) | ||
.call( | ||
Request::GetNamespace, | ||
(controller_instance_id.clone(), pci_id.clone(), nsid), | ||
) | ||
.instrument(tracing::info_span!( | ||
"nvme_get_namespace", | ||
controller_instance_id = controller_instance_id.as_ref().map(|s| s.as_str()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the .as_ref() necessary here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
pci_id, | ||
nsid | ||
)) | ||
.await | ||
.context("nvme manager is shut down")??) | ||
} | ||
|
@@ -235,7 +246,7 @@ impl NvmeManagerWorker { | |
match req { | ||
Request::Inspect(deferred) => deferred.inspect(&self), | ||
Request::ForceLoadDriver(update) => { | ||
match self.get_driver(update.new_value().to_owned()).await { | ||
match self.get_driver(None, update.new_value().to_owned()).await { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of "None", create a dummy string: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced None with "force-load" dummy string in the ForceLoadDriver case in commit e76bedf. |
||
Ok(_) => { | ||
let pci_id = update.new_value().to_string(); | ||
update.succeed(pci_id); | ||
|
@@ -246,8 +257,8 @@ impl NvmeManagerWorker { | |
} | ||
} | ||
Request::GetNamespace(rpc) => { | ||
rpc.handle(async |(pci_id, nsid)| { | ||
self.get_namespace(pci_id.clone(), nsid) | ||
rpc.handle(async |(controller_instance_id, pci_id, nsid)| { | ||
self.get_namespace(controller_instance_id, pci_id.clone(), nsid) | ||
.map_err(|source| NamespaceError { pci_id, source }) | ||
.await | ||
}) | ||
|
@@ -283,9 +294,13 @@ impl NvmeManagerWorker { | |
if !nvme_keepalive || !self.save_restore_supported { | ||
async { | ||
join_all(self.devices.drain().map(|(pci_id, driver)| { | ||
driver | ||
.shutdown() | ||
.instrument(tracing::info_span!("shutdown_nvme_driver", pci_id)) | ||
let controller_instance_id = driver.controller_instance_id(); | ||
driver.shutdown().instrument(tracing::info_span!( | ||
"shutdown_nvme_driver", | ||
pci_id, | ||
controller_instance_id = | ||
controller_instance_id.as_ref().map(|s| s.as_str()) | ||
)) | ||
})) | ||
.await | ||
} | ||
|
@@ -296,6 +311,7 @@ impl NvmeManagerWorker { | |
|
||
async fn get_driver( | ||
&mut self, | ||
controller_instance_id: Option<String>, | ||
pci_id: String, | ||
) -> Result<&mut nvme_driver::NvmeDriver<VfioDevice>, InnerError> { | ||
let driver = match self.devices.entry(pci_id.to_owned()) { | ||
|
@@ -328,6 +344,7 @@ impl NvmeManagerWorker { | |
self.vp_count, | ||
device, | ||
self.is_isolated, | ||
controller_instance_id, | ||
) | ||
.instrument(tracing::info_span!( | ||
"nvme_driver_init", | ||
|
@@ -344,10 +361,13 @@ impl NvmeManagerWorker { | |
|
||
async fn get_namespace( | ||
&mut self, | ||
controller_instance_id: Option<String>, | ||
pci_id: String, | ||
nsid: u32, | ||
) -> Result<nvme_driver::Namespace, InnerError> { | ||
let driver = self.get_driver(pci_id.to_owned()).await?; | ||
let driver = self | ||
.get_driver(controller_instance_id, pci_id.to_owned()) | ||
.await?; | ||
driver | ||
.namespace(nsid) | ||
.await | ||
|
@@ -407,6 +427,7 @@ impl NvmeManagerWorker { | |
vfio_device, | ||
&disk.driver_state, | ||
self.is_isolated, | ||
None, // controller_instance_id is not persisted in saved state | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unfortunate. Is there a way to re-hook-up the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For restored drivers, I now generate the name as |
||
) | ||
.instrument(tracing::info_span!("nvme_driver_restore")) | ||
.await?; | ||
|
@@ -440,7 +461,7 @@ impl AsyncResolveResource<DiskHandleKind, NvmeDiskConfig> for NvmeDiskResolver { | |
) -> Result<Self::Output, Self::Error> { | ||
let namespace = self | ||
.manager | ||
.get_namespace(rsrc.pci_id, rsrc.nsid) | ||
.get_namespace(rsrc.controller_instance_id, rsrc.pci_id, rsrc.nsid) | ||
.await | ||
.context("could not open nvme namespace")?; | ||
|
||
|
@@ -450,6 +471,7 @@ impl AsyncResolveResource<DiskHandleKind, NvmeDiskConfig> for NvmeDiskResolver { | |
|
||
#[derive(MeshPayload, Default)] | ||
pub struct NvmeDiskConfig { | ||
pub controller_instance_id: Option<String>, | ||
pub pci_id: String, | ||
pub nsid: u32, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
controller_instance_id
todebug_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
controller_instance_id
todebug_id
throughout the codebase in commit e76bedf.