From: Jens Axboe <axboe@kernel.dk>
To: majianpeng <majianpeng@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V1] elevator: Fix a race about elevator switching.
Date: Wed, 3 Jul 2013 13:25:44 +0200 [thread overview]
Message-ID: <20130703112544.GG6694@kernel.dk> (raw)
In-Reply-To: <201307011851511379161@gmail.com>
On Mon, Jul 01 2013, majianpeng wrote:
> Thare's a race between elevator switching and normal io operation.
> Because the allocation of struct elevator_queue and struct elevator_data
> don't in a atomic operation.So there are have chance to use NULL
> ->elevator_data.
> For example:
> Thread A: Thread B
> blk_queu_bio elevator_switch
> spin_lock_irq(q->queue_block) elevator_alloc
> elv_merge elevator_init_fn
>
> Because call elevator_alloc, it can't hold queue_lock and the
> ->elevator_data is NULL.So at the same time, threadA call elv_merge and
> nedd some info of elevator_data.So the crash happened.
>
> Move the elevator_alloc into func elevator_init_fn, it make the
> operations in a atomic operation.
>
> Using the follow method can easy reproduce this bug
> 1:dd if=/dev/sdb of=/dev/null
> 2:while true;do echo noop > scheduler;echo deadline > scheduler;done
>
> The test method also use this method.
Applied, thanks.
--
Jens Axboe
prev parent reply other threads:[~2013-07-03 11:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 10:52 [PATCH V1] elevator: Fix a race about elevator switching majianpeng
2013-07-03 11:25 ` Jens Axboe [this message]
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=20130703112544.GG6694@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=majianpeng@gmail.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 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.