From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/4] btrfs: defrag: don't waste CPU time on non-target extent
Date: Fri, 28 Jan 2022 16:12:54 +0800 [thread overview]
Message-ID: <cover.1643357469.git.wqu@suse.com> (raw)
In the rework of btrfs_defrag_file() one core idea is to defrag cluster
by cluster, thus we can have a better layered code structure, just like
what we have now:
btrfs_defrag_file()
|- defrag_one_cluster()
|- defrag_one_range()
|- defrag_one_locked_range()
But there is a catch, btrfs_defrag_file() just moves the cluster to the
next cluster, never considering cases like the current extent is already
too large, we can skip to its end directly.
This increases CPU usage on very large but not fragmented files.
Fix the behavior in defrag_one_cluster() that, defrag_collect_targets()
will reports where next search should start from.
If the current extent is not a target at all, then we can jump to the
end of that non-target extent to save time.
To get the missing optimization, also introduce a new structure,
btrfs_defrag_ctrl, so we don't need to pass things like @newer_than and
@max_to_defrag around.
This also remove weird behaviors like reusing range::start for next
search location.
And since we need to convert old btrfs_ioctl_defrag_range_args to newer
btrfs_defrag_ctrl, also do extra sanity check in the converting
function.
Such cleanup will also bring us closer to expose these extra policy
parameters in future enhanced defrag ioctl interface.
(Unfortunately, the reserved space of the existing defrag ioctl is not
large enough to contain them all)
Qu Wenruo (4):
btrfs: uapi: introduce BTRFS_DEFRAG_RANGE_MASK for later sanity check
btrfs: defrag: introduce btrfs_defrag_ctrl structure for later usage
btrfs: defrag: use btrfs_defrag_ctrl to replace
btrfs_ioctl_defrag_range_args for btrfs_defrag_file()
btrfs: defrag: allow defrag_one_cluster() to large extent which is not
a target
fs/btrfs/ctree.h | 22 +++-
fs/btrfs/file.c | 17 ++--
fs/btrfs/ioctl.c | 199 ++++++++++++++++++++++---------------
include/uapi/linux/btrfs.h | 6 +-
4 files changed, 152 insertions(+), 92 deletions(-)
--
2.34.1
next reply other threads:[~2022-01-28 8:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 8:12 Qu Wenruo [this message]
2022-01-28 8:12 ` [PATCH 1/4] btrfs: uapi: introduce BTRFS_DEFRAG_RANGE_MASK for later sanity check Qu Wenruo
2022-02-03 16:58 ` Filipe Manana
2022-01-28 8:12 ` [PATCH 2/4] btrfs: defrag: introduce btrfs_defrag_ctrl structure for later usage Qu Wenruo
2022-02-03 17:06 ` Filipe Manana
2022-01-28 8:12 ` [PATCH 3/4] btrfs: defrag: use btrfs_defrag_ctrl to replace btrfs_ioctl_defrag_range_args for btrfs_defrag_file() Qu Wenruo
2022-02-03 17:17 ` Filipe Manana
2022-02-04 0:30 ` Qu Wenruo
2022-02-04 1:03 ` Qu Wenruo
2022-02-04 17:57 ` David Sterba
2022-02-04 18:00 ` David Sterba
2022-02-04 18:17 ` David Sterba
2022-02-08 17:00 ` David Sterba
2022-02-09 0:15 ` Qu Wenruo
2022-02-14 16:19 ` David Sterba
2022-01-28 8:12 ` [PATCH 4/4] btrfs: defrag: allow defrag_one_cluster() to large extent which is not a target Qu Wenruo
2022-02-03 17:39 ` Filipe Manana
2022-02-04 0:39 ` Qu Wenruo
2022-02-04 7:08 ` 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=cover.1643357469.git.wqu@suse.com \
--to=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.