MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / punch_hole

Method punch_hole

block/src/raw_sync.rs:110–130  ·  view source on GitHub ↗
(&mut self, offset: u64, length: u64, user_data: u64)

Source from the content-addressed store, hash-verified

108 }
109
110 fn punch_hole(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> {
111 let mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
112
113 // SAFETY: FFI call with valid arguments
114 let result = unsafe {
115 libc::fallocate(
116 self.fd as libc::c_int,
117 mode,
118 offset as libc::off_t,
119 length as libc::off_t,
120 )
121 };
122 if result < 0 {
123 return Err(AsyncIoError::PunchHole(std::io::Error::last_os_error()));
124 }
125
126 self.completion_list.push_back((user_data, result));
127 self.eventfd.write(1).unwrap();
128
129 Ok(())
130 }
131
132 fn write_zeroes(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> {
133 let mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE;

Callers 4

execute_asyncMethod · 0.45
test_punch_holeFunction · 0.45

Calls 1

writeMethod · 0.45

Tested by 2

test_punch_holeFunction · 0.36