From: Filipe Manana <fdmanana@kernel.org>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 0/2] btrfs: defrag: bring back the old file extent search behavior and address merged extent map generation problem
Date: Fri, 11 Feb 2022 12:07:04 +0000 [thread overview]
Message-ID: <YgZRaH6urTEoCAZb@debian9.Home> (raw)
In-Reply-To: <cover.1644561774.git.wqu@suse.com>
On Fri, Feb 11, 2022 at 02:46:11PM +0800, Qu Wenruo wrote:
> Filipe reported that the old defrag code using btrfs_search_forward() to
> do the following optimization:
>
> - Don't cache extent maps
> To save memory in the long run
>
> - Skip entire file ranges which doesn't meet generation requirement
>
> - Don't use merged extent maps which will have unreliable geneartion
>
> The first patch will bring back the old behavior, along with the old
> optimizations.
>
> However the 3rd problem is not that easy to solve, as data
> read/readahead can also load extent maps into the cache, and causing
> extent maps being merged.
>
> Such already cached and merged extent maps will still confuse autodefrag,
> as if we found cached extent maps, we will not try to read them from
> disk again.
>
> So to completely prevent merged extent maps tricking autodefrag, here
> comes the 2nd patch, to mark merged extent maps for defrag.
>
> If we hit an merged extent, and its generation meets our requirement, we
> will not trust it but read from disk to get a reliable generation.
>
> This should reduce defrag IO caused by the hidden extent map merging
> behavior.
>
> Changelog:
> v2:
> - Make defrag_get_em() to be more flexiable to handle file extent
> iteartion
> Now it will not reject item key which is smaller than our target but
> doesn't have the wanted type/objectid.
> It will continue go next next instead, to prevent skipping an extent.
>
> - Properly reduce path.slots[0]
> There is a bug where I want to put "if (path.slots[0] == 0)" but I put
> "if (btrfs_header_nritems(path.slots[0]))".
> This is fixed with reworked file extent iteration code.
>
> - Address merged extent maps properly
> With fixed defrag_get_extent(), we can rely on it to get original em
> from disk.
> So what we need to do is just to ignore merged extents which meets
> our generation requirement.
>
> v3:
> - Rebased to latest misc-next
>
> - Fix several generation spell typo
>
> - Fix a case where btrfs_search_slot() can lead to path->slots[0] >=
> nritems
>
> - Fix the commit message on modified extent map
> Now that part mentioning fsync() doesn't help on the autodefrag bug.
>
> - Update the wording on extent map read from subvolume trees
>
> Qu Wenruo (2):
> btrfs: defrag: bring back the old file extent search behavior
> btrfs: defrag: don't use merged extent map for their generation check
Ok, for the both patches:
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks.
>
> fs/btrfs/extent_map.c | 2 +
> fs/btrfs/extent_map.h | 8 ++
> fs/btrfs/ioctl.c | 174 +++++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 180 insertions(+), 4 deletions(-)
>
> --
> 2.35.0
>
next prev parent reply other threads:[~2022-02-11 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 6:46 [PATCH v3 0/2] btrfs: defrag: bring back the old file extent search behavior and address merged extent map generation problem Qu Wenruo
2022-02-11 6:46 ` [PATCH v3 1/2] btrfs: defrag: bring back the old file extent search behavior Qu Wenruo
2022-02-14 16:15 ` David Sterba
2022-02-15 0:02 ` Qu Wenruo
2022-02-21 17:22 ` David Sterba
2022-02-22 0:05 ` Qu Wenruo
2022-02-11 6:46 ` [PATCH v3 2/2] btrfs: defrag: don't use merged extent map for their generation check Qu Wenruo
2022-02-11 12:07 ` Filipe Manana [this message]
2022-02-21 14:41 ` [PATCH v3 0/2] btrfs: defrag: bring back the old file extent search behavior and address merged extent map generation problem David Sterba
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=YgZRaH6urTEoCAZb@debian9.Home \
--to=fdmanana@kernel.org \
--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