[1/4] elevator: print none at first in elv_iosched_show even if the queue has a scheduler

Message ID b613ad2a94ff552937672d70a5f2e43068e42bb2.1669391142.git.nickyc975@zju.edu.cn
State New
Headers
Series random improvements and cleanups for elevator.c |

Commit Message

Jinlong Chen Nov. 25, 2022, 3:53 p.m. UTC
  This makes the printing order of the io schedulers consistent, and removes
a redundant q->elevator check.

Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
---
 block/elevator.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
  

Comments

Christoph Hellwig Nov. 29, 2022, 8:30 a.m. UTC | #1
On Fri, Nov 25, 2022 at 11:53:11PM +0800, Jinlong Chen wrote:
> This makes the printing order of the io schedulers consistent, and removes
> a redundant q->elevator check.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
  

Patch

diff --git a/block/elevator.c b/block/elevator.c
index 599413620558..308bee253564 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -767,10 +767,12 @@  ssize_t elv_iosched_show(struct request_queue *q, char *name)
 	if (!elv_support_iosched(q))
 		return sprintf(name, "none\n");
 
-	if (!q->elevator)
+	if (!q->elevator) {
 		len += sprintf(name+len, "[none] ");
-	else
+	} else {
+		len += sprintf(name+len, "none ");
 		cur = eq->type;
+	}
 
 	spin_lock(&elv_list_lock);
 	list_for_each_entry(e, &elv_list, list) {
@@ -783,9 +785,6 @@  ssize_t elv_iosched_show(struct request_queue *q, char *name)
 	}
 	spin_unlock(&elv_list_lock);
 
-	if (q->elevator)
-		len += sprintf(name+len, "none");
-
 	len += sprintf(len+name, "\n");
 	return len;
 }