[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5abfd81ae73b4e86ff260475b28a218e78eaad4a.1668772991.git.nickyc975@zju.edu.cn>
Date: Fri, 18 Nov 2022 20:09:53 +0800
From: Jinlong Chen <nickyc975@....edu.cn>
To: axboe@...nel.dk
Cc: hch@....de, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, nickyc975@....edu.cn
Subject: [RFC PATCH 1/2] elevator: add a helper for applying scheduler to request_queue
Prepare for supporting fallback in elevator_switch.
Signed-off-by: Jinlong Chen <nickyc975@....edu.cn>
---
block/elevator.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index a5bdc3b1e7e5..517857a9a68f 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -649,6 +649,21 @@ void elevator_init_mq(struct request_queue *q)
elevator_put(e);
}
+static int __elevator_apply(struct request_queue *q, struct elevator_type *e)
+{
+ int ret;
+
+ ret = blk_mq_init_sched(q, e);
+ if (ret)
+ return ret;
+
+ ret = elv_register_queue(q, true);
+ if (ret)
+ elevator_exit(q);
+
+ return ret;
+}
+
/*
* switch to new_e io scheduler. be careful not to introduce deadlocks -
* we don't free the old io scheduler, before we have allocated what we
@@ -669,15 +684,10 @@ int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
elevator_exit(q);
}
- ret = blk_mq_init_sched(q, new_e);
+ ret = __elevator_apply(q, new_e);
if (ret)
goto out_unfreeze;
- ret = elv_register_queue(q, true);
- if (ret) {
- elevator_exit(q);
- goto out_unfreeze;
- }
blk_add_trace_msg(q, "elv switch: %s", new_e->elevator_name);
out_unfreeze:
--
2.31.1
Powered by blists - more mailing lists