lkml.org 
[lkml]   [2021]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ext4: get discard out of jbd2 commit kthread
From
Date


On 2021/5/18 4:52 AM, Theodore Y. Ts'o wrote:
> On Mon, May 17, 2021 at 11:57:09AM +0800, Wang Jianchao wrote:
>> Right now, discard is issued and waited to be completed in jbd2
>> commit kthread context after the logs are committed. When large
>> amount of files are deleted and discard is flooding, jbd2 commit
>> kthread can be blocked for long time. Then all of the metadata
>> operations can be blocked to wait the log space.
>>
>> One case is the page fault path with read mm->mmap_sem held, which
>> wants to update the file time but has to wait for the log space.
>> When other threads in the task wants to do mmap, then write mmap_sem
>> is blocked. Finally all of the following read mmap_sem requirements
>> are blocked, even the ps command which need to read the /proc/pid/
>> -cmdline. Our monitor service which needs to read /proc/pid/cmdline
>> used to be blocked for 5 mins.
>>
>> This patch moves the discard out of jbd2 kthread context and do it
>> in kworker. And drain the kwork when cannot get space in mb buddy.
>> This is done out of jbd2 handle and won't block the commit process.
>> After that, we could use blk-wbt or other method to throttle the
>> discard and needn't to worry it block the jbd2 commit kthread any
>> more.
>
> Wouldn't be much simpler to do something like this?
>
> if (discard_bio) {
> - submit_bio_wait(discard_bio);
> - bio_put(discard_bio);
> + submit_bio(discard_bio);
> }
>
>
> We're throwing away the return value from submit_bio_wait(), so
> there's no real need to wait for I/O to complete so we can fetch the
> I/O status.
>
> That way we don't need to move all of this to a kworker context.

The submit_bio also needs to be out of jbd2 commit kthread as it may be
blocked due to blk-wbt or no enough request tag. ;)

Best Regards
Jianchao


>
> - Ted
>

\
 
 \ /
  Last update: 2021-05-18 03:21    [W:0.078 / U:0.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site