From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC 4/4] btrfs: inode: make btrfs_invalidatepage() to be subpage compatible
Date: Thu, 17 Dec 2020 09:51:33 -0500 [thread overview]
Message-ID: <778948b8-ec8c-fcbe-310f-eccb37d424f8@toxicpanda.com> (raw)
In-Reply-To: <20201217045737.48100-5-wqu@suse.com>
On 12/16/20 11:57 PM, Qu Wenruo wrote:
> [BUG]
> With current subpage RW patchset, the following script can lead to
> filesystem hang:
> # mkfs.btrfs -f -s 4k $dev
> # mount $dev -o nospace_cache $mnt
> # fsstress -w -n 100 -p 1 -s 1608140256 -v -d $mnt
>
> The file system will hang at wait_event() of
> btrfs_start_ordered_extent().
>
> [CAUSE]
> The root cause is, btrfs_invalidatepage() is freeing page::private which
> still has subpage dirty bit set.
>
> The offending situation happens like this:
> btrfs_fllocate()
> |- btrfs_zero_range()
> |- btrfs_punch_hole_lock_range()
> |- truncate_pagecache_range()
> |- btrfs_invalidatepage()
>
> The involved range looks like:
>
> 0 32K 64K 96K 128K
> |///////||//////|
> | Range to drop |
>
> For the [32K, 64K) range, since the offset is 32K, the page won't be
> invalidated.
>
> But for the [64K, 96K) range, the offset is 0, current
> btrfs_invalidatepage() will call clear_page_extent_mapped() which will
> detach page::private, making the subpage dirty bitmap being cleared.
>
> This prevents later __extent_writepage_io() to locate any range to
> write, thus no way to wake up the ordered extents.
>
> [FIX]
> To fix the problem this patch will:
> - Only clear page status and detach page private when the full page
> is invalidated
>
> - Change how we handle unfinished ordered extent
> If there is any ordered extent unfinished in the page range, we can't
> call clear_extent_bit() with delete == true.
>
> [REASON FOR RFC]
> There is still uncertainty around the btrfs_releasepage() call.
>
> 1. Why we need btrfs_releasepage() call for non-full-page condition?
> Other fs (aka. xfs) just exit without doing special handling if
> invalidatepage() is called with part of the page.
>
> Thus I didn't completely understand why btrfs_releasepage() here is
> needed for non-full page call.
>
> 2. Why "if (offset)" is not causing problem for current code?
> This existing if (offset) call can be skipped for cases like
> offset == 0 length == 2K.
> As MM layer can call invalidatepage() with unaligned offset/length,
> for cases like truncate_inode_pages_range().
> This will make btrfs_invalidatepage() to truncate the whole page when
> we only need to zero part of the page.
>
Are we ever calling with a different length when pagesize == sectorsize? That's
probably why it works fine now.
But I think we should follow what all the other file systems do, if len !=
PAGE_SIZE || offset != 0 then just skip it, that would probably be easier and
work for you as well? Thanks,
Josef
next prev parent reply other threads:[~2020-12-17 14:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 4:57 [PATCH 0/4] btrfs: inode: btrfs_invalidatepage() related refactor and fix for subpage Qu Wenruo
2020-12-17 4:57 ` [PATCH 1/4] btrfs: inode: use min() to replace open-code in btrfs_invalidatepage() Qu Wenruo
2020-12-17 4:57 ` [PATCH 2/4] btrfs: inode: remove variable shadowing " Qu Wenruo
2020-12-17 5:38 ` Su Yue
2020-12-17 5:42 ` Qu Wenruo
2020-12-17 6:08 ` Su Yue
2020-12-17 5:55 ` Nikolay Borisov
2020-12-17 5:59 ` Nikolay Borisov
2020-12-17 6:13 ` Qu Wenruo
2020-12-17 12:29 ` David Sterba
2020-12-17 4:57 ` [PATCH 3/4] btrfs: inode: move the timing of TestClearPagePrivate() " Qu Wenruo
2020-12-17 4:57 ` [PATCH RFC 4/4] btrfs: inode: make btrfs_invalidatepage() to be subpage compatible Qu Wenruo
2020-12-17 11:20 ` Filipe Manana
2020-12-22 4:38 ` Qu Wenruo
2020-12-17 14:51 ` Josef Bacik [this message]
2020-12-18 0:42 ` Qu Wenruo
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=778948b8-ec8c-fcbe-310f-eccb37d424f8@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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