From patchwork Thu Jan 9 12:42:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 3459891 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 E3334C02DC for ; Thu, 9 Jan 2014 12:43:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 594482012E for ; Thu, 9 Jan 2014 12:43:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 083B520121 for ; Thu, 9 Jan 2014 12:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751671AbaAIMnU (ORCPT ); Thu, 9 Jan 2014 07:43:20 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:40969 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751321AbaAIMnS (ORCPT ); Thu, 9 Jan 2014 07:43:18 -0500 X-IronPort-AV: E=Sophos;i="4.95,630,1384272000"; d="scan'208";a="9396295" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 09 Jan 2014 20:39:35 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s09ChCrj031211; Thu, 9 Jan 2014 20:43:12 +0800 Received: from wangs.fnst.cn.fujitsu.com ([10.167.226.104]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014010920420868-954230 ; Thu, 9 Jan 2014 20:42:08 +0800 From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: alex@bpmit.com Subject: [PATCH] Btrfs-progs: fix to make list specified directory's subvolumes work Date: Thu, 9 Jan 2014 20:42:12 +0800 Message-Id: <1389271332-12897-1-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/09 20:42:08, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/09 20:42:09, Serialize complete at 2014/01/09 20:42:09 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.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 Steps to reproduce: # mkfs.btrfs -f /dev/sda8 # mount /dev/sda8 /mnt # mkdir /mnt/subvolumes # btrfs sub create /mnt/subvolumes/subv1 # btrfs sub create /mnt/subvolumes/subv1/subv1.1 # btrfs sub list -o /mnt/subvolumes/subv1 <----we did not list anything The problem is that we don't set @top_id right, fix it. Reported-by: Alex Signed-off-by: Wang Shilong --- btrfs-list.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/btrfs-list.c b/btrfs-list.c index fa69910..9effb27 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -578,23 +578,18 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri, full_path = strdup(found->path); len = add_len; } + if (!ri->top_id) + ri->top_id = found->ref_tree; next = found->ref_tree; - - if (next == top_id) { - ri->top_id = top_id; + if (next == top_id) break; - } - /* * if the ref_tree = BTRFS_FS_TREE_OBJECTID, * we are at the top */ - if (next == BTRFS_FS_TREE_OBJECTID) { - ri->top_id = next; + if (next == BTRFS_FS_TREE_OBJECTID) break; - } - /* * if the ref_tree wasn't in our tree of roots, the * subvolume was deleted.