public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>,
	io-uring <[email protected]>
Subject: Re: [PATCH] io_uring: cancel all requests on task exit
Date: Sun, 17 Jan 2021 07:53:24 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 1/17/21 3:52 AM, Pavel Begunkov wrote:
> On 17/01/2021 04:04, Jens Axboe wrote:
>> We used to have task exit tied to canceling files_struct ownership, but we
>> really should just simplify this and cancel any request that the task has
>> pending when it exits. Instead of handling files ownership specially, we
>> do the same regardless of request type.
>>
>> This can be further simplified in the next major kernel release, unifying
>> how we cancel across exec and exit.
> 
> Looks good in general. See a comment below, but otherwise
> Reviewed-by: Pavel Begunkov <[email protected]>
> 
> btw, I wonder if we can incite syzbot to try to break it.
> 
>>
>> Cc: [email protected] # 5.9+
>> Signed-off-by: Jens Axboe <[email protected]>
>>
>> ---
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index 383ff6ed3734..1190296fc95f 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -9029,7 +9029,7 @@ static void io_uring_remove_task_files(struct io_uring_task *tctx)
>>  		io_uring_del_task_file(file);
>>  }
>>  
>> -void __io_uring_files_cancel(struct files_struct *files)
>> +static void __io_uring_files_cancel(void)
>>  {
>>  	struct io_uring_task *tctx = current->io_uring;
>>  	struct file *file;
>> @@ -9038,11 +9038,10 @@ void __io_uring_files_cancel(struct files_struct *files)
>>  	/* make sure overflow events are dropped */
>>  	atomic_inc(&tctx->in_idle);
>>  	xa_for_each(&tctx->xa, index, file)
>> -		io_uring_cancel_task_requests(file->private_data, files);
>> +		io_uring_cancel_task_requests(file->private_data, NULL);
>>  	atomic_dec(&tctx->in_idle);
>>  
>> -	if (files)
>> -		io_uring_remove_task_files(tctx);
>> +	io_uring_remove_task_files(tctx);
> 
> This restricts cancellations to only one iteration. Just delete it,
> __io_uring_task_cancel() calls it already.

Ah indeed, makes it even better. I removed it, thanks.

-- 
Jens Axboe


      parent reply	other threads:[~2021-01-17 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17  4:04 [PATCH] io_uring: cancel all requests on task exit Jens Axboe
2021-01-17 10:52 ` Pavel Begunkov
2021-01-17 12:51   ` Josef
2021-01-17 14:52     ` Jens Axboe
2021-01-17 14:53   ` 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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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