|
|
Log in / Subscribe / Register

Remap tree

From:  Mark Harmstone <mark-AT-harmstone.com>
To:  linux-btrfs-AT-vger.kernel.org
Subject:  [PATCH v3 00/17] Remap tree
Date:  Thu, 09 Oct 2025 12:27:55 +0100
Message-ID:  <20251009112814.13942-1-mark@harmstone.com>
Cc:  Mark Harmstone <mark-AT-harmstone.com>
Archive-link:  Article

This is version 3 of the patch series for the new logical remapping tree
feature - see the previous cover letters for more information including
the rationale:

* RFC: https://lore.kernel.org/all/20250515163641.3449017-1-maha...
* Version 1: https://lore.kernel.org/all/20250605162345.2561026-1-maha...
* Version 2: https://lore.kernel.org/all/20250813143509.31073-1-mark@h...

Changes since version 2:
* Addressed the points that Boris mentioned in his reviews
* Moved fully_remapped_bgs list from the transaction to fs_info
* Chunk sub_stripes now set to 0 when num_stripes is
* Fixed crash with RAID0
* Made it so changing a block group's flags feeds through to the
  block_group_item on commit
* Added discarding of fully-remapped block groups

For async discard, we set a new flag on the block group item,
BTRFS_BLOCK_GROUP_STRIPE_REMOVAL_PENDING, in the transaction in which
the last identity remap is removed. We then queue up async discard of
the whole of the range in the usual way. Once the block group has been
fully discarded, we remove the device extents, remove the chunk stripes,
and clear the STRIPE_REMOVAL_PENDING flag.

If we encounter a block group with this flag set when we walk the block
group tree on mount, we queue it up for discard again - that way it's
not possible for the discard of a block group to be missed.

For sync discard we don't set this flag, discard happens at the same
time as the transaction commit. But if we encounter it on mount we still
queue the BG up for discard, it just happens on the commit of the first
transaction after mount.

If you are trying the btrfs-progs patches I linked to in the other cover
letters, bear in mind that btrfs-check doesn't like the fact that
BTRFS_BLOCK_GROUP_STRIPE_REMOVAL_PENDING gets set on the block group
item but not the chunk item. There didn't seem much point in setting it
on both, but I can change this if anybody has strong feelings on the
matter.

Mark Harmstone (17):
  btrfs: add definitions and constants for remap-tree
  btrfs: add REMAP chunk type
  btrfs: allow remapped chunks to have zero stripes
  btrfs: remove remapped block groups from the free-space tree
  btrfs: don't add metadata items for the remap tree to the extent tree
  btrfs: add extended version of struct block_group_item
  btrfs: allow mounting filesystems with remap-tree incompat flag
  btrfs: redirect I/O for remapped block groups
  btrfs: release BG lock before calling btrfs_link_bg_list()
  btrfs: handle deletions from remapped block group
  btrfs: handle setting up relocation of block group with remap-tree
  btrfs: move existing remaps before relocating block group
  btrfs: replace identity maps with actual remaps when doing relocations
  btrfs: add do_remap param to btrfs_discard_extent()
  btrfs: allow balancing remap tree
  btrfs: handle discarding fully-remapped block groups
  btrfs: add stripe removal pending flag

 fs/btrfs/Kconfig                |    2 +
 fs/btrfs/accessors.h            |   29 +
 fs/btrfs/block-group.c          |  272 ++++-
 fs/btrfs/block-group.h          |   22 +-
 fs/btrfs/block-rsv.c            |    8 +
 fs/btrfs/block-rsv.h            |    1 +
 fs/btrfs/discard.c              |   70 +-
 fs/btrfs/disk-io.c              |  107 +-
 fs/btrfs/extent-tree.c          |  131 ++-
 fs/btrfs/extent-tree.h          |    3 +-
 fs/btrfs/free-space-cache.c     |   84 +-
 fs/btrfs/free-space-cache.h     |    1 +
 fs/btrfs/free-space-tree.c      |    4 +-
 fs/btrfs/free-space-tree.h      |    5 +-
 fs/btrfs/fs.h                   |   10 +-
 fs/btrfs/inode.c                |    2 +-
 fs/btrfs/locking.c              |    1 +
 fs/btrfs/relocation.c           | 1867 ++++++++++++++++++++++++++++++-
 fs/btrfs/relocation.h           |   10 +-
 fs/btrfs/space-info.c           |   22 +-
 fs/btrfs/sysfs.c                |    4 +
 fs/btrfs/transaction.c          |   13 +
 fs/btrfs/tree-checker.c         |   94 +-
 fs/btrfs/tree-checker.h         |    5 +
 fs/btrfs/volumes.c              |  302 ++++-
 fs/btrfs/volumes.h              |   19 +-
 include/uapi/linux/btrfs.h      |    1 +
 include/uapi/linux/btrfs_tree.h |   30 +-
 28 files changed, 2901 insertions(+), 218 deletions(-)

-- 
2.49.1




Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds