From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH RFC 0/3] btrfs: make autodefrag to defrag and only defrag small write ranges
Date: Wed, 9 Feb 2022 17:23:11 +0800 [thread overview]
Message-ID: <cover.1644398069.git.wqu@suse.com> (raw)
Previously autodefrag works by scanning the whole file with a minimal
generation threshold.
Although we have various optimization to skip ranges which don't meet
the generation requirement, it can still waste some time on scanning the
whole file, especially if the inode got an almost full overwrite.
There is another problem, there is a gap between our small writes and
defrag extent size threshold.
In fact, for compressed writes, <16K will be considered as small writes,
while for uncompressed writes, <32K will be considered as small writes.
On the other hand, autodefrag uses 256K as default extent size
threshold.
This means if one file has a lot of writes larger than 32K, which
normally will not trigger autodefrag, but if one small write happens,
all writes between 32K and 256K will be defragged.
This double standards is causing extra IO.
This patchset will address it by only defragging the small writes which
trigger autodefrag.
This rework will cause the following behavior change:
- Only small write ranges will be defragged
Exactly what we want.
- Enlarged critical section for fs_info::defrag_inodes_lock
Now we need to not only add the inode_defrag structure to rb tree, but
also call set_extent_bits() inside the critical section.
Thus defrag_inodes_lock is upgraded to mutex.
No benchmark for the possible performance impact though.
- No inode re-queue if there are large sectors to defrag
Not sure if this will make a difference, as we no longer requeue, and
only scan forward.
Reason for RFC:
I'm not sure if this is the correct way to go, but with my biased eyes,
it looks very solid.
Another concern is how to backport for v5.16.
Qu Wenruo (3):
btrfs: remove an unused parameter of btrfs_add_inode_defrag()
btrfs: introduce IO_TREE_AUTODEFRAG owner type
btrfs: make autodefrag to defrag small writes without rescanning the
whole file
fs/btrfs/ctree.h | 5 +-
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/extent-io-tree.h | 1 +
fs/btrfs/file.c | 217 +++++++++++++++++++++-----------------
fs/btrfs/inode.c | 2 +-
5 files changed, 125 insertions(+), 102 deletions(-)
--
2.35.0
next reply other threads:[~2022-02-09 9:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 9:23 Qu Wenruo [this message]
2022-02-09 9:23 ` [PATCH RFC 1/3] btrfs: remove an unused parameter of btrfs_add_inode_defrag() Qu Wenruo
2022-02-09 9:23 ` [PATCH RFC 2/3] btrfs: introduce IO_TREE_AUTODEFRAG owner type Qu Wenruo
2022-02-09 9:23 ` [PATCH RFC 3/3] btrfs: make autodefrag to defrag small writes without rescanning the whole file Qu Wenruo
2022-02-09 17:39 ` Filipe Manana
2022-02-10 0:31 ` Qu Wenruo
2022-02-10 15:48 ` Filipe Manana
2022-02-11 0:24 ` Qu Wenruo
2022-02-11 6:21 ` Qu Wenruo
2022-02-14 16:35 ` David Sterba
2022-02-15 5:54 ` Qu Wenruo
2022-02-09 17:48 ` [PATCH RFC 0/3] btrfs: make autodefrag to defrag and only defrag small write ranges Filipe Manana
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.1644398069.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.