From 72c3bf8438830b65cae7bdaff126053e562280e5 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Fri, 29 Nov 2024 01:07:55 -0500 Subject: [PATCH] fs: handle ENOENT within lib 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 --- lib/fs.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/fs.cc b/lib/fs.cc index f063a0a..e75a920 100644 --- 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; }