public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] aio: block exit_aio() until all context requests are completed
       [not found] <1409737544-9392-1-git-send-email-guz.fnst@cn.fujitsu.com>
@ 2014-09-03 14:43 ` Benjamin LaHaise
  2014-09-04  0:47   ` Gu Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin LaHaise @ 2014-09-03 14:43 UTC (permalink / raw)
  To: Gu Zheng; +Cc: linux-aio, linux-kernel

Hi Gu,

On Wed, Sep 03, 2014 at 05:45:44PM +0800, Gu Zheng wrote:
> It seems that exit_aio() also needs to wait for all iocbs to complete (like
> io_destroy), but we missed the wait step in current implemention, so fix
> it in the same way as we did in io_destroy.

I actually already have another version of this patch queued up that 
checks the return value of kill_ioctx().

		-ben

> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
>  fs/aio.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index 97bc62c..3e35b12 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -793,6 +793,8 @@ void exit_aio(struct mm_struct *mm)
>  
>  	for (i = 0; i < table->nr; ++i) {
>  		struct kioctx *ctx = table->table[i];
> +		struct completion requests_done =
> +			COMPLETION_INITIALIZER_ONSTACK(requests_done);
>  
>  		if (!ctx)
>  			continue;
> @@ -804,7 +806,10 @@ void exit_aio(struct mm_struct *mm)
>  		 * that it needs to unmap the area, just set it to 0.
>  		 */
>  		ctx->mmap_size = 0;
> -		kill_ioctx(mm, ctx, NULL);
> +		kill_ioctx(mm, ctx, &requests_done);
> +
> +		/* Wait until all IO for the context are done. */
> +		wait_for_completion(&requests_done);
>  	}
>  
>  	RCU_INIT_POINTER(mm->ioctx_table, NULL);
> -- 
> 1.7.7

-- 
"Thought is the essence of where you are now."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] aio: block exit_aio() until all context requests are completed
  2014-09-03 14:43 ` [PATCH] aio: block exit_aio() until all context requests are completed Benjamin LaHaise
@ 2014-09-04  0:47   ` Gu Zheng
  2014-09-04 20:58     ` Benjamin LaHaise
  0 siblings, 1 reply; 3+ messages in thread
From: Gu Zheng @ 2014-09-04  0:47 UTC (permalink / raw)
  To: Benjamin LaHaise; +Cc: linux-aio, linux-kernel

Hi Ben,
On 09/03/2014 10:43 PM, Benjamin LaHaise wrote:

> Hi Gu,
> 
> On Wed, Sep 03, 2014 at 05:45:44PM +0800, Gu Zheng wrote:
>> It seems that exit_aio() also needs to wait for all iocbs to complete (like
>> io_destroy), but we missed the wait step in current implemention, so fix
>> it in the same way as we did in io_destroy.
> 
> I actually already have another version of this patch queued up that 
> checks the return value of kill_ioctx().

That's good, but I did not find it, have you sent it to the open list?
IMO, there's no need to check the return value of kill_ioctx(), because
context can be marked as DEAD only by io_destroy(), and io_destroy() is
on the block mode. So if we run into the calling of kill_ioctx() in
exit_aio, the context is surely valid.

Thanks,
Gu

> 
> 		-ben
> 
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> ---
>>  fs/aio.c |    7 ++++++-
>>  1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/aio.c b/fs/aio.c
>> index 97bc62c..3e35b12 100644
>> --- a/fs/aio.c
>> +++ b/fs/aio.c
>> @@ -793,6 +793,8 @@ void exit_aio(struct mm_struct *mm)
>>  
>>  	for (i = 0; i < table->nr; ++i) {
>>  		struct kioctx *ctx = table->table[i];
>> +		struct completion requests_done =
>> +			COMPLETION_INITIALIZER_ONSTACK(requests_done);
>>  
>>  		if (!ctx)
>>  			continue;
>> @@ -804,7 +806,10 @@ void exit_aio(struct mm_struct *mm)
>>  		 * that it needs to unmap the area, just set it to 0.
>>  		 */
>>  		ctx->mmap_size = 0;
>> -		kill_ioctx(mm, ctx, NULL);
>> +		kill_ioctx(mm, ctx, &requests_done);
>> +
>> +		/* Wait until all IO for the context are done. */
>> +		wait_for_completion(&requests_done);
>>  	}
>>  
>>  	RCU_INIT_POINTER(mm->ioctx_table, NULL);
>> -- 
>> 1.7.7
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] aio: block exit_aio() until all context requests are completed
  2014-09-04  0:47   ` Gu Zheng
@ 2014-09-04 20:58     ` Benjamin LaHaise
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin LaHaise @ 2014-09-04 20:58 UTC (permalink / raw)
  To: Gu Zheng; +Cc: linux-aio, linux-kernel

On Thu, Sep 04, 2014 at 08:47:19AM +0800, Gu Zheng wrote:
> That's good, but I did not find it, have you sent it to the open list?

Sorry, the aio list wasn't cc'd on that one -- it was on one of the other 
development lists.

> IMO, there's no need to check the return value of kill_ioctx(), because
> context can be marked as DEAD only by io_destroy(), and io_destroy() is
> on the block mode. So if we run into the calling of kill_ioctx() in
> exit_aio, the context is surely valid.

Fair point.  I applied your version.  A pull request has been sent.

		-ben

> Thanks,
> Gu
> 
> > 
> > 		-ben
> > 
> >> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> >> ---
> >>  fs/aio.c |    7 ++++++-
> >>  1 files changed, 6 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/fs/aio.c b/fs/aio.c
> >> index 97bc62c..3e35b12 100644
> >> --- a/fs/aio.c
> >> +++ b/fs/aio.c
> >> @@ -793,6 +793,8 @@ void exit_aio(struct mm_struct *mm)
> >>  
> >>  	for (i = 0; i < table->nr; ++i) {
> >>  		struct kioctx *ctx = table->table[i];
> >> +		struct completion requests_done =
> >> +			COMPLETION_INITIALIZER_ONSTACK(requests_done);
> >>  
> >>  		if (!ctx)
> >>  			continue;
> >> @@ -804,7 +806,10 @@ void exit_aio(struct mm_struct *mm)
> >>  		 * that it needs to unmap the area, just set it to 0.
> >>  		 */
> >>  		ctx->mmap_size = 0;
> >> -		kill_ioctx(mm, ctx, NULL);
> >> +		kill_ioctx(mm, ctx, &requests_done);
> >> +
> >> +		/* Wait until all IO for the context are done. */
> >> +		wait_for_completion(&requests_done);
> >>  	}
> >>  
> >>  	RCU_INIT_POINTER(mm->ioctx_table, NULL);
> >> -- 
> >> 1.7.7
> > 
> 

-- 
"Thought is the essence of where you are now."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-04 20:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1409737544-9392-1-git-send-email-guz.fnst@cn.fujitsu.com>
2014-09-03 14:43 ` [PATCH] aio: block exit_aio() until all context requests are completed Benjamin LaHaise
2014-09-04  0:47   ` Gu Zheng
2014-09-04 20:58     ` Benjamin LaHaise

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox