1
1
#include <linux/blkdev.h>
2
2
#include <linux/blk-mq.h>
3
+
4
+ struct elevator_queue ;
5
+ struct request ;
6
+
3
7
#include <linux/elevator.h>
4
8
#include <linux/spinlock.h>
5
9
#include <linux/version.h>
@@ -367,7 +371,7 @@ static struct request* ioem_dequeue(struct ioem_data *data)
367
371
goto out ;
368
372
}
369
373
370
- while (true ) {
374
+ while (! RB_EMPTY_ROOT ( & data -> root . rb_root ) ) {
371
375
rq = ioem_peek_request (data );
372
376
if (time_to_send == 0 ) {
373
377
time_to_send = ioem_priv (rq )-> time_to_send ;
@@ -386,6 +390,8 @@ static struct request* ioem_dequeue(struct ioem_data *data)
386
390
// check the IRL to decide whether the quota has exceeded
387
391
ioem_erase_head (data , rq );
388
392
393
+ // if this request should be considered by irl, try to dispatch through irl.
394
+ // if not, return the request directly.
389
395
if (ioem_priv (rq )-> ioem_limit_should_affect ) {
390
396
irl_ret = irl_dispatch (data , rq );
391
397
if (irl_ret .dispatch > 0 ) {
@@ -397,9 +403,12 @@ static struct request* ioem_dequeue(struct ioem_data *data)
397
403
ioem_priv (rq )-> time_to_send = irl_ret .time_to_send ;
398
404
list_add_tail (& rq -> queuelist , & data -> list );
399
405
ioem_priv (rq )-> in_list = true;
406
+ time_to_send = min (time_to_send , irl_ret .time_to_send );
400
407
401
408
rq = NULL ;
402
409
}
410
+ } else {
411
+ goto out ;
403
412
}
404
413
}
405
414
@@ -547,7 +556,7 @@ static void ioem_mq_insert_requests(struct blk_mq_hw_ctx * hctx, struct list_hea
547
556
ioem_data_sync_with_injections (id );
548
557
549
558
list_for_each_entry_safe (rq , next , list , queuelist ) {
550
- list_del (& rq -> queuelist );
559
+ list_del_init (& rq -> queuelist );
551
560
552
561
if (at_head ) {
553
562
ioem_priv (rq )-> time_to_send = 0 ;
@@ -556,6 +565,8 @@ static void ioem_mq_insert_requests(struct blk_mq_hw_ctx * hctx, struct list_hea
556
565
ioem_priv (rq )-> time_to_send = ktime_get_ns ();
557
566
ioem_priv (rq )-> ioem_limit_should_affect = ioem_limit_should_affect (id , rq );
558
567
}
568
+ ioem_priv (rq )-> in_list = false;
569
+ ioem_priv (rq )-> in_rbtree = false;
559
570
560
571
ioem_error_injection (rq );
561
572
ioem_enqueue (id , rq );
0 commit comments