From: Jens Axboe <axboe@kernel.dk>
To: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: vgoyal@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [patch]cfq-iosched: fix cfq_cic_link() race confition
Date: Fri, 02 Dec 2011 10:05:15 +0100 [thread overview]
Message-ID: <4ED894CB.80005@kernel.dk> (raw)
In-Reply-To: <4ED886DC.1000608@jp.fujitsu.com>
On 2011-12-02 09:05, Yasuaki Ishimatsu wrote:
> cfq_cic_link() has race condition. When some processes which shared ioc
> issue I/O to same block device simultaneously, cfq_cic_link() returns -EEXIST
> sometimes. The race condition might stop I/O by following steps:
>
> step 1: Process A: Issue an I/O to /dev/sda
> step 2: Process A: Get an ioc (iocA here) in get_io_context() which does not
> linked with a cic for the device
> step 3: Process A: Get a new cic for the device (cicA here) in
> cfq_alloc_io_context()
>
> step 4: Process B: Issue an I/O to /dev/sda
> step 5: Process B: Get iocA in get_io_context() since process A and B share the
> same ioc
> step 6: Process B: Get a new cic for the device (cicB here) in
> cfq_alloc_io_context() since iocA has not been linked with a
> cic for the device yet
>
> step 7: Process A: Link cicA to iocA in cfq_cic_link()
> step 8: Process A: Dispatch I/O to driver and finish it
>
> step 9: Process B: Try to link cicB to iocA in cfq_cic_link()
> But it fails with showing "cfq: cic link failed!" kernel
> message, since iocA has already linked with cicA at step 7.
> step 10: Process B: Wait for finishig I/O in get_request_wait()
> The function does not wake up, when there is no I/O to the
> device.
>
> When cfq_cic_link() returns -EEXIST, it means ioc has already linked with cic.
> So when cfq_cic_link() return -EEXIST, retry cfq_cic_lookup().
Thanks, your analysis and fix looks correct. Good work! Applied.
--
Jens Axboe
next prev parent reply other threads:[~2011-12-02 9:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-02 8:05 [patch]cfq-iosched: fix cfq_cic_link() race confition Yasuaki Ishimatsu
2011-12-02 9:05 ` Jens Axboe [this message]
2011-12-02 13:49 ` Vivek Goyal
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=4ED894CB.80005@kernel.dk \
--to=axboe@kernel.dk \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--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