From: Ryan Ding <ryan.ding@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 1/4] ocfs2: fix ip_unaligned_aio deadlock with dio work queue
Date: Tue, 24 Nov 2015 11:24:19 +0800 [thread overview]
Message-ID: <5653D863.9080308@oracle.com> (raw)
In-Reply-To: <20151123162640.fa62db07934ad869b00e5435@linux-foundation.org>
Hi Andrew,
On 11/24/2015 08:26 AM, Andrew Morton wrote:
> On Fri, 20 Nov 2015 16:23:16 +0800 Ryan Ding <ryan.ding@oracle.com> wrote:
>
>> In the current implementation of unaligned aio+dio, lock order behave as follow:
>>
>> in user process context:
>> -> call io_submit()
>> -> get i_mutex
>> <== window1
>> -> get ip_unaligned_aio
>> -> submit direct io to block device
>> -> release i_mutex
>> -> io_submit() return
>>
>> in dio work queue context(the work queue is created in __blockdev_direct_IO):
>> -> release ip_unaligned_aio
>> <== window2
>> -> get i_mutex
>> -> clear unwritten flag & change i_size
>> -> release i_mutex
>>
>> There is a limitation to the thread number of dio work queue. 256 at default.
>> If all 256 thread are in the above 'window2' stage, and there is a user process
>> in the 'window1' stage, the system will became deadlock. Since the user process
>> hold i_mutex to wait ip_unaligned_aio lock, while there is a direct bio hold
>> ip_unaligned_aio mutex who is waiting for a dio work queue thread to be
>> schedule. But all the dio work queue thread is waiting for i_mutex lock in
>> 'window2'.
>>
>> This case only happened in a test which send a large number(more than 256) of
>> aio at one io_submit() call.
>>
>> My design is to remove ip_unaligned_aio lock. Change it to a sync io instead.
>> Just like ip_unaligned_aio lock, serialize the unaligned aio dio.
> So this patch series is a bunch of fixes against your previous patch series:
>
> ocfs2-add-ocfs2_write_type_t-type-to-identify-the-caller-of-write.patch
> ocfs2-use-c_new-to-indicate-newly-allocated-extents.patch
> ocfs2-test-target-page-before-change-it.patch
> ocfs2-do-not-change-i_size-in-write_end-for-direct-io.patch
> ocfs2-return-the-physical-address-in-ocfs2_write_cluster.patch
> ocfs2-record-unwritten-extents-when-populate-write-desc.patch
> ocfs2-fix-sparse-file-data-ordering-issue-in-direct-io.patch
> ocfs2-code-clean-up-for-direct-io.patch
>
> correct?
Yes, you are right. :)
> Those patches are languishing a bit, awaiting review/ack. I'll send
> everything out for a round of review soon...
Thanks a lot!
Ryan
next prev parent reply other threads:[~2015-11-24 3:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 8:23 [Ocfs2-devel] [PATCH 1/4] ocfs2: fix ip_unaligned_aio deadlock with dio work queue Ryan Ding
2015-11-20 8:23 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: take ip_alloc_sem in ocfs2_dio_get_block & ocfs2_dio_end_io_write Ryan Ding
2015-12-01 6:36 ` Junxiao Bi
2015-11-20 8:23 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: fix disk file size and memory file size mismatch Ryan Ding
2015-12-01 6:44 ` Junxiao Bi
2015-11-20 8:23 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: Fix a deadlock issue in ocfs2_dio_end_io_write() Ryan Ding
2015-12-01 6:53 ` Junxiao Bi
2015-11-24 0:26 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix ip_unaligned_aio deadlock with dio work queue Andrew Morton
2015-11-24 3:24 ` Ryan Ding [this message]
2015-12-01 4:42 ` Junxiao Bi
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=5653D863.9080308@oracle.com \
--to=ryan.ding@oracle.com \
--cc=ocfs2-devel@oss.oracle.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