From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: David Sterba <dsterba@suse.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
linux-btrfs@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>,
Naohiro Aota <Naohiro.Aota@wdc.com>,
Filipe Manana <fdmanana@suse.com>,
Anand Jain <anand.jain@oracle.com>
Subject: [PATCH v4 0/3] btrfs: zoned: automatic BG reclaim
Date: Thu, 15 Apr 2021 22:58:32 +0900 [thread overview]
Message-ID: <cover.1618494550.git.johannes.thumshirn@wdc.com> (raw)
When a file gets deleted on a zoned file system, the space freed is not
returned back into the block group's free space, but is migrated to
zone_unusable.
As this zone_unusable space is behind the current write pointer it is not
possible to use it for new allocations. In the current implementation a
zone is reset once all of the block group's space is accounted as zone
unusable.
This behaviour can lead to premature ENOSPC errors on a busy file system.
Instead of only reclaiming the zone once it is completely unusable,
kick off a reclaim job once the amount of unusable bytes exceeds a user
configurable threshold between 51% and 100%. It can be set per mounted
filesystem via the sysfs tunable bg_reclaim_threshold which is set to 75%
per default.
Similar to reclaiming unused block groups, these dirty block groups are
added to a to_reclaim list and then on a transaction commit, the reclaim
process is triggered but after we deleted unused block groups, which will
free space for the relocation process.
Zones that are 100% full and zone unusable already get reclaimed atomatically
on transaction commit. Another improvement on the garbage collection side of
zoned btrfs would be no to reclaim block groups that have used, pinned and
reserved = 0 but zone_unusable > 0. This is not yet included as it needs
further reaserch and testing.
Changes to v3:
- Special case "discarding" after relocation (Filipe)
Changes to v2:
- Fix locking in multiple ways (Filipe)
- Offload reclaim into workqueue (Josef)
- Add patch discarding/zone-resetting after successfull relocation (Anand)
Changes to v1:
- Document sysfs parameter (David)
- Add info print for reclaim (Josef)
- Rename delete_unused_bgs_mutex to reclaim_bgs_lock (Filipe)
- Remove list_is_singular check (Filipe)
- Document of space_info->groups_sem use (Filipe)
Johannes Thumshirn (3):
btrfs: zoned: reset zones of relocated block groups
btrfs: rename delete_unused_bgs_mutex
btrfs: zoned: automatically reclaim zones
fs/btrfs/block-group.c | 102 +++++++++++++++++++++++++++++++++--
fs/btrfs/block-group.h | 3 ++
fs/btrfs/ctree.h | 8 ++-
fs/btrfs/disk-io.c | 19 +++++--
fs/btrfs/free-space-cache.c | 9 +++-
fs/btrfs/sysfs.c | 35 ++++++++++++
fs/btrfs/volumes.c | 69 ++++++++++++++----------
fs/btrfs/volumes.h | 1 +
include/trace/events/btrfs.h | 12 +++++
9 files changed, 222 insertions(+), 36 deletions(-)
--
2.30.0
next reply other threads:[~2021-04-15 13:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 13:58 Johannes Thumshirn [this message]
2021-04-15 13:58 ` [PATCH v4 1/3] btrfs: zoned: reset zones of relocated block groups Johannes Thumshirn
2021-04-15 18:26 ` Josef Bacik
2021-04-16 5:50 ` Johannes Thumshirn
2021-04-16 9:11 ` Filipe Manana
2021-04-16 9:14 ` Johannes Thumshirn
2021-04-16 9:30 ` Filipe Manana
2021-04-16 9:32 ` Johannes Thumshirn
2021-04-15 13:58 ` [PATCH v4 2/3] btrfs: rename delete_unused_bgs_mutex Johannes Thumshirn
2021-04-15 18:26 ` Josef Bacik
2021-04-16 9:15 ` Filipe Manana
2021-04-16 16:36 ` David Sterba
2021-04-15 13:58 ` [PATCH v4 3/3] btrfs: zoned: automatically reclaim zones Johannes Thumshirn
2021-04-15 18:36 ` Josef Bacik
2021-04-16 5:50 ` Johannes Thumshirn
2021-04-16 9:28 ` Filipe Manana
2021-04-16 16:38 ` David Sterba
2021-04-16 16:41 ` 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=cover.1618494550.git.johannes.thumshirn@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=Naohiro.Aota@wdc.com \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=josef@toxicpanda.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;
as well as URLs for NNTP newsgroup(s).