Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: add definitions and constants for remap-tree

Add an incompat flag for the new remap-tree feature, and the constants
and definitions needed to support it.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Mark Harmstone and committed by
David Sterba
ef6a31d0 c208aa0e

+34 -4
+4
fs/btrfs/accessors.h
··· 1010 1010 BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_size, 1011 1011 struct btrfs_verity_descriptor_item, size, 64); 1012 1012 1013 + BTRFS_SETGET_FUNCS(remap_address, struct btrfs_remap_item, address, 64); 1014 + BTRFS_SETGET_STACK_FUNCS(stack_remap_address, struct btrfs_remap_item, 1015 + address, 64); 1016 + 1013 1017 /* Cast into the data area of the leaf. */ 1014 1018 #define btrfs_item_ptr(leaf, slot, type) \ 1015 1019 ((type *)(btrfs_item_nr_offset(leaf, 0) + btrfs_item_offset(leaf, slot)))
+1
fs/btrfs/locking.c
··· 73 73 { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, DEFINE_NAME("free-space") }, 74 74 { .id = BTRFS_BLOCK_GROUP_TREE_OBJECTID, DEFINE_NAME("block-group") }, 75 75 { .id = BTRFS_RAID_STRIPE_TREE_OBJECTID, DEFINE_NAME("raid-stripe") }, 76 + { .id = BTRFS_REMAP_TREE_OBJECTID, DEFINE_NAME("remap") }, 76 77 { .id = 0, DEFINE_NAME("tree") }, 77 78 }; 78 79
+3
fs/btrfs/sysfs.c
··· 299 299 BTRFS_FEAT_ATTR_INCOMPAT(extent_tree_v2, EXTENT_TREE_V2); 300 300 /* Remove once support for raid stripe tree is feature complete. */ 301 301 BTRFS_FEAT_ATTR_INCOMPAT(raid_stripe_tree, RAID_STRIPE_TREE); 302 + /* Remove once support for remap tree is feature complete. */ 303 + BTRFS_FEAT_ATTR_INCOMPAT(remap_tree, REMAP_TREE); 302 304 #endif 303 305 #ifdef CONFIG_FS_VERITY 304 306 BTRFS_FEAT_ATTR_COMPAT_RO(verity, VERITY); ··· 333 331 #ifdef CONFIG_BTRFS_EXPERIMENTAL 334 332 BTRFS_FEAT_ATTR_PTR(extent_tree_v2), 335 333 BTRFS_FEAT_ATTR_PTR(raid_stripe_tree), 334 + BTRFS_FEAT_ATTR_PTR(remap_tree), 336 335 #endif 337 336 #ifdef CONFIG_FS_VERITY 338 337 BTRFS_FEAT_ATTR_PTR(verity),
+2 -4
fs/btrfs/tree-checker.c
··· 913 913 length, btrfs_stripe_nr_to_offset(U32_MAX)); 914 914 return -EUCLEAN; 915 915 } 916 - if (unlikely(type & ~(BTRFS_BLOCK_GROUP_TYPE_MASK | 917 - BTRFS_BLOCK_GROUP_PROFILE_MASK))) { 916 + if (unlikely(type & ~BTRFS_BLOCK_GROUP_VALID)) { 918 917 chunk_err(fs_info, leaf, chunk, logical, 919 918 "unrecognized chunk type: 0x%llx", 920 - ~(BTRFS_BLOCK_GROUP_TYPE_MASK | 921 - BTRFS_BLOCK_GROUP_PROFILE_MASK) & type); 919 + type & ~BTRFS_BLOCK_GROUP_VALID); 922 920 return -EUCLEAN; 923 921 } 924 922
+5
fs/btrfs/tree-checker.h
··· 57 57 BTRFS_TREE_BLOCK_WRITTEN_NOT_SET, 58 58 }; 59 59 60 + 61 + #define BTRFS_BLOCK_GROUP_VALID (BTRFS_BLOCK_GROUP_TYPE_MASK | \ 62 + BTRFS_BLOCK_GROUP_PROFILE_MASK | \ 63 + BTRFS_BLOCK_GROUP_REMAPPED) 64 + 60 65 /* 61 66 * Exported simply for btrfs-progs which wants to have the 62 67 * btrfs_tree_block_status return codes.
+1
fs/btrfs/volumes.c
··· 231 231 DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_DATA, "data"); 232 232 DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_SYSTEM, "system"); 233 233 DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_METADATA, "metadata"); 234 + DESCRIBE_FLAG(BTRFS_BLOCK_GROUP_REMAPPED, "remapped"); 234 235 235 236 DESCRIBE_FLAG(BTRFS_AVAIL_ALLOC_BIT_SINGLE, "single"); 236 237 for (i = 0; i < BTRFS_NR_RAID_TYPES; i++)
+1
include/uapi/linux/btrfs.h
··· 336 336 #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13) 337 337 #define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE (1ULL << 14) 338 338 #define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA (1ULL << 16) 339 + #define BTRFS_FEATURE_INCOMPAT_REMAP_TREE (1ULL << 17) 339 340 340 341 struct btrfs_ioctl_feature_flags { 341 342 __u64 compat_flags;
+17
include/uapi/linux/btrfs_tree.h
··· 76 76 /* Tracks RAID stripes in block groups. */ 77 77 #define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL 78 78 79 + /* Holds details of remapped addresses after relocation. */ 80 + #define BTRFS_REMAP_TREE_OBJECTID 13ULL 81 + 79 82 /* device stats in the device tree */ 80 83 #define BTRFS_DEV_STATS_OBJECTID 0ULL 81 84 ··· 284 281 #define BTRFS_CHUNK_ITEM_KEY 228 285 282 286 283 #define BTRFS_RAID_STRIPE_KEY 230 284 + 285 + #define BTRFS_IDENTITY_REMAP_KEY 234 286 + #define BTRFS_REMAP_KEY 235 287 + #define BTRFS_REMAP_BACKREF_KEY 236 287 288 288 289 /* 289 290 * Records the overall state of the qgroups. ··· 1168 1161 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) 1169 1162 #define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9) 1170 1163 #define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10) 1164 + #define BTRFS_BLOCK_GROUP_REMAPPED (1ULL << 11) 1171 1165 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \ 1172 1166 BTRFS_SPACE_INFO_GLOBAL_RSV) 1173 1167 ··· 1329 1321 */ 1330 1322 __le64 reserved[2]; 1331 1323 __u8 encryption; 1324 + } __attribute__ ((__packed__)); 1325 + 1326 + /* 1327 + * For a range identified by a BTRFS_REMAP_KEY item in the remap tree, gives 1328 + * the address that the start of the range will get remapped to. This 1329 + * structure is also shared by BTRFS_REMAP_BACKREF_KEY. 1330 + */ 1331 + struct btrfs_remap_item { 1332 + __le64 address; 1332 1333 } __attribute__ ((__packed__)); 1333 1334 1334 1335 #endif /* _BTRFS_CTREE_H_ */