Thread (43 messages) 43 messages, 5 authors, 2025-09-02

Re: [PATCH v2 01/16] btrfs: add definitions and constants for remap-tree

From: Mark Harmstone <hidden>
Date: 2025-08-18 17:21:33

Thanks Boris.

The funny indentation is artefact of diff: the plus sign at the beginning
throws off the tabstop in your e-mail client. If you do `git am` it looks
fine.

On 16/08/2025 12.51 am, Boris Burkov wrote:
On Wed, Aug 13, 2025 at 03:34:43PM +0100, Mark Harmstone wrote:
quoted
Add an incompat flag for the new remap-tree feature, and the constants
and definitions needed to support it.

Signed-off-by: Mark Harmstone <redacted>
Some formatting nits, but you can add

Reviewed-by: Boris Burkov <redacted>
quoted
---
  fs/btrfs/accessors.h            |  3 +++
  fs/btrfs/locking.c              |  1 +
  fs/btrfs/sysfs.c                |  2 ++
  fs/btrfs/tree-checker.c         |  6 ++----
  fs/btrfs/tree-checker.h         |  5 +++++
  fs/btrfs/volumes.c              |  1 +
  include/uapi/linux/btrfs.h      |  1 +
  include/uapi/linux/btrfs_tree.h | 12 ++++++++++++
  8 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/accessors.h b/fs/btrfs/accessors.h
index 99b3ced12805..95a1ca8c099b 100644
--- a/fs/btrfs/accessors.h
+++ b/fs/btrfs/accessors.h
@@ -1009,6 +1009,9 @@ BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_encryption,
  BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_size,
  			 struct btrfs_verity_descriptor_item, size, 64);
  
+BTRFS_SETGET_FUNCS(remap_address, struct btrfs_remap, address, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_remap_address, struct btrfs_remap, address, 64);
+
  /* Cast into the data area of the leaf. */
  #define btrfs_item_ptr(leaf, slot, type)				\
  	((type *)(btrfs_item_nr_offset(leaf, 0) + btrfs_item_offset(leaf, slot)))
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index a3e6d9616e60..26f810258486 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -73,6 +73,7 @@ static struct btrfs_lockdep_keyset {
  	{ .id = BTRFS_FREE_SPACE_TREE_OBJECTID,	DEFINE_NAME("free-space") },
  	{ .id = BTRFS_BLOCK_GROUP_TREE_OBJECTID, DEFINE_NAME("block-group") },
  	{ .id = BTRFS_RAID_STRIPE_TREE_OBJECTID, DEFINE_NAME("raid-stripe") },
+	{ .id = BTRFS_REMAP_TREE_OBJECTID,      DEFINE_NAME("remap-tree") },
  	{ .id = 0,				DEFINE_NAME("tree")	},
  };
  
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 81f52c1f55ce..857d2772db1c 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -291,6 +291,7 @@ BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
  BTRFS_FEAT_ATTR_COMPAT_RO(block_group_tree, BLOCK_GROUP_TREE);
  BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
  BTRFS_FEAT_ATTR_INCOMPAT(simple_quota, SIMPLE_QUOTA);
+BTRFS_FEAT_ATTR_INCOMPAT(remap_tree, REMAP_TREE);
  #ifdef CONFIG_BLK_DEV_ZONED
  BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
  #endif
@@ -325,6 +326,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
  	BTRFS_FEAT_ATTR_PTR(raid1c34),
  	BTRFS_FEAT_ATTR_PTR(block_group_tree),
  	BTRFS_FEAT_ATTR_PTR(simple_quota),
+	BTRFS_FEAT_ATTR_PTR(remap_tree),
  #ifdef CONFIG_BLK_DEV_ZONED
  	BTRFS_FEAT_ATTR_PTR(zoned),
  #endif
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 0f556f4de3f9..76ec3698f197 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -912,12 +912,10 @@ int btrfs_check_chunk_valid(const struct btrfs_fs_info *fs_info,
  			  length, btrfs_stripe_nr_to_offset(U32_MAX));
  		return -EUCLEAN;
  	}
-	if (unlikely(type & ~(BTRFS_BLOCK_GROUP_TYPE_MASK |
-			      BTRFS_BLOCK_GROUP_PROFILE_MASK))) {
+	if (unlikely(type & ~BTRFS_BLOCK_GROUP_VALID)) {
  		chunk_err(fs_info, leaf, chunk, logical,
  			  "unrecognized chunk type: 0x%llx",
-			  ~(BTRFS_BLOCK_GROUP_TYPE_MASK |
-			    BTRFS_BLOCK_GROUP_PROFILE_MASK) & type);
+			  type & ~BTRFS_BLOCK_GROUP_VALID);
  		return -EUCLEAN;
  	}
  
diff --git a/fs/btrfs/tree-checker.h b/fs/btrfs/tree-checker.h
index eb201f4ec3c7..833e2fd989eb 100644
--- a/fs/btrfs/tree-checker.h
+++ b/fs/btrfs/tree-checker.h
@@ -57,6 +57,11 @@ enum btrfs_tree_block_status {
  	BTRFS_TREE_BLOCK_WRITTEN_NOT_SET,
  };
  
+
+#define BTRFS_BLOCK_GROUP_VALID	(BTRFS_BLOCK_GROUP_TYPE_MASK | \
+				 BTRFS_BLOCK_GROUP_PROFILE_MASK | \
+				 BTRFS_BLOCK_GROUP_REMAPPED)
+
I think the two next lines should be lined up after the '('

See the masks in include/uapi/linux/btrfs_tree.h
quoted
  /*
   * Exported simply for btrfs-progs which wants to have the
   * btrfs_tree_block_status return codes.
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index fa7a929a0461..e067e9cd68a5 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -231,6 +231,7 @@ void btrfs_describe_block_groups(u64 bg_flags, char *buf, u32 size_buf)
  	DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_DATA, "data");
  	DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_SYSTEM, "system");
  	DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_METADATA, "metadata");
+	DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_REMAPPED, "remapped");
  
  	DESCRIBE_FLAG(BTRFS_AVAIL_ALLOC_BIT_SINGLE, "single");
  	for (i = 0; i < BTRFS_NR_RAID_TYPES; i++)
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 8e710bbb688e..fba303ed49e6 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -336,6 +336,7 @@ struct btrfs_ioctl_fs_info_args {
  #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2	(1ULL << 13)
  #define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE	(1ULL << 14)
  #define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA	(1ULL << 16)
+#define BTRFS_FEATURE_INCOMPAT_REMAP_TREE	(1ULL << 17)
  
  struct btrfs_ioctl_feature_flags {
  	__u64 compat_flags;
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index fc29d273845d..4439d77a7252 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -76,6 +76,9 @@
  /* Tracks RAID stripes in block groups. */
  #define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL
  
+/* Holds details of remapped addresses after relocation. */
+#define BTRFS_REMAP_TREE_OBJECTID 13ULL
+
  /* device stats in the device tree */
  #define BTRFS_DEV_STATS_OBJECTID 0ULL
  
@@ -282,6 +285,10 @@
  
  #define BTRFS_RAID_STRIPE_KEY	230
  
+#define BTRFS_IDENTITY_REMAP_KEY 	234
+#define BTRFS_REMAP_KEY		 	235
+#define BTRFS_REMAP_BACKREF_KEY	 	236
more funny indenting
quoted
+
  /*
   * Records the overall state of the qgroups.
   * There's only one instance of this key present,
@@ -1161,6 +1168,7 @@ struct btrfs_dev_replace_item {
  #define BTRFS_BLOCK_GROUP_RAID6         (1ULL << 8)
  #define BTRFS_BLOCK_GROUP_RAID1C3       (1ULL << 9)
  #define BTRFS_BLOCK_GROUP_RAID1C4       (1ULL << 10)
+#define BTRFS_BLOCK_GROUP_REMAPPED      (1ULL << 11)
  #define BTRFS_BLOCK_GROUP_RESERVED	(BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
  					 BTRFS_SPACE_INFO_GLOBAL_RSV)
  
@@ -1323,4 +1331,8 @@ struct btrfs_verity_descriptor_item {
  	__u8 encryption;
  } __attribute__ ((__packed__));
  
+struct btrfs_remap {
+	__le64 address;
+} __attribute__ ((__packed__));
+
  #endif /* _BTRFS_CTREE_H_ */
-- 
2.49.1
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help