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

Method find_inflight_request

virtio-devices/src/block.rs:427–445  ·  view source on GitHub ↗
(&mut self, completed_head: u16)

Source from the content-addressed store, hash-verified

425
426 #[inline]
427 fn find_inflight_request(&mut self, completed_head: u16) -> Result<Request> {
428 // This loop neatly handles the fast path where the completions are
429 // in order (it turns into just a pop_front()) and the 1% of the time
430 // (analysis during boot) where slight out of ordering has been
431 // observed e.g.
432 // Submissions: 1 2 3 4 5 6 7
433 // Completions: 2 1 3 5 4 7 6
434 // In this case find the corresponding item and swap it with the front
435 // This is a O(1) operation and is prepared for the future as it it likely
436 // the next completion would be for the one that was skipped which will
437 // now be the new front.
438 for (i, (head, _)) in self.inflight_requests.iter().enumerate() {
439 if head == &completed_head {
440 return Ok(self.inflight_requests.swap_remove_front(i).unwrap().1);
441 }
442 }
443
444 Err(Error::MissingEntryRequestList)
445 }
446
447 fn process_queue_complete(&mut self) -> Result<()> {
448 let mem = self.mem.memory();

Callers 1

Calls 1

iterMethod · 0.80

Tested by

no test coverage detected