Re: [PATCH for-5.10] io_uring: remove req cancel in ->flush()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/19/20 5:40 PM, Pavel Begunkov wrote:
> On 19/10/2020 21:08, Jens Axboe wrote:
>> On 10/19/20 9:45 AM, Pavel Begunkov wrote:
>>> Every close(io_uring) causes cancellation of all inflight requests
>>> carrying ->files. That's not nice but was neccessary up until recently.
>>> Now task->files removal is handled in the core code, so that part of
>>> flush can be removed.
>>
>> It does change the behavior, but I'd wager that's safe. One minor
>> comment:
> 
> Right, but I would think that users are not happy that every close
> kills requests without apparent reasons.

To be fair, closing the ring fd is kind of unexpected and I would not
expect any real applications to do that. If they did, I would have
expected queries on why file table requests get canceled on close. Hence
I'm not too worried about anyone hitting any issues related to this
change, as the change is certainly one for the better.

>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>> index 95d2bb7069c6..6536e24eb44e 100644
>>> --- a/fs/io_uring.c
>>> +++ b/fs/io_uring.c
>>> @@ -8748,16 +8748,12 @@ void __io_uring_task_cancel(void)
>>>  
>>>  static int io_uring_flush(struct file *file, void *data)
>>>  {
>>> -	struct io_ring_ctx *ctx = file->private_data;
>>> +	bool exiting = !data;
>>>  
>>> -	/*
>>> -	 * If the task is going away, cancel work it may have pending
>>> -	 */
>>>  	if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
>>> -		data = NULL;
>>> +		exiting = true;
>>>  
>>> -	io_uring_cancel_task_requests(ctx, data);
>>> -	io_uring_attempt_task_drop(file, !data);
>>> +	io_uring_attempt_task_drop(file, exiting);
>>>  	return 0;
>>>  }
>>
>> Why not just keep the !data for task_drop? Would make the diff take
>> away just the hunk we're interested in. Even adding a comment would be
>> better, imho.
> 
> That would look cleaner, but I just left what already was there. TBH,
> I don't even entirely understand why exiting=!data. Looking up how
> exit_files() works, it passes down non-NULL files to
> put_files_struct() -> ... filp_close() -> f_op->flush().
> 
> I'm curious how does this filp_close(file, files=NULL) happens?

It doesn't, we just clear it internall to match all requests, not just
files backed ones.

> Moreover, if that's exit_files() which is interesting, then first
> it calls io_uring_cancel_task_requests(), which should remove all
> struct file from tctx->xa. I haven't tested it though.

Yep, further cleanups are certainly possible there.

I've queued this up, thanks.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux