[2/4] elevator: printk a warning if switching to a new io scheduler fails

Message ID d51ed0fb457db7a4f9cbb0dbce36d534e22be457.1669126766.git.nickyc975@zju.edu.cn
State New
Headers
Series random improvments and cleanups for elevator.c |

Commit Message

Jinlong Chen Nov. 22, 2022, 2:21 p.m. UTC
  printk a warning to indicate that the io scheduler has been set to none
if switching to a new io scheduler fails.

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

Comments

Jinlong Chen Nov. 22, 2022, 2:55 p.m. UTC | #1
> 
> printk a warning to indicate that the io scheduler has been set to none
> if switching to a new io scheduler fails.
> 
> Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
> ---
>  block/elevator.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/block/elevator.c b/block/elevator.c
> index 01aa9f38f22e..1fa45717b1d6 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -683,6 +683,12 @@ int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
>  out_unfreeze:
>  	blk_mq_unquiesce_queue(q);
>  	blk_mq_unfreeze_queue(q);
> +
> +	if (ret) {
> +		pr_warn("elv: switch to \"%s\" failed, falling back to \"none\"\n",
> +			new_e->elevator_name);
> +	}
> +
>  	return ret;
>  }
>  

Hi, Jens!

This patch is suggested by Christoph, but I forgot to add the Suggested-by
tag. Would you please add "Suggested-by: Christoph Hellwig <hch@lst.de>"
if you apply the patch?

Thanks!
Jinlong Chen
  
Christoph Hellwig Nov. 23, 2022, 7:37 a.m. UTC | #2
Looks good:

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

Patch

diff --git a/block/elevator.c b/block/elevator.c
index 01aa9f38f22e..1fa45717b1d6 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -683,6 +683,12 @@  int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
 out_unfreeze:
 	blk_mq_unquiesce_queue(q);
 	blk_mq_unfreeze_queue(q);
+
+	if (ret) {
+		pr_warn("elv: switch to \"%s\" failed, falling back to \"none\"\n",
+			new_e->elevator_name);
+	}
+
 	return ret;
 }