public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk,
	seiji.aguchi@hds.com, vgoyal@redhat.com, majianpeng@gmail.com
Subject: Re: [PATCH v2 1/2] elevator: Fix a race in elevator switching and md device initialization
Date: Sun, 22 Sep 2013 13:04:17 -0400	[thread overview]
Message-ID: <20130922170417.GF30946@htj.dyndns.org> (raw)
In-Reply-To: <20130830224707.21812.63516.stgit@hds.com>

On Fri, Aug 30, 2013 at 06:47:07PM -0400, Tomoki Sekiyama wrote:
> @@ -739,9 +739,17 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn,
>  
>  	q->sg_reserved_size = INT_MAX;
>  
> +	/* Protect q->elevator from elevator_change */
> +	mutex_lock(&q->sysfs_lock);
> +
>  	/* init elevator */
> -	if (elevator_init(q, NULL))
> +	if (elevator_init(q, NULL)) {
> +		mutex_unlock(&q->sysfs_lock);
>  		return NULL;
> +	}
> +
> +	mutex_unlock(&q->sysfs_lock);
> +
>  	return q;
>  }
>  EXPORT_SYMBOL(blk_init_allocated_queue);
> diff --git a/block/elevator.c b/block/elevator.c
> index 668394d..02d4390 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -186,6 +186,12 @@ int elevator_init(struct request_queue *q, char *name)
>  	struct elevator_type *e = NULL;
>  	int err;
>  
> +	/*
> +	 * q->sysfs_lock must be held to provide mutual exclusion between
> +	 * elevator_switch() and here.
> +	 */
> +	lockdep_assert_held(&q->sysfs_lock);
> +
>  	if (unlikely(q->elevator))
>  		return 0;

Hmm... why aren't we just changing elevator_init() to grab sysfs_lock
where necessary?  It'd be more consistent with elevator_exit() that
way.

Thanks.

-- 
tejun

  parent reply	other threads:[~2013-09-22 17:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 22:47 [PATCH v2 1/2] elevator: Fix a race in elevator switching and md device initialization Tomoki Sekiyama
2013-08-30 22:47 ` [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change() Tomoki Sekiyama
2013-09-22 17:00   ` Tejun Heo
2013-09-06 15:01 ` [PATCH v2 1/2] elevator: Fix a race in elevator switching and md device initialization Tomoki Sekiyama
2013-09-22 17:04 ` Tejun Heo [this message]
2013-09-23 20:11   ` Tomoki Sekiyama
2013-09-23 20:14     ` Tejun Heo
2013-10-09 22:36       ` Tomoki Sekiyama

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=20130922170417.GF30946@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=majianpeng@gmail.com \
    --cc=seiji.aguchi@hds.com \
    --cc=tomoki.sekiyama@hds.com \
    --cc=vgoyal@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox