Skip to content

Commit 176d45e

Browse files
committed
fix compile warning and handle packet without ioem_limit
Signed-off-by: YangKeao <[email protected]>
1 parent ab5c534 commit 176d45e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

driver/ioem.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <linux/blkdev.h>
22
#include <linux/blk-mq.h>
3+
4+
struct elevator_queue;
5+
struct request;
6+
37
#include <linux/elevator.h>
48
#include <linux/spinlock.h>
59
#include <linux/version.h>
@@ -367,7 +371,7 @@ static struct request* ioem_dequeue(struct ioem_data *data)
367371
goto out;
368372
}
369373

370-
while (true) {
374+
while (!RB_EMPTY_ROOT(&data->root.rb_root)) {
371375
rq = ioem_peek_request(data);
372376
if (time_to_send == 0) {
373377
time_to_send = ioem_priv(rq)->time_to_send;
@@ -386,6 +390,8 @@ static struct request* ioem_dequeue(struct ioem_data *data)
386390
// check the IRL to decide whether the quota has exceeded
387391
ioem_erase_head(data, rq);
388392

393+
// if this request should be considered by irl, try to dispatch through irl.
394+
// if not, return the request directly.
389395
if (ioem_priv(rq)->ioem_limit_should_affect) {
390396
irl_ret = irl_dispatch(data, rq);
391397
if (irl_ret.dispatch > 0) {
@@ -397,9 +403,12 @@ static struct request* ioem_dequeue(struct ioem_data *data)
397403
ioem_priv(rq)->time_to_send = irl_ret.time_to_send;
398404
list_add_tail(&rq->queuelist, &data->list);
399405
ioem_priv(rq)->in_list = true;
406+
time_to_send = min(time_to_send, irl_ret.time_to_send);
400407

401408
rq = NULL;
402409
}
410+
} else {
411+
goto out;
403412
}
404413
}
405414

@@ -547,7 +556,7 @@ static void ioem_mq_insert_requests(struct blk_mq_hw_ctx * hctx, struct list_hea
547556
ioem_data_sync_with_injections(id);
548557

549558
list_for_each_entry_safe(rq, next, list, queuelist) {
550-
list_del(&rq->queuelist);
559+
list_del_init(&rq->queuelist);
551560

552561
if (at_head) {
553562
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
556565
ioem_priv(rq)->time_to_send = ktime_get_ns();
557566
ioem_priv(rq)->ioem_limit_should_affect = ioem_limit_should_affect(id, rq);
558567
}
568+
ioem_priv(rq)->in_list = false;
569+
ioem_priv(rq)->in_rbtree = false;
559570

560571
ioem_error_injection(rq);
561572
ioem_enqueue(id, rq);

driver/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
#include <linux/delay.h>
2222
#include <linux/fdtable.h>
23+
24+
struct elevator_queue;
25+
struct request;
26+
2327
#include <linux/elevator.h>
2428

2529
#include "config.h"

0 commit comments

Comments
 (0)