From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: Benjamin LaHaise <bcrl@kvack.org>
Cc: Dave Jones <davej@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>,
jmoyer@redhat.com, kosaki.motohiro@jp.fujitsu.com,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
tangchen <tangchen@cn.fujitsu.com>,
miaox@cn.fujitsu.com, linux-aio@kvack.org,
fsdevel <linux-fsdevel@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/2] aio: fix the confliction of read events and migrating ring page
Date: Fri, 21 Mar 2014 09:56:36 +0800 [thread overview]
Message-ID: <532B9C54.80705@cn.fujitsu.com> (raw)
In-Reply-To: <20140320163004.GE28970@kvack.org>
Hi Ben,
On 03/21/2014 12:30 AM, Benjamin LaHaise wrote:
> On Thu, Mar 20, 2014 at 10:32:07AM -0400, Dave Jones wrote:
>> On Thu, Mar 20, 2014 at 01:46:25PM +0800, Gu Zheng wrote:
>>
>> > diff --git a/fs/aio.c b/fs/aio.c
>> > index 88ad40c..e353085 100644
>> > --- a/fs/aio.c
>> > +++ b/fs/aio.c
>> > @@ -319,6 +319,9 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
>> > ctx->ring_pages[old->index] = new;
>> > spin_unlock_irqrestore(&ctx->completion_lock, flags);
>> >
>> > + /* Ensure read event is completed before putting old page */
>> > + mutex_lock(&ctx->ring_lock);
>> > + mutex_unlock(&ctx->ring_lock);
>> > put_page(old);
>> >
>> > return rc;
>>
>> This looks a bit weird. Would using a completion work here ?
>
> Nope. This is actually the most elegant fix I've seen for this approach,
> as everything else has relied on adding additional spin locks (which only
> end up being needed in the migration case) around access to the ring_pages
> on the reader side. That said, this patch is not a complete solution to
> the problem, as the update of the ring's head pointer could still get lost
> with this patch. I think the right thing is just taking the ring_lock
> mutex over the entire page migration operation. That should be safe, as
> nowhere else is the ring_lock mutex nested with any other locks.
This one is based on linux-next which has merged the following patch:
commit 692c9b8c5ee8d263bb8348171f0bebd3d84eb2c1
Author: Tang Chen <tangchen@cn.fujitsu.com>
Date: Mon Mar 10 16:15:33 2014 +0800
aio, memory-hotplug: Fix confliction when migrating and accessing ring pages.
With this patch, the update of the ring's head pointer is safe because it is protected
by completion_lock, so we do not need to enlarge the ring_lock protection region.
And on the other side, if we take the ring_lock over the entire page migration
operation, reading events will be affected if the page migration is going.
Thanks,
Gu
>
> -ben
>
>> Dave
>
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
next prev parent reply other threads:[~2014-03-21 1:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-20 5:46 [PATCH 2/2] aio: fix the confliction of read events and migrating ring page Gu Zheng
2014-03-20 14:32 ` Dave Jones
2014-03-20 16:30 ` Benjamin LaHaise
2014-03-21 1:56 ` Gu Zheng [this message]
2014-03-21 17:35 ` Benjamin LaHaise
2014-03-21 18:35 ` [PATCH] aio: ensure access to ctx->ring_pages is correctly serialised Benjamin LaHaise
2014-03-24 10:56 ` Gu Zheng
2014-03-24 10:59 ` [V2 PATCH 1/2] aio: clean up aio_migratepage() and related code much Gu Zheng
2014-03-24 13:20 ` Benjamin LaHaise
2014-03-25 10:11 ` Gu Zheng
2014-03-24 10:59 ` [V2 PATCH 2/2] aio: fix the confliction of aio read events and aio migrate page Gu Zheng
2014-03-24 18:22 ` [PATCH] aio: ensure access to ctx->ring_pages is correctly serialised Sasha Levin
2014-03-24 19:07 ` Benjamin LaHaise
2014-03-25 17:47 ` Sasha Levin
2014-03-25 18:57 ` Benjamin LaHaise
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=532B9C54.80705@cn.fujitsu.com \
--to=guz.fnst@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=bcrl@kvack.org \
--cc=davej@redhat.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=jmoyer@redhat.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miaox@cn.fujitsu.com \
--cc=tangchen@cn.fujitsu.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).