Skip to contentSkip to conversation

btrfs-progs: fix btrfs_group_profile_str regression

PATCH In review Wang Yugui 3 participants 3 messages Oct 30, 2021 – Nov 2, 2021 Btrfs file system

lore
Share & tools
lore

Wang Yugui

author
#0 lore raw

PATCH 1/1 btrfs-progs: fix btrfs_group_profile_str regression

dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table") introduced a regression that raid profile of GlobalReserve will be output as 'unknown'.

 $ btrfs filesystem df /mnt/test
 Data, single: total=5.02TiB, used=4.98TiB
 System, single: total=4.00MiB, used=624.00KiB
 Metadata, single: total=11.01GiB, used=6.94GiB
 GlobalReserve, unknown: total=512.00MiB, used=0.00B

fix it by
- add the process of BTRFS_BLOCK_GROUP_RESERVED
- fix the define of BTRFS_BLOCK_GROUP_RESERVED too.

Fixes dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table")
---
 common/utils.c        | 2 +-
 kernel-shared/ctree.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
common/utils.c +1 -1
index aee0eedc..e8744199 100644
@@ -1030,7 +1030,7 @@ const char* btrfs_group_profile_str(u64 flag)
 {
 	int index;
 
-	flag &= ~BTRFS_BLOCK_GROUP_TYPE_MASK;
+	flag &= ~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_RESERVED);
 	if (flag & ~BTRFS_BLOCK_GROUP_PROFILE_MASK)
 		return "unknown";
 
kernel-shared/ctree.h +2 -1
index 563ea50b..99ebc3ad 100644
@@ -972,7 +972,8 @@ struct btrfs_csum_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_RESERVED	BTRFS_AVAIL_ALLOC_BIT_SINGLE
+#define BTRFS_BLOCK_GROUP_RESERVED	(BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
+					 BTRFS_SPACE_INFO_GLOBAL_RSV)
 
 enum btrfs_raid_types {
 	BTRFS_RAID_RAID10,
Signature · 1 line
2.32.0
#1 lore raw
Quoted 10 lines · Wang Yugui

dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table") introduced a regression that raid profile of GlobalReserve will be output as 'unknown'.

  $ btrfs filesystem df /mnt/test
  Data, single: total=5.02TiB, used=4.98TiB
  System, single: total=4.00MiB, used=624.00KiB
  Metadata, single: total=11.01GiB, used=6.94GiB
  GlobalReserve, unknown: total=512.00MiB, used=0.00B
Quoted 3 lines

fix it by
- add the process of BTRFS_BLOCK_GROUP_RESERVED
- fix the define of BTRFS_BLOCK_GROUP_RESERVED too.

That also unified kernel uapi and progs headers' definition of BTRFS_BLOCK_GROUP_RESERVED.

Quoted 3 lines
Fixes dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table")

Thanks,
Qu

Quoted 34 lines
---
  common/utils.c        | 2 +-
  kernel-shared/ctree.h | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)
common/utils.c +1 -1
index aee0eedc..e8744199 100644
@@ -1030,7 +1030,7 @@ const char* btrfs_group_profile_str(u64 flag)
  {
  	int index;
 
-	flag &= ~BTRFS_BLOCK_GROUP_TYPE_MASK;
+	flag &= ~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_RESERVED);
  	if (flag & ~BTRFS_BLOCK_GROUP_PROFILE_MASK)
  		return "unknown";
 
kernel-shared/ctree.h +2 -1
index 563ea50b..99ebc3ad 100644
@@ -972,7 +972,8 @@ struct btrfs_csum_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_RESERVED	BTRFS_AVAIL_ALLOC_BIT_SINGLE
+#define BTRFS_BLOCK_GROUP_RESERVED	(BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
+					 BTRFS_SPACE_INFO_GLOBAL_RSV)
 
  enum btrfs_raid_types {
  	BTRFS_RAID_RAID10,
#2 lore raw
In reply to Wang Yugui
Quoted 10 lines · Wang Yugui

dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table") introduced a regression that raid profile of GlobalReserve will be output as 'unknown'.

 $ btrfs filesystem df /mnt/test
 Data, single: total=5.02TiB, used=4.98TiB
 System, single: total=4.00MiB, used=624.00KiB
 Metadata, single: total=11.01GiB, used=6.94GiB
 GlobalReserve, unknown: total=512.00MiB, used=0.00B
Quoted 6 lines

fix it by
- add the process of BTRFS_BLOCK_GROUP_RESERVED
- fix the define of BTRFS_BLOCK_GROUP_RESERVED too.

Fixes dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table")

Added to devel, thanks.