]> git.hungrycats.org Git - bees/commitdiff
fs: handle ENOENT within lib
authorZygo Blaxell <bees@furryterror.org>
Fri, 29 Nov 2024 06:07:55 +0000 (01:07 -0500)
committerZygo Blaxell <bees@furryterror.org>
Sun, 1 Dec 2024 04:30:33 +0000 (23:30 -0500)
This prevents the storms of exceptions that occur when a subvol is
deleted.  We simply treat the entire tree as if it was empty.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
lib/fs.cc

index f063a0a6d068af447b1cc4a95ff49e0f61ead148..e75a92038c2b0c72a8b78e658ee5bebf39f2195a 100644 (file)
--- a/lib/fs.cc
+++ b/lib/fs.cc
@@ -774,6 +774,11 @@ namespace crucible {
                        ioctl_ptr->buf_size = buf_size;
                        // Don't bother supporting V1.  Kernels that old have other problems.
                        int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data());
+                       if (rv != 0 && errno == ENOENT) {
+                               // If we are searching a tree that is deleted or no longer exists, just return an empty list
+                               nr_items = 0;
+                               break;
+                       }
                        if (rv != 0 && errno != EOVERFLOW) {
                                return false;
                        }