MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / submit_and_wait_fsync

Method submit_and_wait_fsync

nodedb-wal/src/uring_writer.rs:268–293  ·  view source on GitHub ↗

Submit an fsync SQE and wait for the CQE.

(&mut self)

Source from the content-addressed store, hash-verified

266
267 /// Submit an fsync SQE and wait for the CQE.
268 fn submit_and_wait_fsync(&mut self) -> Result<()> {
269 let fd = types::Fd(self.file.as_raw_fd());
270 let fsync_op = opcode::Fsync::new(fd).build().user_data(0x02);
271
272 unsafe {
273 self.ring
274 .submission()
275 .push(&fsync_op)
276 .map_err(|_| WalError::Io(std::io::Error::other("io_uring SQ full")))?;
277 }
278
279 self.ring.submit_and_wait(1).map_err(WalError::Io)?;
280
281 let cqe =
282 self.ring.completion().next().ok_or_else(|| {
283 WalError::Io(std::io::Error::other("io_uring: no CQE after fsync"))
284 })?;
285
286 if cqe.result() < 0 {
287 return Err(WalError::Io(std::io::Error::from_raw_os_error(
288 -cqe.result(),
289 )));
290 }
291
292 Ok(())
293 }
294
295 /// Seal the WAL.
296 pub fn seal(&mut self) -> Result<()> {

Callers 1

submit_and_syncMethod · 0.80

Calls 4

as_raw_fdMethod · 0.45
buildMethod · 0.45
pushMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected