@@ -404,7 +404,6 @@ impl VirtioBlock {
404
404
break ;
405
405
}
406
406
407
- used_any = true ;
408
407
request. process ( & mut self . disk , head. index , mem, & self . metrics )
409
408
}
410
409
Err ( err) => {
@@ -425,6 +424,7 @@ impl VirtioBlock {
425
424
break ;
426
425
}
427
426
ProcessingResult :: Executed ( finished) => {
427
+ used_any = true ;
428
428
queue
429
429
. add_used ( head. index , finished. num_bytes_to_mem )
430
430
. unwrap_or_else ( |err| {
@@ -438,7 +438,7 @@ impl VirtioBlock {
438
438
}
439
439
queue. advance_used_ring_idx ( ) ;
440
440
441
- if queue. prepare_kick ( ) {
441
+ if used_any && queue. prepare_kick ( ) {
442
442
self . irq_trigger
443
443
. trigger_irq ( IrqType :: Vring )
444
444
. unwrap_or_else ( |_| {
@@ -1574,14 +1574,14 @@ mod tests {
1574
1574
1575
1575
// Run scenario that doesn't trigger FullSq BlockError: Add sq_size flush requests.
1576
1576
add_flush_requests_batch ( & mut block, & vq, IO_URING_NUM_ENTRIES ) ;
1577
- simulate_queue_event ( & mut block, Some ( true ) ) ;
1577
+ simulate_queue_event ( & mut block, Some ( false ) ) ;
1578
1578
assert ! ( !block. is_io_engine_throttled) ;
1579
1579
simulate_async_completion_event ( & mut block, true ) ;
1580
1580
check_flush_requests_batch ( IO_URING_NUM_ENTRIES , & vq) ;
1581
1581
1582
1582
// Run scenario that triggers FullSqError : Add sq_size + 10 flush requests.
1583
1583
add_flush_requests_batch ( & mut block, & vq, IO_URING_NUM_ENTRIES + 10 ) ;
1584
- simulate_queue_event ( & mut block, Some ( true ) ) ;
1584
+ simulate_queue_event ( & mut block, Some ( false ) ) ;
1585
1585
assert ! ( block. is_io_engine_throttled) ;
1586
1586
// When the async_completion_event is triggered:
1587
1587
// 1. sq_size requests should be processed processed.
@@ -1608,16 +1608,16 @@ mod tests {
1608
1608
// Run scenario that triggers FullCqError. Push 2 * IO_URING_NUM_ENTRIES and wait for
1609
1609
// completion. Then try to push another entry.
1610
1610
add_flush_requests_batch ( & mut block, & vq, IO_URING_NUM_ENTRIES ) ;
1611
- simulate_queue_event ( & mut block, Some ( true ) ) ;
1611
+ simulate_queue_event ( & mut block, Some ( false ) ) ;
1612
1612
assert ! ( !block. is_io_engine_throttled) ;
1613
1613
thread:: sleep ( Duration :: from_millis ( 150 ) ) ;
1614
1614
add_flush_requests_batch ( & mut block, & vq, IO_URING_NUM_ENTRIES ) ;
1615
- simulate_queue_event ( & mut block, Some ( true ) ) ;
1615
+ simulate_queue_event ( & mut block, Some ( false ) ) ;
1616
1616
assert ! ( !block. is_io_engine_throttled) ;
1617
1617
thread:: sleep ( Duration :: from_millis ( 150 ) ) ;
1618
1618
1619
1619
add_flush_requests_batch ( & mut block, & vq, 1 ) ;
1620
- simulate_queue_event ( & mut block, Some ( true ) ) ;
1620
+ simulate_queue_event ( & mut block, Some ( false ) ) ;
1621
1621
assert ! ( block. is_io_engine_throttled) ;
1622
1622
simulate_async_completion_event ( & mut block, true ) ;
1623
1623
assert ! ( !block. is_io_engine_throttled) ;
@@ -1673,15 +1673,13 @@ mod tests {
1673
1673
vq. dtable [ 1 ] . len . set ( 512 ) ;
1674
1674
mem. write_obj :: < u64 > ( 123_456_789 , data_addr) . unwrap ( ) ;
1675
1675
1676
- // This will fail because of bandwidth rate limiting.
1677
- // The irq is still triggered because notification suppression
1678
- // is not enabled.
1676
+ // Following write procedure should fail because of bandwidth rate limiting.
1679
1677
{
1680
1678
// Trigger the attempt to write.
1681
1679
check_metric_after_block ! (
1682
1680
& block. metrics. rate_limiter_throttled_events,
1683
1681
1 ,
1684
- simulate_queue_event( & mut block, Some ( true ) )
1682
+ simulate_queue_event( & mut block, Some ( false ) )
1685
1683
) ;
1686
1684
1687
1685
// Assert that limiter is blocked.
@@ -1743,15 +1741,13 @@ mod tests {
1743
1741
vq. dtable [ 1 ] . len . set ( 512 ) ;
1744
1742
mem. write_obj :: < u64 > ( 123_456_789 , data_addr) . unwrap ( ) ;
1745
1743
1746
- // This will fail because of ops rate limiting.
1747
- // The irq is still triggered because notification suppression
1748
- // is not enabled.
1744
+ // Following write procedure should fail because of ops rate limiting.
1749
1745
{
1750
1746
// Trigger the attempt to write.
1751
1747
check_metric_after_block ! (
1752
1748
& block. metrics. rate_limiter_throttled_events,
1753
1749
1 ,
1754
- simulate_queue_event( & mut block, Some ( true ) )
1750
+ simulate_queue_event( & mut block, Some ( false ) )
1755
1751
) ;
1756
1752
1757
1753
// Assert that limiter is blocked.
@@ -1760,8 +1756,7 @@ mod tests {
1760
1756
assert_eq ! ( vq. used. idx. get( ) , 0 ) ;
1761
1757
}
1762
1758
1763
- // Do a second write that still fails but this time on the fast path
1764
- // which does not call `process_queue`, so no irq notifications.
1759
+ // Do a second write that still fails but this time on the fast path.
1765
1760
{
1766
1761
// Trigger the attempt to write.
1767
1762
check_metric_after_block ! (
0 commit comments