From b8b19dbc31af27903c8735a5ae07a5765b5a63c3 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Wed, 8 Jun 2022 12:20:55 -0700 Subject: [PATCH] discovery: don't bail on fs::canonicalize() errors (#473) --- cmd/zfs_object_agent/zettacache/src/open.rs | 39 ++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) 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) => {