diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 37b14e0..2c80aaa 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -95,6 +95,7 @@ namespace crucible { iterator m_end = nullptr; friend struct BtrfsIoctlLogicalInoArgs; } m_iors; + BtrfsDataContainer m_container; }; ostream & operator<<(ostream &os, const BtrfsIoctlLogicalInoArgs &p); diff --git a/lib/fs.cc b/lib/fs.cc index 8a7a655..2b2793d 100644 --- a/lib/fs.cc +++ b/lib/fs.cc @@ -303,7 +303,8 @@ namespace crucible { } BtrfsIoctlLogicalInoArgs::BtrfsIoctlLogicalInoArgs(uint64_t new_logical, size_t new_size) : - m_container_size(new_size) + m_container_size(new_size), + m_container(new_size) { memset_zero(this); logical = new_logical; @@ -374,9 +375,8 @@ namespace crucible { BtrfsIoctlLogicalInoArgs::do_ioctl_nothrow(int fd) { btrfs_ioctl_logical_ino_args *p = static_cast(this); - thread_local BtrfsDataContainer container; - inodes = reinterpret_cast(container.prepare(m_container_size)); - size = container.get_size(); + inodes = reinterpret_cast(m_container.prepare(m_container_size)); + size = m_container.get_size(); m_iors.clear(); @@ -452,7 +452,7 @@ namespace crucible { BtrfsIoctlInoPathArgs::do_ioctl_nothrow(int fd) { btrfs_ioctl_ino_path_args *p = static_cast(this); - thread_local BtrfsDataContainer container; + BtrfsDataContainer container(m_container_size); fspath = reinterpret_cast(container.prepare(m_container_size)); size = m_container_size; @@ -816,13 +816,8 @@ namespace crucible { // Keep the ioctl buffer from one run to the next to save on malloc costs size_t target_buf_size = sizeof(btrfs_ioctl_search_args_v2) + m_buf_size; - thread_local vector ioctl_arg; - if (ioctl_arg.size() < m_buf_size) { - ioctl_arg = vector_copy_struct(this); - ioctl_arg.resize(target_buf_size); - } else { - memcpy(ioctl_arg.data(), static_cast(this), sizeof(btrfs_ioctl_search_key)); - } + vector ioctl_arg = vector_copy_struct(this); + ioctl_arg.resize(target_buf_size); btrfs_ioctl_search_args_v2 *ioctl_ptr = reinterpret_cast(ioctl_arg.data());