All of lore.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 2/3] elevator: allow name aliases
Date: Wed, 25 Oct 2017 11:32:06 -0700	[thread overview]
Message-ID: <20171025183206.GB9160@vader> (raw)
In-Reply-To: <1508954687-3204-3-git-send-email-axboe@kernel.dk>

On Wed, Oct 25, 2017 at 12:04:46PM -0600, Jens Axboe wrote:
> Since we now lookup elevator types with the appropriate multiqueue
> capability, allow schedulers to register with an alias alongside
> the real name. This is in preparation for allowing 'mq-deadline'
> to register an alias of 'deadline' as well.
> 
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
>  block/elevator.c         | 22 ++++++++++++++++------
>  include/linux/elevator.h |  1 +
>  2 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/block/elevator.c b/block/elevator.c
> index b70e69f795db..dc0432e12ecf 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -83,6 +83,16 @@ bool elv_bio_merge_ok(struct request *rq, struct bio *bio)
>  }
>  EXPORT_SYMBOL(elv_bio_merge_ok);
>  
> +static bool elevator_match(const struct elevator_type *e, const char *name)
> +{
> +	if (!strcmp(e->elevator_name, name))
> +		return true;
> +	if (e->elevator_alias && !strcmp(e->elevator_alias, name))
> +		return true;
> +
> +	return false;
> +}
> +
>  /*
>   * Return scheduler with name 'name' and with matching 'mq capability
>   */
> @@ -91,7 +101,7 @@ static struct elevator_type *elevator_find(const char *name, bool mq)
>  	struct elevator_type *e;
>  
>  	list_for_each_entry(e, &elv_list, list) {
> -		if (!strcmp(e->elevator_name, name) && !(mq ^ e->uses_mq))
> +		if (elevator_match(e, name) && !(mq ^ e->uses_mq))
>  			return e;
>  	}
>  
> @@ -922,9 +932,9 @@ int elv_register(struct elevator_type *e)
>  	spin_unlock(&elv_list_lock);
>  
>  	/* print pretty message */
> -	if (!strcmp(e->elevator_name, chosen_elevator) ||
> +	if (elevator_match(e, chosen_elevator) ||
>  			(!*chosen_elevator &&
> -			 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
> +			 elevator_match(e, CONFIG_DEFAULT_IOSCHED)))
>  				def = " (default)";
>  
>  	printk(KERN_INFO "io scheduler %s registered%s\n", e->elevator_name,
> @@ -1077,8 +1087,7 @@ static int __elevator_change(struct request_queue *q, const char *name)
>  	if (!e)
>  		return -EINVAL;
>  
> -	if (q->elevator &&
> -	    !strcmp(elevator_name, q->elevator->type->elevator_name)) {
> +	if (q->elevator && elevator_match(q->elevator->type, elevator_name)) {
>  		elevator_put(e);
>  		return 0;
>  	}
> @@ -1126,7 +1135,8 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name)
>  
>  	spin_lock(&elv_list_lock);
>  	list_for_each_entry(__e, &elv_list, list) {
> -		if (elv && !strcmp(elv->elevator_name, __e->elevator_name)) {
> +		if (elv && elevator_match(elv, __e->elevator_name) &&
> +		    !(__e->uses_mq ^ (q->mq_ops != NULL))) {

Same thing here, (__e->uses_mq == (q->mq_ops != NULL)). Still confusing
but less so.

Otherwise Reviewed-by: Omar Sandoval <osandov@fb.com>

  reply	other threads:[~2017-10-25 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 18:04 [PATCH 0/3] mq vs non-mq scheduler tweaks Jens Axboe
2017-10-25 18:04 ` [PATCH 1/3] elevator: lookup mq vs non-mq elevators Jens Axboe
2017-10-25 18:27   ` Omar Sandoval
2017-10-25 18:31     ` Jens Axboe
2017-10-25 18:04 ` [PATCH 2/3] elevator: allow name aliases Jens Axboe
2017-10-25 18:32   ` Omar Sandoval [this message]
2017-10-25 18:32     ` Jens Axboe
2017-10-25 18:04 ` [PATCH 3/3] mq-deadline: add 'deadline' as a name alias Jens Axboe
2017-10-25 18:34   ` Omar Sandoval
2017-10-25 18:36     ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171025183206.GB9160@vader \
    --to=osandov@osandov.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.