diff --git a/cmd/zfs_object_agent/zettacache/src/open.rs b/cmd/zfs_object_agent/zettacache/src/open.rs index 92aa51ade934..39a968ac9537 100644 --- a/cmd/zfs_object_agent/zettacache/src/open.rs +++ b/cmd/zfs_object_agent/zettacache/src/open.rs @@ -80,8 +80,16 @@ async fn discover_devices(dir_path: &Path, target_guid: Option) -> Result { + if meta.is_dir() { + continue; + } + } + Err(why) => { + debug!("discovery: {entry:?}.metadata() failed. error: {why:?}"); + continue; + } } // In certain directories under /dev we've come across device symlinks @@ -90,18 +98,25 @@ async fn discover_devices(dir_path: &Path, target_guid: Option) -> Result { + if !canonical_entries.contains(&canonical_path) { + canonical_entries.insert(canonical_path); - // We use the original directory path here instead of the - // resolved/canonical path to avoid surprising the user. E.g. `zcache - // list -f` should show device paths from the discovery directory - // supplied by the user instead of the resolved device paths. - discovery.push(DiscoveredDevice::from_path(path)) + // We use the original directory path here instead of the + // resolved/canonical path to avoid surprising the user. E.g. `zcache + // list -f` should show device paths from the discovery directory + // supplied by the user instead of the resolved device paths. + discovery.push(DiscoveredDevice::from_path(path)) + } + } + Err(why) => { + debug!("discovery: fs::canonicalize({path:?}) failed. error: {why:?}"); + continue; + } + } } + while let Some(result) = discovery.next().await { match result { Ok(device) => {