mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-13 17:45:09 -05:00
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>
This commit is contained in:
committed by
David Sterba
parent
c208aa0ef6
commit
ef6a31d035
@@ -1010,6 +1010,10 @@ 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_item, address, 64);
|
||||
BTRFS_SETGET_STACK_FUNCS(stack_remap_address, struct btrfs_remap_item,
|
||||
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)))
|
||||
|
||||
@@ -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") },
|
||||
{ .id = 0, DEFINE_NAME("tree") },
|
||||
};
|
||||
|
||||
|
||||
@@ -299,6 +299,8 @@ BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
|
||||
BTRFS_FEAT_ATTR_INCOMPAT(extent_tree_v2, EXTENT_TREE_V2);
|
||||
/* Remove once support for raid stripe tree is feature complete. */
|
||||
BTRFS_FEAT_ATTR_INCOMPAT(raid_stripe_tree, RAID_STRIPE_TREE);
|
||||
/* Remove once support for remap tree is feature complete. */
|
||||
BTRFS_FEAT_ATTR_INCOMPAT(remap_tree, REMAP_TREE);
|
||||
#endif
|
||||
#ifdef CONFIG_FS_VERITY
|
||||
BTRFS_FEAT_ATTR_COMPAT_RO(verity, VERITY);
|
||||
@@ -331,6 +333,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
|
||||
#ifdef CONFIG_BTRFS_EXPERIMENTAL
|
||||
BTRFS_FEAT_ATTR_PTR(extent_tree_v2),
|
||||
BTRFS_FEAT_ATTR_PTR(raid_stripe_tree),
|
||||
BTRFS_FEAT_ATTR_PTR(remap_tree),
|
||||
#endif
|
||||
#ifdef CONFIG_FS_VERITY
|
||||
BTRFS_FEAT_ATTR_PTR(verity),
|
||||
|
||||
@@ -913,12 +913,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
/*
|
||||
* Exported simply for btrfs-progs which wants to have the
|
||||
* btrfs_tree_block_status return codes.
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
/*
|
||||
* 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,13 @@ struct btrfs_verity_descriptor_item {
|
||||
__u8 encryption;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
/*
|
||||
* For a range identified by a BTRFS_REMAP_KEY item in the remap tree, gives
|
||||
* the address that the start of the range will get remapped to. This
|
||||
* structure is also shared by BTRFS_REMAP_BACKREF_KEY.
|
||||
*/
|
||||
struct btrfs_remap_item {
|
||||
__le64 address;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
#endif /* _BTRFS_CTREE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user