Thread (3 messages) 3 messages, 3 authors, 2021-11-02

Re: [PATCH] btrfs-progs: fix btrfs_group_profile_str regression

From: Qu Wenruo <hidden>
Date: 2021-11-02 10:42:50


On 2021/10/30 22:36, Wang Yugui wrote:
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.
That also unified kernel uapi and progs headers' definition of
BTRFS_BLOCK_GROUP_RESERVED.
Fixes: dad03fac3bb8 ("btrfs-progs: switch btrfs_group_profile_str to use raid table")
Signed-off-by: Wang Yugui <redacted>
Revewed-by: Qu Wenruo [off-list ref]

Thanks,
Qu
quoted hunk ↗ jump to hunk
---
  common/utils.c        | 2 +-
  kernel-shared/ctree.h | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/utils.c b/common/utils.c
index aee0eedc..e8744199 100644
--- a/common/utils.c
+++ b/common/utils.c
@@ -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";
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 563ea50b..99ebc3ad 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -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,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help