All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] btrfs: zoned: automatic BG reclaim
@ 2021-03-19 10:48 Johannes Thumshirn
  2021-03-19 10:48 ` [PATCH v2 1/2] btrfs: rename delete_unused_bgs_mutex Johannes Thumshirn
  2021-03-19 10:48 ` [PATCH v2 2/2] btrfs: zoned: automatically reclaim zones Johannes Thumshirn
  0 siblings, 2 replies; 13+ messages in thread
From: Johannes Thumshirn @ 2021-03-19 10:48 UTC (permalink / raw)
  To: David Sterba
  Cc: Johannes Thumshirn, linux-btrfs @ vger . kernel . org,
	Naohiro Aota, Josef Bacik, Filipe Manana

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.


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 (2):
  btrfs: rename delete_unused_bgs_mutex
  btrfs: zoned: automatically reclaim zones

 fs/btrfs/block-group.c       | 90 ++++++++++++++++++++++++++++++++++--
 fs/btrfs/block-group.h       |  2 +
 fs/btrfs/ctree.h             |  5 +-
 fs/btrfs/disk-io.c           | 17 +++++--
 fs/btrfs/free-space-cache.c  |  9 +++-
 fs/btrfs/sysfs.c             | 35 ++++++++++++++
 fs/btrfs/volumes.c           | 48 +++++++++----------
 fs/btrfs/volumes.h           |  1 +
 include/trace/events/btrfs.h | 12 +++++
 9 files changed, 187 insertions(+), 32 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-04-07 11:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 10:48 [PATCH v2 0/2] btrfs: zoned: automatic BG reclaim Johannes Thumshirn
2021-03-19 10:48 ` [PATCH v2 1/2] btrfs: rename delete_unused_bgs_mutex Johannes Thumshirn
2021-03-19 17:49   ` Josef Bacik
2021-03-23  6:25   ` Anand Jain
2021-03-19 10:48 ` [PATCH v2 2/2] btrfs: zoned: automatically reclaim zones Johannes Thumshirn
2021-03-19 17:59   ` Josef Bacik
2021-03-23  7:11     ` Naohiro Aota
2021-04-07 11:30     ` Johannes Thumshirn
2021-03-23  6:45   ` Anand Jain
2021-04-07 11:29     ` Johannes Thumshirn
2021-03-23  9:57   ` Filipe Manana
2021-03-23 10:22     ` Johannes Thumshirn
2021-03-25 10:28       ` Johannes Thumshirn

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.