btrfs-progs: read global reserve size from space infos
authorDavid Sterba <dsterba@suse.cz>
Tue, 29 Apr 2014 15:57:01 +0000 (17:57 +0200)
committerDavid Sterba <dsterba@suse.cz>
Thu, 28 Aug 2014 00:03:33 +0000 (02:03 +0200)
Kernels >= 3.15 export the global block reserve as a space info presented
by 'btrfs fi df' but would display 'unknown' instead of some meaningful
string.

Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-filesystem.c
ctree.h

index 7e8ca95052e921a3230e8045b868f5dc444c3f96..0301442f57caf2c071390f0b5538a216a1d881a8 100644 (file)
@@ -120,7 +120,10 @@ static const char * const cmd_df_usage[] = {
 
 static char *group_type_str(u64 flag)
 {
-       switch (flag & BTRFS_BLOCK_GROUP_TYPE_MASK) {
+       u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
+               BTRFS_SPACE_INFO_GLOBAL_RSV;
+
+       switch (flag & mask) {
        case BTRFS_BLOCK_GROUP_DATA:
                return "Data";
        case BTRFS_BLOCK_GROUP_SYSTEM:
@@ -129,6 +132,8 @@ static char *group_type_str(u64 flag)
                return "Metadata";
        case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
                return "Data+Metadata";
+       case BTRFS_SPACE_INFO_GLOBAL_RSV:
+               return "GlobalReserve";
        default:
                return "unknown";
        }
diff --git a/ctree.h b/ctree.h
index 6fa1ca69f9f8298bf38b68856de5d82a28b06b01..93b8585129251140bbf38e183840a741b7c869d9 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -860,6 +860,12 @@ struct btrfs_csum_item {
 /* used in struct btrfs_balance_args fields */
 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE   (1ULL << 48)
 
+/*
+ * GLOBAL_RSV does not exist as a on-disk block group type and is used
+ * internally for exporting info about global block reserve from space infos
+ */
+#define BTRFS_SPACE_INFO_GLOBAL_RSV    (1ULL << 49)
+
 #define BTRFS_QGROUP_STATUS_OFF                        0
 #define BTRFS_QGROUP_STATUS_ON                 1
 #define BTRFS_QGROUP_STATUS_SCANNING           2