Commit d7790b92 authored by Shlomo Pongratz's avatar Shlomo Pongratz Committed by Jens Axboe

block/null_blk: Fix completion processing from LIFO to FIFO

The completion queue is implemented using lockless list.

The llist_add is adds the events to the list head which is a push operation.
The processing of the completion elements is done by disconnecting all the
pushed elements and iterating over the disconnected list. The problem is
that the processing is done in reverse order w.r.t order of the insertion
i.e. LIFO processing. By reversing the disconnected list which is done in
linear time the desired FIFO processing is achieved.
Signed-off-by: default avatarShlomo Pongratz <shlomop@mellanox.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 5cb8850c
...@@ -195,6 +195,7 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer) ...@@ -195,6 +195,7 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer)
cq = &per_cpu(completion_queues, smp_processor_id()); cq = &per_cpu(completion_queues, smp_processor_id());
while ((entry = llist_del_all(&cq->list)) != NULL) { while ((entry = llist_del_all(&cq->list)) != NULL) {
entry = llist_reverse_order(entry);
do { do {
cmd = container_of(entry, struct nullb_cmd, ll_list); cmd = container_of(entry, struct nullb_cmd, ll_list);
end_cmd(cmd); end_cmd(cmd);
...@@ -235,6 +236,7 @@ static void null_ipi_cmd_end_io(void *data) ...@@ -235,6 +236,7 @@ static void null_ipi_cmd_end_io(void *data)
cq = &per_cpu(completion_queues, smp_processor_id()); cq = &per_cpu(completion_queues, smp_processor_id());
entry = llist_del_all(&cq->list); entry = llist_del_all(&cq->list);
entry = llist_reverse_order(entry);
while (entry) { while (entry) {
next = entry->next; next = entry->next;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment