From patchwork Tue Mar 29 14:27:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 8687741 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33B53C0553 for ; Tue, 29 Mar 2016 14:28:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F3A3201FE for ; Tue, 29 Mar 2016 14:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCB4420160 for ; Tue, 29 Mar 2016 14:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756498AbcC2O1t (ORCPT ); Tue, 29 Mar 2016 10:27:49 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:51009 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756368AbcC2O1s (ORCPT ); Tue, 29 Mar 2016 10:27:48 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2TERZLD019176 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Mar 2016 14:27:35 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u2TERZEi004761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Mar 2016 14:27:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u2TERYkL005602; Tue, 29 Mar 2016 14:27:34 GMT Received: from arch2.sg.oracle.com (/10.186.101.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Mar 2016 07:27:34 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: clm@fb.com, dsterba@suse.cz Subject: [PATCH 4/4] btrfs-progs: add global spare device list to filesystem show Date: Tue, 29 Mar 2016 22:27:21 +0800 Message-Id: <1459261641-32254-4-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1459261641-32254-1-git-send-email-anand.jain@oracle.com> References: <1459261349-32206-1-git-send-email-anand.jain@oracle.com> <1459261641-32254-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] 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.9 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 This patch will add list of spare devices to the filesystem show output, as show in the example below. btrfs fi show Label: none uuid: 17f7d403-17d7-4f0a-b8ba-de673fdd3f56 Total devices 2 FS bytes used 15.88MiB devid 1 size 2.00GiB used 417.50MiB path /dev/sdc devid 2 size 2.00GiB used 417.50MiB path /dev/sdd Global spare device size 3.00GiB path /dev/sde btrfs-progs v4.2.3-12-gb5f4b68 Signed-off-by: Anand Jain --- cmds-filesystem.c | 5 +++++ utils.h | 1 + 2 files changed, 6 insertions(+) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 0901c47e8679..78e5eba624dd 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -903,6 +903,11 @@ devs_only: struct btrfs_fs_devices, list); free_fs_devices(fs_devices); } + + if (where == -1 && search == NULL) { + ret = print_spare_device(unit_mode); + printf("\n"); + } out: free_seen_fsid(); return ret; diff --git a/utils.h b/utils.h index ff5966d11913..ea54692aca86 100644 --- a/utils.h +++ b/utils.h @@ -280,6 +280,7 @@ const char *get_argv0_buf(void); unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode); void clean_args_no_options(int argc, char *argv[], const char * const *usage); int string_is_numerical(const char *str); +int print_spare_device(unsigned unit_mode); __attribute__ ((format (printf, 1, 2))) static inline void warning(const char *fmt, ...)