[pbs-devel] [PATCH proxmox-backup] fix #4823: datastore: ignore vanished files when walking directory

Gabriel Goller g.goller at proxmox.com
Tue Sep 5 11:37:47 CEST 2023


When walking through a datastore on a GC run, it can
happen that the snapshot is deleted, and then walked over.
For example:
- read dir entry for group
- walk entries (snapshots)
- snapshot X is removed/pruned
- walking reaches snapshot X, but ENOENT
Previously we bailed here, now we just ignore it.

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index fe75d9b5..d135ad90 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -869,18 +869,24 @@ impl DataStore {
         let handle_entry_err = |err: walkdir::Error| {
             if let Some(inner) = err.io_error() {
                 if let Some(path) = err.path() {
-                    if inner.kind() == io::ErrorKind::PermissionDenied {
-                        // only allow to skip ext4 fsck directory, avoid GC if, for example,
-                        // a user got file permissions wrong on datastore rsync to new server
-                        if err.depth() > 1 || !path.ends_with("lost+found") {
-                            bail!("cannot continue garbage-collection safely, permission denied on: {:?}", path)
+                    match inner.kind() {
+                        io::ErrorKind::PermissionDenied => {
+                            // only allow to skip ext4 fsck directory, avoid GC if, for example,
+                            // a user got file permissions wrong on datastore rsync to new server
+                            if err.depth() > 1 || !path.ends_with("lost+found") {
+                                bail!("cannot continue garbage-collection safely, permission denied on: {:?}", path)
+                            }
+                        }
+                        io::ErrorKind::NotFound => {
+                            // ignore vanished file
+                        }
+                        _ => {
+                            bail!(
+                                "unexpected error on datastore traversal: {} - {:?}",
+                                inner,
+                                path
+                            )
                         }
-                    } else {
-                        bail!(
-                            "unexpected error on datastore traversal: {} - {:?}",
-                            inner,
-                            path
-                        )
                     }
                 } else {
                     bail!("unexpected error on datastore traversal: {}", inner)
-- 
2.39.2






More information about the pbs-devel mailing list