From cb2c20ccc99fb24aee772decf77edc5bb22bfc42 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 23 Oct 2022 14:01:38 -0400 Subject: [PATCH] fs: get rid of base class btrfs_ioctl_same_extent_info We only use BtrfsExtentInfo when it's exactly equivalent to the base, so drop the derived class. While we're here, fix BtrfsExtentSame::add so it uses a btrfs-compatible uint64_t instead of an off_t. Signed-off-by: Zygo Blaxell --- include/crucible/fs.h | 8 ++------ lib/fs.cc | 19 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 89e0271..7ab6b1a 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -27,20 +27,16 @@ namespace crucible { // wrapper around fallocate(...FALLOC_FL_PUNCH_HOLE...) void punch_hole(int fd, off_t offset, off_t len); - struct BtrfsExtentInfo : public btrfs_ioctl_same_extent_info { - BtrfsExtentInfo(int dst_fd, off_t dst_offset); - }; - struct BtrfsExtentSame { virtual ~BtrfsExtentSame(); BtrfsExtentSame(int src_fd, off_t src_offset, off_t src_length); - void add(int fd, off_t offset); + void add(int fd, uint64_t offset); virtual void do_ioctl(); uint64_t m_logical_offset = 0; uint64_t m_length = 0; int m_fd; - vector m_info; + vector m_info; }; ostream & operator<<(ostream &os, const btrfs_ioctl_same_extent_info *info); diff --git a/lib/fs.cc b/lib/fs.cc index cd20c77..90a0bab 100644 --- a/lib/fs.cc +++ b/lib/fs.cc @@ -33,18 +33,6 @@ namespace crucible { #endif } - BtrfsExtentInfo::BtrfsExtentInfo(int dst_fd, off_t dst_offset) : - btrfs_ioctl_same_extent_info( (btrfs_ioctl_same_extent_info) { } ) - { - assert(fd == 0); - assert(logical_offset == 0); - assert(bytes_deduped == 0); - assert(status == 0); - assert(reserved == 0); - fd = dst_fd; - logical_offset = dst_offset; - } - BtrfsExtentSame::BtrfsExtentSame(int src_fd, off_t src_offset, off_t src_length) : m_logical_offset(src_offset), m_length(src_length), @@ -57,9 +45,12 @@ namespace crucible { } void - BtrfsExtentSame::add(int fd, off_t offset) + BtrfsExtentSame::add(int const fd, uint64_t const offset) { - m_info.push_back(BtrfsExtentInfo(fd, offset)); + m_info.push_back( (btrfs_ioctl_same_extent_info) { + .fd = fd, + .logical_offset = offset, + }); } ostream &