From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: fix improper setting of scanned
Date: Wed, 8 Jan 2020 18:44:36 +0100 [thread overview]
Message-ID: <20200108174435.GL3929@twin.jikos.cz> (raw)
In-Reply-To: <20200103153844.13852-1-josef@toxicpanda.com>
As 'scanning' has another meaning in btrfs, the subject should say
something about writeback or at least write cache range scanning.
On Fri, Jan 03, 2020 at 10:38:44AM -0500, Josef Bacik wrote:
> We noticed that we were having regular CG OOM kills in cases where there
> was still enough dirty pages to avoid OOM'ing. It turned out there's
> this corner case in btrfs's handling of range_cyclic where files that
> were being redirtied were not getting fully written out because of how
> we do range_cyclic writeback.
>
> We unconditionally were setting scanned = 1; the first time we found any
> pages in the inode. This isn't actually what we want, we want it to be
> set if we've scanned the entire file. For range_cyclic we could be
> starting in the middle or towards the end of the file, so we could write
> one page and then not write any of the other dirty pages in the file
> because we set scanned = 1.
>
> Fix this by not setting scanned = 1 if we find pages. The rules for
> setting scanned should be
>
> 1) !range_cyclic. In this case we have a specified range to write out.
> 2) range_cyclic && index == 0. In this case we've started at the
> beginning and there is no need to loop around a second time.
> 3) range_cyclic && we started at index > 0 and we've reached the end of
> the file without satisfying our nr_to_write.
>
> This patch fixes both of our writepages implementations to make sure
> these rules hold true. This fixed our over zealous CG OOMs in
> production.
>
> Fixes: d1310b2e0cd9 ("Btrfs: Split the extent_map code into two parts")
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/extent_io.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 410f5a64d3a6..d634cb0c39e3 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3965,6 +3965,7 @@ int btree_write_cache_pages(struct address_space *mapping,
> if (wbc->range_cyclic) {
> index = mapping->writeback_index; /* Start from prev offset */
> end = -1;
> + scanned = (index == 0);
It's explained in the changelog but I think a comment would be good here
too. I'll add it at commit time.
prev parent reply other threads:[~2020-01-08 17:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-03 15:38 [PATCH] btrfs: fix improper setting of scanned Josef Bacik
2020-01-08 17:44 ` David Sterba [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 \
--in-reply-to=20200108174435.GL3929@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@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