From: Zygo Blaxell Date: Mon, 27 Jan 2025 02:59:07 +0000 (-0500) Subject: hash: handle $BEESHOME on non-btrfs X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6908420adcf3fbafef8bbde8a25f8bac65424b6;p=bees hash: handle $BEESHOME on non-btrfs bees explicitly supports storing $BEESHOME on another filesystem, and does not require that filesystem to be btrfs; however, if $BEESHOME is on a non-btrfs filesystem, there is an exception on every startup when trying to identify the subvol root of the hash table file in order to blacklist it, because non-btrfs filesystems don't have subvol roots. Fix by checking not only whether $BEESHOME is on btrfs, but whether it is on the _same_ btrfs, as the bees root, without throwing an exception. The hash table is blacklisted only when both filesystems are btrfs and have the same fsid. Signed-off-by: Zygo Blaxell --- diff --git a/src/bees-hash.cc b/src/bees-hash.cc index ab177377..88e184ab 100644 --- a/src/bees-hash.cc +++ b/src/bees-hash.cc @@ -811,8 +811,18 @@ BeesHashTable::BeesHashTable(shared_ptr ctx, string filename, off_t prefetch_loop(); }); - // Blacklist might fail if the hash table is not stored on a btrfs + // Blacklist might fail if the hash table is not stored on a btrfs, + // or if it's on a _different_ btrfs catch_all([&]() { + // Root is definitely a btrfs + BtrfsIoctlFsInfoArgs root_info; + root_info.do_ioctl(m_ctx->root_fd()); + // Hash might not be a btrfs + BtrfsIoctlFsInfoArgs hash_info; + if (hash_info.do_ioctl_nothrow(m_fd)) return; + // If Hash is a btrfs, Root must be the same one + if (root_info.fsid() != hash_info.fsid()) return; + // Hash is on the same one, blacklist it m_ctx->blacklist_insert(BeesFileId(m_fd)); }); }