mirror of
				https://github.com/Zygo/bees.git
				synced 2025-11-04 04:00:36 +01:00 
			
		
		
		
	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 <bees@furryterror.org>
This commit is contained in:
		@@ -27,20 +27,16 @@ namespace crucible {
 | 
				
			|||||||
	// wrapper around fallocate(...FALLOC_FL_PUNCH_HOLE...)
 | 
						// wrapper around fallocate(...FALLOC_FL_PUNCH_HOLE...)
 | 
				
			||||||
	void punch_hole(int fd, off_t offset, off_t len);
 | 
						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 {
 | 
						struct BtrfsExtentSame {
 | 
				
			||||||
		virtual ~BtrfsExtentSame();
 | 
							virtual ~BtrfsExtentSame();
 | 
				
			||||||
		BtrfsExtentSame(int src_fd, off_t src_offset, off_t src_length);
 | 
							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();
 | 
							virtual void do_ioctl();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		uint64_t m_logical_offset = 0;
 | 
							uint64_t m_logical_offset = 0;
 | 
				
			||||||
		uint64_t m_length = 0;
 | 
							uint64_t m_length = 0;
 | 
				
			||||||
		int m_fd;
 | 
							int m_fd;
 | 
				
			||||||
		vector<BtrfsExtentInfo> m_info;
 | 
							vector<btrfs_ioctl_same_extent_info> m_info;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ostream & operator<<(ostream &os, const btrfs_ioctl_same_extent_info *info);
 | 
						ostream & operator<<(ostream &os, const btrfs_ioctl_same_extent_info *info);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								lib/fs.cc
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								lib/fs.cc
									
									
									
									
									
								
							@@ -33,18 +33,6 @@ namespace crucible {
 | 
				
			|||||||
#endif
 | 
					#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) :
 | 
						BtrfsExtentSame::BtrfsExtentSame(int src_fd, off_t src_offset, off_t src_length) :
 | 
				
			||||||
		m_logical_offset(src_offset),
 | 
							m_logical_offset(src_offset),
 | 
				
			||||||
		m_length(src_length),
 | 
							m_length(src_length),
 | 
				
			||||||
@@ -57,9 +45,12 @@ namespace crucible {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void
 | 
						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 &
 | 
						ostream &
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user