btrfs-progs: partial support for WRITE_INTENT_BITMAP compat RO flag
cover btrfs-progs: partial support for WRITE_INTENT_BITMAP compat RO flag
This is the btrfs-progs counter-part to add placeholder for WRITE_INTENT_BITMAP compat RO flag.
The same as kernel, this will have two compat RO flags:
- EXTRA_SUPER_RESERVED
To indicate exactly how many bytes are reserved at the beginning of each device.
By default mkfs.btrfs will reserve another 1MiB in addition to the existing 1MiB.
So that later write-intent-bitmap can utilize the extra space. (although write-intent-bitmap may only utilize at most 64KiB).
- WRITE_INTENT_BITMAP
Just to indicate if we have write intent bitmap.
Currently it doesn't do any real work (aka, just a place holder).
Thus the patchset is mostly for EXTRA_SUPER_RESERVED, including the following part:
- Add the needed definition
- Add mkfs support
- Add print-tree support
- Add extra warning and solution for btrfsck
For EXTRA_SUPER_RESERVED only, it's no different than the initial 1MiB reservation, kernel can handle it without problem.
The extra check support will just do warning, and at the end, output a solution (using balance with drange filter).
Qu Wenruo (6):
btrfs-progs: introduce a new compat RO flag, EXTRA_SUPER_RESERVED
btrfs-progs: mkfs: add support for extra-super-reserved runtime flag
btrfs-progs: print-tree: remove duplicated definition for compat RO
flags
btrfs-progs: print-tree: support btrfs_super_block::reserved_bytes
btrfs-progs: check: add extra warning for dev extents inside the
reserved range
btrfs-progs: introduce the experimental compat RO flag,
WRITE_INTENT_BITMAP
check/main.c | 17 ++++++++++++++++ check/mode-lowmem.c | 22 +++++++++++++++++++++ common/fsfeatures.c | 19 ++++++++++++++++++ common/fsfeatures.h | 2 ++ kernel-shared/ctree.h | 40 ++++++++++++++++++++++++++++++++++++-- kernel-shared/disk-io.c | 18 +++++++++++++++++ kernel-shared/print-tree.c | 11 ++++++++--- kernel-shared/volumes.c | 4 ++++ mkfs/common.c | 25 ++++++++++++++++++++++++ mkfs/main.c | 14 +++++++++++++ 10 files changed, 167 insertions(+), 5 deletions(-)
Signature · 1 line
2.36.1
PATCH 1/6 btrfs-progs: introduce a new compat RO flag, EXTRA_SUPER_RESERVED
This new compat RO flag allows btrfs to reserve extra space other than the default 1MiB at the beginning of each device.
Currently the new RO flag will enable the new super block member, reserved_bytes, to be utilized for chunk allocation, to avoid the specified byte range.
--- kernel-shared/ctree.h | 24 ++++++++++++++++++++++-- kernel-shared/disk-io.c | 9 +++++++++ kernel-shared/volumes.c | 4 ++++ 3 files changed, 35 insertions(+), 2 deletions(-)
kernel-shared/ctree.h +22 -2
@@ -466,8 +466,15 @@ struct btrfs_super_block {__le64 reserved[24 ];u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE ];struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS ]; + +/* +* How many bytes are reserved at the beginning of a device. +* Should be >= BTRFS_DEFAULT_RESERVED. +*/ +__le32 reserved_bytes; +/* Padded to 4096 bytes */ -u8 padding[565 ]; +u8 padding[561 ]; } __attribute__ ((__packed__));BUILD_ASSERT (sizeof (struct btrfs_super_block ) ==BTRFS_SUPER_INFO_SIZE );
@@ -485,6 +492,16 @@ BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);*/ #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1) +/* +* Allow btrfs to have extra reserved space (other than the default 1MiB) at +* the beginning of each device. +* +* This feature will enable the usage of btrfs_super_block::reserved_bytes. +* +* This feature would only be available for non-zoned filesystems. +*/ +#define BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED (1ULL << 3) +#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
@@ -514,7 +531,8 @@ BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);*/ #define BTRFS_FEATURE_COMPAT_RO_SUPP \ (BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | \ - BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID) + BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID |\ + BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED)#if EXPERIMENTAL #define BTRFS_FEATURE_INCOMPAT_SUPP \
@@ -2374,6 +2392,8 @@ BTRFS_SETGET_STACK_FUNCS(super_block_group_root_level, struct btrfs_super_block, block_group_root_level, 8);BTRFS_SETGET_STACK_FUNCS (super_nr_global_roots ,struct btrfs_super_block , nr_global_roots, 64); +BTRFS_SETGET_STACK_FUNCS(super_reserved_bytes, struct btrfs_super_block, + reserved_bytes,32 );static inline unsigned long btrfs_leaf_data (struct extent_buffer *l) {
kernel-shared/disk-io.c +9 -0
@@ -1848,6 +1848,15 @@ int btrfs_check_super(struct btrfs_super_block *sb, unsigned sbflags) } } +if (btrfs_super_compat_ro_flags (sb) & +BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED && +btrfs_super_reserved_bytes (sb) <BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ) { +error ("reserved bytes invalid, has %u expect >= %llu" , +btrfs_super_reserved_bytes (sb), +BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ); + goto error_out; + } +if (btrfs_super_incompat_flags (sb) &BTRFS_FEATURE_INCOMPAT_METADATA_UUID ) metadata_uuid = sb->metadata_uuid;else
kernel-shared/volumes.c +4 -0
@@ -562,10 +562,14 @@ int btrfs_scan_one_device(int fd, const char *path,static u64 dev_extent_search_start (struct btrfs_device *device,u64 start) { +struct btrfs_fs_info *fs_info = device->fs_info;u64 zone_size;switch (device->fs_devices->chunk_alloc_policy) {case BTRFS_CHUNK_ALLOC_REGULAR : +if (btrfs_fs_compat_ro (fs_info,EXTRA_SUPER_RESERVED )) +return max_t (u64, start, +btrfs_super_reserved_bytes (fs_info->super_copy));/* * We don't want to overwrite the superblock on the drive nor * any area used by the boot loader (grub for example), so we
Signature · 1 line
2.36.1
PATCH 2/6 btrfs-progs: mkfs: add support for extra-super-reserved runtime flag
In reply to Qu WenruoThis allows mkfs to reserved extra 1MiB (2MiB in total).
The extra 1MiB should be large enough for either write-intent bitmap or full journal.
--- common/fsfeatures.c | 8 ++++++++ common/fsfeatures.h | 1 + mkfs/common.c | 16 ++++++++++++++++ mkfs/main.c | 9 +++++++++ 4 files changed, 34 insertions(+)
common/fsfeatures.c +8 -0
@@ -172,6 +172,14 @@ static const struct btrfs_feature runtime_features[] = {VERSION_TO_STRING2 (safe,4 ,9 ),VERSION_TO_STRING2 (default,5 ,15 ), .desc = "free space tree (space_cache=v2)" + }, { + .name ="extra-super-reserved" , + .flag = BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED, + .sysfs_name = "extra_super_reserved", +VERSION_TO_STRING2 (compat,6 ,0 ), +VERSION_NULL (safe), +VERSION_NULL (default), + .desc = "extra super block reserved space for each device" }, /* Keep this one last */ {
common/fsfeatures.h +1 -0
@@ -45,6 +45,7 @@#define BTRFS_RUNTIME_FEATURE_QUOTA (1ULL << 0)#define BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE (1ULL << 1) +#define BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED (1ULL << 2)void btrfs_list_all_fs_features (u64 mask_disallowed);void btrfs_list_all_runtime_features (u64 mask_disallowed);
mkfs/common.c +16 -0
@@ -314,6 +314,8 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE);bool extent_tree_v2 = !!(cfg->features &BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 ); +bool extra_super_reserved = !!(cfg->runtime_features & +BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED );/* Don't include the free space tree in the blocks to process. */ if (!free_space_tree)
@@ -324,6 +326,12 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) blocks_nr =ARRAY_SIZE (extent_tree_v2_blocks); add_block_group = false; } +/* +* The extra 1MiB should be enough for either write-intent bitmap or +* future full journal. +*/ +if (extra_super_reserved) + system_group_offset +=SZ_1M ;if ((cfg->features &BTRFS_FEATURE_INCOMPAT_ZONED )) { system_group_offset =zoned_system_group_offset (cfg->zone_size);
@@ -641,6 +649,14 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) goto out; } +if (extra_super_reserved) { +u64 ro_flags =btrfs_super_compat_ro_flags (&super) | +BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED ; + +btrfs_set_super_compat_ro_flags (&super, ro_flags); +btrfs_set_super_reserved_bytes (&super, system_group_offset); + } +if (extent_tree_v2) { ret = create_block_group_tree(fd, cfg, buf, system_group_offset,
mkfs/main.c +9 -0
@@ -1239,6 +1239,15 @@ int BOX_MAIN(mkfs)(int argc, char **argv) features |=BTRFS_FEATURE_INCOMPAT_ZONED ; } +/* +* Runtime extra-super-reserved feature conflicts with zoned support, +* as it's for regular devices explicitly. +*/ +if (zoned && (runtime_features & +BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED )) { +error ("extra-super-reserved runtime feature conflicts with zoned devices" ); +exit (1 ); + }/* * Set default profiles according to number of added devices. * For mixed groups defaults are single/single.
Signature · 1 line
2.36.1
PATCH 3/6 btrfs-progs: print-tree: remove duplicated definition for compat RO flags
In reply to Qu WenruoIn print_readable_compat_ro_flag(), we provide BTRFS_FEATURE_COMPAT_RO_SUPP | BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID for supported flags.
However BTRFS_FEATURE_COMPAT_RO_SUPP already includes the latter two flags.
Just remove the unnecessary flags.
t#
--- kernel-shared/print-tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel-shared/print-tree.c +1 -3
@@ -1754,9 +1754,7 @@ static void print_readable_compat_ro_flag(u64 flag)*/ return __print_readable_flag (flag, compat_ro_flags_array, compat_ro_flags_num, -BTRFS_FEATURE_COMPAT_RO_SUPP | -BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | -BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID ); +BTRFS_FEATURE_COMPAT_RO_SUPP ); }static void print_readable_incompat_flag (u64 flag)
Signature · 1 line
2.36.1
PATCH 4/6 btrfs-progs: print-tree: support btrfs_super_block::reserved_bytes
In reply to Qu WenruoThis only needs two things:
- Add readable flags for EXTRA_SUPER_RESERVED flag
- Add optional output for reserved_bytes
--- kernel-shared/print-tree.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel-shared/print-tree.c +6 -0
@@ -1668,6 +1668,7 @@ struct readable_flag_entry {static struct readable_flag_entry compat_ro_flags_array[] = {DEF_COMPAT_RO_FLAG_ENTRY (FREE_SPACE_TREE ),DEF_COMPAT_RO_FLAG_ENTRY (FREE_SPACE_TREE_VALID ), +DEF_COMPAT_RO_FLAG_ENTRY (EXTRA_SUPER_RESERVED ), };static const int compat_ro_flags_num =sizeof (compat_ro_flags_array) /sizeof (struct readable_flag_entry );
@@ -2051,6 +2052,11 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full)printf ("block_group_root_level\t%llu\n" , (unsigned long long )btrfs_super_block_group_root_level (sb)); +if (btrfs_super_compat_ro_flags (sb) & +BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED ) +printf ("reserved_bytes\t\t%u\n" , +btrfs_super_reserved_bytes (sb)); +uuid_unparse (sb->dev_item.uuid, buf);printf ("dev_item.uuid\t\t%s\n" , buf);
Signature · 1 line
2.36.1
PATCH 5/6 btrfs-progs: check: add extra warning for dev extents inside the reserved range
In reply to Qu WenruoSince kernel can handle it without problem, and we rely on balance to relocate those offending dev extents, we only need to output warning when such dev extents are detected.
--- check/main.c | 17 +++++++++++++++++ check/mode-lowmem.c | 22 ++++++++++++++++++++++ kernel-shared/ctree.h | 1 + 3 files changed, 40 insertions(+)
check/main.c +17 -0
@@ -8918,6 +8918,7 @@ static int check_dev_extents(void)struct btrfs_key key;struct btrfs_root *dev_root = gfs_info->dev_root;int ret; +u32 super_reserved =BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ;u64 prev_devid =0 ;u64 prev_dev_ext_end =0 ;
@@ -8927,6 +8928,10 @@ static int check_dev_extents(void) key.type =BTRFS_DEV_EXTENT_KEY ; key.offset =0 ; +if (btrfs_fs_compat_ro (gfs_info,EXTRA_SUPER_RESERVED ) && +btrfs_super_reserved_bytes (gfs_info->super_copy) >= super_reserved) + super_reserved =btrfs_super_reserved_bytes (gfs_info->super_copy); + ret =btrfs_search_slot (NULL , dev_root, &key, &path,0 ,0 );if (ret <0 ) { errno = -ret;
@@ -8983,6 +8988,13 @@ static int check_dev_extents(void) ret = -EUCLEAN ; goto out; } +if (physical_offset < super_reserved) { +warning ( +"dev extent devid %llu physical offset %llu is inside the reserved range (%u)" , + devid, physical_offset, + super_reserved); + gfs_info->found_dev_extents_in_reserved =1 ; + } prev_devid = devid; prev_dev_ext_end = physical_offset + physical_len;
@@ -8998,6 +9010,11 @@ static int check_dev_extents(void) } } out: +if (gfs_info->found_dev_extents_in_reserved) { +warning ("to relocate the dev extents in reserved range, mount the fs and run:" ); +warning ("\tbtrfs balance start -mdrange=0..%u -ddrange=0..%u -sdrange=0..%u" , + super_reserved, super_reserved, super_reserved); + }btrfs_release_path (&path);return ret; }
check/mode-lowmem.c +22 -0
@@ -4433,12 +4433,17 @@ static int check_dev_extent_item(struct extent_buffer *eb, int slot)struct btrfs_key devext_key;struct btrfs_chunk *chunk;struct extent_buffer *l; +u32 super_reserved =BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ;int num_stripes;u64 length;int i;int found_chunk =0 ;int ret; +if (btrfs_fs_compat_ro (gfs_info,EXTRA_SUPER_RESERVED ) && +btrfs_super_reserved_bytes (gfs_info->super_copy) >= super_reserved) + super_reserved =btrfs_super_reserved_bytes (gfs_info->super_copy); +btrfs_item_key_to_cpu (eb, &devext_key, slot); ptr = btrfs_item_ptr(eb, slot, struct btrfs_dev_extent); length =btrfs_dev_extent_length (eb, ptr);
@@ -4447,6 +4452,13 @@ static int check_dev_extent_item(struct extent_buffer *eb, int slot) chunk_key.type =BTRFS_CHUNK_ITEM_KEY ; chunk_key.offset =btrfs_dev_extent_chunk_offset (eb, ptr); +if (devext_key.offset < super_reserved) { +warning ( +"dev extent devid %llu physical offset %llu is inside the reserved range (%u)" , + devext_key.objectid, devext_key.offset, + super_reserved); + gfs_info->found_dev_extents_in_reserved =1 ; + }btrfs_init_path (&path); ret =btrfs_search_slot (NULL , chunk_root, &chunk_key, &path,0 ,0 );if (ret)
@@ -5526,9 +5538,14 @@ int check_chunks_and_extents_lowmem(void)struct btrfs_key key;struct btrfs_root *root;struct btrfs_root *cur_root; +u32 super_reserved =BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ;int err =0 ;int ret; +if (btrfs_fs_compat_ro (gfs_info,EXTRA_SUPER_RESERVED ) && +btrfs_super_reserved_bytes (gfs_info->super_copy) >= super_reserved) + super_reserved =btrfs_super_reserved_bytes (gfs_info->super_copy); + root = gfs_info->chunk_root; ret =check_btrfs_root (root,1 ); err |= ret;
@@ -5590,6 +5607,11 @@ out: total_used); err |=SUPER_BYTES_USED_ERROR ; } +if (gfs_info->found_dev_extents_in_reserved) { +warning ("to relocate the dev extents in reserved range, mount the fs and run:" ); +warning ("\tbtrfs balance start -mdrange=0..%u -ddrange=0..%u -sdrange=0..%u" , + super_reserved, super_reserved, super_reserved); + }if (repair) { ret =end_avoid_extents_overwrite ();
kernel-shared/ctree.h +1 -0
@@ -1271,6 +1271,7 @@ struct btrfs_fs_info { unsigned int finalize_on_close:1; unsigned int hide_names:1; unsigned int allow_transid_mismatch:1; + unsigned int found_dev_extents_in_reserved:1;int transaction_aborted;int force_csum_type;
Signature · 1 line
2.36.1
PATCH 6/6 btrfs-progs: introduce the experimental compat RO flag, WRITE_INTENT_BITMAP
In reply to Qu WenruoThis new compat RO flag will only be enabled through experimental features.
Since this feature has no real code implementation yet, only the following code changes are added:
- New super block check
To ensure WRITE_INTENT_BITMAP is enabled along with EXTRA_SUPER_RESERVED
- New compat RO flag readable string output
- New mkfs runtime features
--- common/fsfeatures.c | 11 +++++++++++ common/fsfeatures.h | 1 + kernel-shared/ctree.h | 15 +++++++++++++++ kernel-shared/disk-io.c | 9 +++++++++ kernel-shared/print-tree.c | 1 + mkfs/common.c | 9 +++++++++ mkfs/main.c | 5 +++++ 7 files changed, 51 insertions(+)
common/fsfeatures.c +11 -0
@@ -181,6 +181,17 @@ static const struct btrfs_feature runtime_features[] = { VERSION_NULL(default), .desc = "extra super block reserved space for each device" }, +#if EXPERIMENTAL + { + .name = "write-intent-bitmap", + .flag = BTRFS_RUNTIME_FEATURE_WRITE_INTENT_BITMAP, + .sysfs_name ="write_intent_bitmap" , +VERSION_NULL (compat), +VERSION_NULL (safe), +VERSION_NULL (default), + .desc = "write intent bitmap" + }, +#endif /* Keep this one last */ { .name = "list-all",
common/fsfeatures.h +1 -0
@@ -46,6 +46,7 @@#define BTRFS_RUNTIME_FEATURE_QUOTA (1ULL << 0)#define BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE (1ULL << 1)#define BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED (1ULL << 2) +#define BTRFS_RUNTIME_FEATURE_WRITE_INTENT_BITMAP (1ULL << 3)void btrfs_list_all_fs_features (u64 mask_disallowed);void btrfs_list_all_runtime_features (u64 mask_disallowed);
kernel-shared/ctree.h +15 -0
@@ -502,6 +502,13 @@ BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);*/ #define BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED (1ULL << 3) +/* +* Allow btrfs to have per-device write-intent bitmap. +* Will be utilized to close the RAID56 write-hole (by forced scrub for dirty +* partial written stripes at mount time). +*/ +#define BTRFS_FEATURE_COMPAT_RO_WRITE_INTENT_BITMAP (1ULL << 4) +#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
@@ -524,6 +531,13 @@ BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);#define BTRFS_FEATURE_COMPAT_SUPP 0ULL +#if EXPERIMENTAL +#define BTRFS_FEATURE_COMPAT_RO_SUPP \ + (BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | \ + BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID |\ + BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED | \ + BTRFS_FEATURE_COMPAT_RO_WRITE_INTENT_BITMAP) +#else /* * The FREE_SPACE_TREE and FREE_SPACE_TREE_VALID compat_ro bits must not be * added here until read-write support for the free space tree is implemented in
@@ -533,6 +547,7 @@ BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); (BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | \BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID |\ BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED) +#endif #if EXPERIMENTAL #define BTRFS_FEATURE_INCOMPAT_SUPP \
kernel-shared/disk-io.c +9 -0
@@ -1848,6 +1848,15 @@ int btrfs_check_super(struct btrfs_super_block *sb, unsigned sbflags) } } +if (btrfs_super_compat_ro_flags (sb) & +BTRFS_FEATURE_COMPAT_RO_WRITE_INTENT_BITMAP && + !(btrfs_super_compat_ro_flags (sb) & +BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED )) { +error ( +"write intent bitmap feature enabled without extra super reserved feature" ); + goto error_out; + } +if (btrfs_super_compat_ro_flags (sb) &BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED &&btrfs_super_reserved_bytes (sb) <BTRFS_BLOCK_RESERVED_1M_FOR_SUPER ) {
kernel-shared/print-tree.c +1 -0
@@ -1669,6 +1669,7 @@ static struct readable_flag_entry compat_ro_flags_array[] = {DEF_COMPAT_RO_FLAG_ENTRY (FREE_SPACE_TREE ),DEF_COMPAT_RO_FLAG_ENTRY (FREE_SPACE_TREE_VALID ),DEF_COMPAT_RO_FLAG_ENTRY (EXTRA_SUPER_RESERVED ), + DEF_COMPAT_RO_FLAG_ENTRY(WRITE_INTENT_BITMAP), };static const int compat_ro_flags_num =sizeof (compat_ro_flags_array) /sizeof (struct readable_flag_entry );
mkfs/common.c +9 -0
@@ -316,6 +316,8 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2);bool extra_super_reserved = !!(cfg->runtime_features &BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED ); +bool write_intent_bitmap = !!(cfg->runtime_features & +BTRFS_RUNTIME_FEATURE_WRITE_INTENT_BITMAP );/* Don't include the free space tree in the blocks to process. */ if (!free_space_tree)
@@ -657,6 +659,13 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)btrfs_set_super_reserved_bytes (&super, system_group_offset); } +if (write_intent_bitmap) { +u64 ro_flags =btrfs_super_compat_ro_flags (&super) | +BTRFS_FEATURE_COMPAT_RO_WRITE_INTENT_BITMAP ; + +btrfs_set_super_compat_ro_flags (&super, ro_flags); + } +if (extent_tree_v2) { ret = create_block_group_tree(fd, cfg, buf, system_group_offset,
mkfs/main.c +5 -0
@@ -1248,6 +1248,11 @@ int BOX_MAIN(mkfs)(int argc, char **argv)error ("extra-super-reserved runtime feature conflicts with zoned devices" );exit (1 ); } + +/* Write intent bitmap must has extra reserved space. */ +if (runtime_features &BTRFS_RUNTIME_FEATURE_WRITE_INTENT_BITMAP ) + runtime_features |=BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED ; +/* * Set default profiles according to number of added devices. * For mixed groups defaults are single/single.
Signature · 1 line
2.36.1