From patchwork Thu Nov 13 01:36:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 5293341 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 249269F2F1 for ; Thu, 13 Nov 2014 01:38:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47210201F2 for ; Thu, 13 Nov 2014 01:38:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6210C201EF for ; Thu, 13 Nov 2014 01:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753737AbaKMBiA (ORCPT ); Wed, 12 Nov 2014 20:38:00 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:14787 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753723AbaKMBh7 (ORCPT ); Wed, 12 Nov 2014 20:37:59 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="43306028" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Nov 2014 09:34:46 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sAD1biIk026712 for ; Thu, 13 Nov 2014 09:37:45 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 13 Nov 2014 09:38:08 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH] btrfs-progs: use canonical name for device in btrfs fi show when mounted Date: Thu, 13 Nov 2014 09:36:20 +0800 Message-ID: <1415842580-2430-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] 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=ham 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 When using lvm volumes to check fstests: btrfs/006, it fails like: Label: 'TestLabel.006' uuid: Total devices FS bytes used devid size used path SCRATCH_DEV + devid size used path /dev/dm-4 + devid size used path /dev/dm-5 + devid size used path /dev/dm-6 The /dev/dm-* points to lvm volumes, use @canonicalize_path() to convert them and we will make it through. Of course we should do the same thing for dev stat. Signed-off-by: Gui Hecheng --- cmds-device.c | 16 +++++++++++----- cmds-filesystem.c | 7 ++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cmds-device.c b/cmds-device.c index 9323986..6cd41e1 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -408,31 +408,37 @@ static int cmd_dev_stats(int argc, char **argv) path, strerror(errno)); err = 1; } else { + char *canonical_path; + + canonical_path = canonicalize_path((char *)path); + if (args.nr_items >= BTRFS_DEV_STAT_WRITE_ERRS + 1) printf("[%s].write_io_errs %llu\n", - path, + canonical_path, (unsigned long long) args.values[ BTRFS_DEV_STAT_WRITE_ERRS]); if (args.nr_items >= BTRFS_DEV_STAT_READ_ERRS + 1) printf("[%s].read_io_errs %llu\n", - path, + canonical_path, (unsigned long long) args.values[ BTRFS_DEV_STAT_READ_ERRS]); if (args.nr_items >= BTRFS_DEV_STAT_FLUSH_ERRS + 1) printf("[%s].flush_io_errs %llu\n", - path, + canonical_path, (unsigned long long) args.values[ BTRFS_DEV_STAT_FLUSH_ERRS]); if (args.nr_items >= BTRFS_DEV_STAT_CORRUPTION_ERRS + 1) printf("[%s].corruption_errs %llu\n", - path, + canonical_path, (unsigned long long) args.values[ BTRFS_DEV_STAT_CORRUPTION_ERRS]); if (args.nr_items >= BTRFS_DEV_STAT_GENERATION_ERRS + 1) printf("[%s].generation_errs %llu\n", - path, + canonical_path, (unsigned long long) args.values[ BTRFS_DEV_STAT_GENERATION_ERRS]); + + free(canonical_path); } } diff --git a/cmds-filesystem.c b/cmds-filesystem.c index e4b2785..cd6b3c6 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -510,7 +510,10 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, pretty_size(calc_used_bytes(space_info))); for (i = 0; i < fs_info->num_devices; i++) { + char *canonical_path; + tmp_dev_info = (struct btrfs_ioctl_dev_info_args *)&dev_info[i]; + canonical_path = canonicalize_path((char *)tmp_dev_info->path); /* Add check for missing devices even mounted */ fd = open((char *)tmp_dev_info->path, O_RDONLY); @@ -523,7 +526,9 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, tmp_dev_info->devid, pretty_size(tmp_dev_info->total_bytes), pretty_size(tmp_dev_info->bytes_used), - tmp_dev_info->path); + canonical_path); + + free(canonical_path); } if (missing)