Submit an fsync SQE and wait for the CQE.
(&mut self)
| 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<()> { |
no test coverage detected