From patchwork Wed Sep 19 07:52:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1476221 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A6420DF238 for ; Wed, 19 Sep 2012 07:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752255Ab2ISHwk (ORCPT ); Wed, 19 Sep 2012 03:52:40 -0400 Received: from mga02.intel.com ([134.134.136.20]:48196 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752217Ab2ISHwj (ORCPT ); Wed, 19 Sep 2012 03:52:39 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 19 Sep 2012 00:52:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,447,1344236400"; d="scan'208";a="207679995" Received: from zyan5-mobl.sh.intel.com ([10.239.36.142]) by orsmga002.jf.intel.com with ESMTP; 19 Sep 2012 00:52:38 -0700 From: "Yan, Zheng" To: sage@inktank.com, ceph-devel@vger.kernel.org Cc: "Yan, Zheng" Subject: [PATCH] mds: Clean up finished two phase commits Date: Wed, 19 Sep 2012 15:52:36 +0800 Message-Id: <1348041156-2990-1-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.4 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: "Yan, Zheng" When handling master request with slaves, the mds could crash after receiving all slaves' commit acknowledgement, but before journalling the ECommitted. Current MDS recovery code does not handle this case correctly, the request will be left in LogSegment's uncommitted_masters after recovery is finished. It prevents LogSegment from being trimmed. The fix is find and clean up request of this kind when recovery enters rejoin stage. Signed-off-by: Yan, Zheng --- src/mds/MDCache.cc | 18 ++++++++++++++++++ src/mds/MDCache.h | 1 + src/mds/MDS.cc | 1 + 3 files changed, 20 insertions(+) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 9ac7a62..da3affb 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -2163,6 +2163,24 @@ void MDCache::committed_master_slave(metareqid_t r, int from) } +/* + * The mds could crash after receiving all slaves' commit acknowledgement, + * but before journalling the ECommitted. + */ +void MDCache::finish_committed_masters() +{ + map::iterator p = uncommitted_masters.begin(); + while (p != uncommitted_masters.end()) { + if (p->second.slaves.empty()) { + metareqid_t reqid = p->first; + dout(10) << "finish_committed_masters " << reqid << dendl; + ++p; + log_master_commit(reqid); + } else { + ++p; + } + } +} /* * at end of resolve... we must journal a commit|abort for all slave diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 9c7b096..12bdb03 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -291,6 +291,7 @@ public: void log_master_commit(metareqid_t reqid); void _logged_master_commit(metareqid_t reqid, LogSegment *ls, list &waiters); void committed_master_slave(metareqid_t r, int from); + void finish_committed_masters(); void _logged_slave_commit(int from, metareqid_t reqid); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index ce306c4..d0aac30 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1413,6 +1413,7 @@ void MDS::reconnect_done() void MDS::rejoin_joint_start() { dout(1) << "rejoin_joint_start" << dendl; + mdcache->finish_committed_masters(); mdcache->rejoin_send_rejoins(); } void MDS::rejoin_done()