From patchwork Tue Dec 11 08:30:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1861191 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 10D463FCA5 for ; Tue, 11 Dec 2012 08:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546Ab2LKIbO (ORCPT ); Tue, 11 Dec 2012 03:31:14 -0500 Received: from mga11.intel.com ([192.55.52.93]:16602 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173Ab2LKIbN (ORCPT ); Tue, 11 Dec 2012 03:31:13 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 11 Dec 2012 00:31:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,256,1355126400"; d="scan'208";a="262275489" Received: from zyan5-mobl.sh.intel.com ([10.239.36.25]) by fmsmga002.fm.intel.com with ESMTP; 11 Dec 2012 00:31:11 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH 09/14] mds: take export lock set before sending MExportDirDiscover Date: Tue, 11 Dec 2012 16:30:55 +0800 Message-Id: <1355214660-26354-10-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1355214660-26354-1-git-send-email-zheng.z.yan@intel.com> References: <1355214660-26354-1-git-send-email-zheng.z.yan@intel.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: "Yan, Zheng" Migrator::export_dir() only check if it can lock the export lock set but not take the lock set. So someone else can change the path to the exporting dir and confuse Migrator::handle_export_discover(). Signed-off-by: Yan, Zheng --- src/mds/Migrator.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index c157279..5db21cd 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -236,6 +236,8 @@ void Migrator::handle_mds_failure_or_stop(int who) dir->unfreeze_tree(); // cancel the freeze dir->auth_unpin(this); export_state.erase(dir); // clean up + export_unlock(dir); + export_locks.erase(dir); dir->state_clear(CDir::STATE_EXPORTING); if (export_peer[dir] != who) // tell them. mds->send_message_mds(new MExportDirCancel(dir->dirfrag()), export_peer[dir]); @@ -663,6 +665,8 @@ void Migrator::export_dir(CDir *dir, int dest) dout(7) << "export_dir can't rdlock needed locks, failing." << dendl; return; } + mds->locker->rdlock_take_set(locks); + export_locks[dir].swap(locks); // ok. assert(export_state.count(dir) == 0); @@ -705,6 +709,9 @@ void Migrator::handle_export_discover_ack(MExportDirDiscoverAck *m) export_peer[dir] != m->get_source().num()) { dout(7) << "must have aborted" << dendl; } else { + // release locks to avoid deadlock + export_unlock(dir); + export_locks.erase(dir); // freeze the subtree export_state[dir] = EXPORT_FREEZING; dir->auth_unpin(this);