1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

fs: add a runtime debug stream for btrfs tree searches

This allows plugging in an ostream at run time so that we can audit all
the search calls we are doing.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2025-02-02 12:25:50 -05:00
parent 75040789c6
commit a3c0ba0d69
2 changed files with 5 additions and 0 deletions

View File

@ -201,6 +201,7 @@ namespace crucible {
static thread_local size_t s_calls; static thread_local size_t s_calls;
static thread_local size_t s_loops; static thread_local size_t s_loops;
static thread_local size_t s_loops_empty; static thread_local size_t s_loops_empty;
static thread_local shared_ptr<ostream> s_debug_ostream;
}; };
ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key); ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);

View File

@ -757,6 +757,7 @@ namespace crucible {
thread_local size_t BtrfsIoctlSearchKey::s_calls = 0; thread_local size_t BtrfsIoctlSearchKey::s_calls = 0;
thread_local size_t BtrfsIoctlSearchKey::s_loops = 0; thread_local size_t BtrfsIoctlSearchKey::s_loops = 0;
thread_local size_t BtrfsIoctlSearchKey::s_loops_empty = 0; thread_local size_t BtrfsIoctlSearchKey::s_loops_empty = 0;
thread_local shared_ptr<ostream> BtrfsIoctlSearchKey::s_debug_ostream;
bool bool
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd) BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
@ -776,6 +777,9 @@ namespace crucible {
ioctl_ptr = ioctl_arg.get<btrfs_ioctl_search_args_v2>(); ioctl_ptr = ioctl_arg.get<btrfs_ioctl_search_args_v2>();
ioctl_ptr->key = static_cast<const btrfs_ioctl_search_key&>(*this); ioctl_ptr->key = static_cast<const btrfs_ioctl_search_key&>(*this);
ioctl_ptr->buf_size = buf_size; ioctl_ptr->buf_size = buf_size;
if (s_debug_ostream) {
(*s_debug_ostream) << "bisk " << (ioctl_ptr->key) << "\n";
}
// Don't bother supporting V1. Kernels that old have other problems. // Don't bother supporting V1. Kernels that old have other problems.
int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data()); int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data());
++s_calls; ++s_calls;