linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Jianchao <jianchao.wan9@gmail.com>
To: "Theodore Y. Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: get discard out of jbd2 commit kthread
Date: Tue, 18 May 2021 09:19:13 +0800	[thread overview]
Message-ID: <c7c00420-ed5c-0f5d-23c1-1c64b1800778@gmail.com> (raw)
In-Reply-To: <YKLXev4cjeRuGRqd@mit.edu>



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
> 

  reply	other threads:[~2021-05-18  1:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  3:57 [PATCH] ext4: get discard out of jbd2 commit kthread Wang Jianchao
2021-05-17 20:52 ` Theodore Y. Ts'o
2021-05-18  1:19   ` Wang Jianchao [this message]
2021-05-18 14:57     ` Theodore Y. Ts'o
2021-05-19  1:27       ` Wang Jianchao
2021-05-19 15:08         ` Theodore Y. Ts'o
2021-05-20  1:20           ` Wang Jianchao

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=c7c00420-ed5c-0f5d-23c1-1c64b1800778@gmail.com \
    --to=jianchao.wan9@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).