linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Wang Jianchao <jianchao.wan9@gmail.com>
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: Mon, 17 May 2021 16:52:10 -0400	[thread overview]
Message-ID: <YKLXev4cjeRuGRqd@mit.edu> (raw)
In-Reply-To: <53146e54-af36-0c32-cad8-433460461237@gmail.com>

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.

     	    	       	       	   - Ted

  reply	other threads:[~2021-05-17 20:52 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 [this message]
2021-05-18  1:19   ` Wang Jianchao
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=YKLXev4cjeRuGRqd@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=jianchao.wan9@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).