From patchwork Thu Mar 31 07:59:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Zhong X-Patchwork-Id: 678691 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2V8u9HS020509 for ; Thu, 31 Mar 2011 08:56:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933142Ab1CaI4D (ORCPT ); Thu, 31 Mar 2011 04:56:03 -0400 Received: from mga09.intel.com ([134.134.136.24]:27142 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933134Ab1CaI4C (ORCPT ); Thu, 31 Mar 2011 04:56:02 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 31 Mar 2011 01:56:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.63,274,1299484800"; d="scan'208";a="727364546" Received: from zhongxin-desktop.bj.intel.com (HELO localhost.localdomain) ([10.238.154.195]) by orsmga001.jf.intel.com with ESMTP; 31 Mar 2011 01:56:00 -0700 From: "Zhong, Xin" To: linux-btrfs@vger.kernel.org Cc: xin.zhong@intel.com Subject: [PATCH] Btrfs: fix subvolume mount by name problem when default mount subvolume is set Date: Thu, 31 Mar 2011 15:59:22 +0800 Message-Id: <1301558362-2650-1-git-send-email-xin.zhong@intel.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 31 Mar 2011 08:56:09 +0000 (UTC) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index db0a827..138bc4c 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -786,15 +786,18 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, s->s_flags |= MS_ACTIVE; } - root = get_default_root(s, subvol_objectid); - if (IS_ERR(root)) { - error = PTR_ERR(root); - deactivate_locked_super(s); - goto error_free_subvol_name; - } /* if they gave us a subvolume name bind mount into that */ if (strcmp(subvol_name, ".")) { struct dentry *new_root; + + /* we search subvolume name in the btrfs root, not the default mount subvolume */ + root = get_default_root(s, BTRFS_FS_TREE_OBJECTID); + if (IS_ERR(root)) { + error = PTR_ERR(root); + deactivate_locked_super(s); + goto error_free_subvol_name; + } + mutex_lock(&root->d_inode->i_mutex); new_root = lookup_one_len(subvol_name, root, strlen(subvol_name)); @@ -816,6 +819,14 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, dput(root); root = new_root; } + else { + root = get_default_root(s, subvol_objectid); + if (IS_ERR(root)) { + error = PTR_ERR(root); + deactivate_locked_super(s); + goto error_free_subvol_name; + } + } mnt->mnt_sb = s; mnt->mnt_root = root;