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

Method punch_hole

block/src/qcow_async.rs:202–238  ·  view source on GitHub ↗
(&mut self, offset: u64, length: u64, user_data: u64)

Source from the content-addressed store, hash-verified

200 }
201
202 fn punch_hole(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> {
203 let virtual_size = self.metadata.virtual_size();
204 let cluster_size = self.cluster_size;
205
206 let result = self
207 .metadata
208 .deallocate_bytes(
209 offset,
210 length as usize,
211 self.sparse,
212 virtual_size,
213 cluster_size,
214 self.backing_file.as_deref(),
215 )
216 .map_err(AsyncIoError::PunchHole);
217
218 match result {
219 Ok(actions) => {
220 for action in &actions {
221 self.apply_dealloc_action(action);
222 }
223 self.completion_list.push_back((user_data, 0));
224 self.eventfd.write(1).unwrap();
225 Ok(())
226 }
227 Err(e) => {
228 let errno = if let AsyncIoError::PunchHole(ref io_err) = e {
229 -io_err.raw_os_error().unwrap_or(libc::EIO)
230 } else {
231 -libc::EIO
232 };
233 self.completion_list.push_back((user_data, errno));
234 self.eventfd.write(1).unwrap();
235 Ok(())
236 }
237 }
238 }
239
240 fn write_zeroes(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> {
241 // For QCOW2, zeroing and hole punching are the same operation.

Calls 4

apply_dealloc_actionMethod · 0.80
virtual_sizeMethod · 0.45
deallocate_bytesMethod · 0.45
writeMethod · 0.45