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

Method write_zeroes

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

Source from the content-addressed store, hash-verified

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;
134
135 // SAFETY: FFI call with valid arguments
136 let result = unsafe {
137 libc::fallocate(
138 self.fd as libc::c_int,
139 mode,
140 offset as libc::off_t,
141 length as libc::off_t,
142 )
143 };
144 if result < 0 {
145 return Err(AsyncIoError::WriteZeroes(std::io::Error::last_os_error()));
146 }
147
148 self.completion_list.push_back((user_data, result));
149 self.eventfd.write(1).unwrap();
150
151 Ok(())
152 }
153}
154
155#[cfg(test)]

Callers 6

execute_asyncMethod · 0.45
test_write_zeroesFunction · 0.45
zero_clusterMethod · 0.45
write_zeroes_readFunction · 0.45
discard_sets_zero_flagFunction · 0.45

Calls 1

writeMethod · 0.45

Tested by 4

test_write_zeroesFunction · 0.36
write_zeroes_readFunction · 0.36
discard_sets_zero_flagFunction · 0.36