block: small improvements for process_queue()
@@ -285,8 +285,9 @@ impl Block {
let queue = &mut self.queues[queue_index];
let mut used_any = false;
+
while let Some(head) = queue.pop_or_enable_notification(mem) {
- let maybe_len = match Request::parse(&head, mem, self.disk.nsectors()) {
+ let maybe_finished = match Request::parse(&head, mem, self.disk.nsectors()) {
Ok(request) => {
if request.rate_limit(&mut self.rate_limiter) {
// Stop processing the queue and return this descriptor chain to the
@@ -297,19 +298,26 @@ impl Block {
}
used_any = true;
- request
- .execute(&mut self.disk, head.index, mem)
- .map(|req| req.num_bytes_to_mem)
+ request.execute(&mut self.disk, head.index, mem)
}
Err(e) => {
error!("Failed to parse available descriptor chain: {:?}", e);
METRICS.block.execute_fails.inc();
- Some(0)
+ Some(FinishedRequest {
+ num_bytes_to_mem: 0,
+ desc_idx: head.index,
+ })
}
};
- if let Some(len) = maybe_len {
- Self::add_used_descriptor(queue, head.index, len, mem, &self.irq_trigger);
+ if let Some(finished) = maybe_finished {
+ Self::add_used_descriptor(
+ queue,
+ head.index,
+ finished.num_bytes_to_mem,
+ mem,
+ &self.irq_trigger,
+ );
}
}
