From patchwork Tue Apr 29 15:57:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 4088191 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69620BFF02 for ; Tue, 29 Apr 2014 15:57:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9925A201E7 for ; Tue, 29 Apr 2014 15:57:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC863201C0 for ; Tue, 29 Apr 2014 15:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757859AbaD2P5F (ORCPT ); Tue, 29 Apr 2014 11:57:05 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57197 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757634AbaD2P5D (ORCPT ); Tue, 29 Apr 2014 11:57:03 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C7E7FAC4F for ; Tue, 29 Apr 2014 15:57:02 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 91913DA935; Tue, 29 Apr 2014 17:57:02 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 01/14] btrfs-progs: read global reserve size from space infos Date: Tue, 29 Apr 2014 17:57:01 +0200 Message-Id: X-Mailer: git-send-email 1.9.0 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- ctree.h | 6 ++++++ utils.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ctree.h b/ctree.h index 8ac17619b9dc..5c43fc5f5f6e 100644 --- a/ctree.h +++ b/ctree.h @@ -862,6 +862,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 diff --git a/utils.c b/utils.c index f2ab416c28b2..ca150404ea6f 100644 --- a/utils.c +++ b/utils.c @@ -2240,7 +2240,10 @@ u64 get_partition_size(char *dev) */ const 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: @@ -2249,6 +2252,8 @@ const 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"; }