From patchwork Fri Nov 30 02:36:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1823441 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 4336F3FC5A for ; Fri, 30 Nov 2012 02:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755450Ab2K3ChI (ORCPT ); Thu, 29 Nov 2012 21:37:08 -0500 Received: from mga02.intel.com ([134.134.136.20]:8401 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754991Ab2K3ChF (ORCPT ); Thu, 29 Nov 2012 21:37:05 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 29 Nov 2012 18:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,189,1355126400"; d="scan'208";a="226945428" Received: from zyan5-mobl.sh.intel.com ([10.239.36.120]) by orsmga001.jf.intel.com with ESMTP; 29 Nov 2012 18:37:04 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH 5/5] mds: compare sessionmap version before replaying imported sessions Date: Fri, 30 Nov 2012 10:36:54 +0800 Message-Id: <1354243014-21072-6-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1354243014-21072-1-git-send-email-zheng.z.yan@intel.com> References: <1354243014-21072-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" Otherwise we may wrongly increase mds->sessionmap.version, which will confuse future journal replays that involving sessionmap. Signed-off-by: Yan, Zheng --- src/mds/Server.cc | 2 ++ src/mds/events/EUpdate.h | 8 ++++++-- src/mds/journal.cc | 24 +++++++++++++++++------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 2c59f25..a10c503 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -5425,6 +5425,8 @@ void Server::handle_client_rename(MDRequest *mdr) } _rename_prepare(mdr, &le->metablob, &le->client_map, srcdn, destdn, straydn); + if (le->client_map.length()) + le->cmapv = mds->sessionmap.projected; // -- commit locally -- C_MDS_rename_finish *fin = new C_MDS_rename_finish(mds, mdr, srcdn, destdn, straydn); diff --git a/src/mds/events/EUpdate.h b/src/mds/events/EUpdate.h index 6ce18fe..a302a5a 100644 --- a/src/mds/events/EUpdate.h +++ b/src/mds/events/EUpdate.h @@ -23,13 +23,14 @@ public: EMetaBlob metablob; string type; bufferlist client_map; + version_t cmapv; metareqid_t reqid; bool had_slaves; EUpdate() : LogEvent(EVENT_UPDATE) { } EUpdate(MDLog *mdlog, const char *s) : LogEvent(EVENT_UPDATE), metablob(mdlog), - type(s), had_slaves(false) { } + type(s), cmapv(0), had_slaves(false) { } void print(ostream& out) { if (type.length()) @@ -38,12 +39,13 @@ public: } void encode(bufferlist &bl) const { - __u8 struct_v = 2; + __u8 struct_v = 3; ::encode(struct_v, bl); ::encode(stamp, bl); ::encode(type, bl); ::encode(metablob, bl); ::encode(client_map, bl); + ::encode(cmapv, bl); ::encode(reqid, bl); ::encode(had_slaves, bl); } @@ -55,6 +57,8 @@ public: ::decode(type, bl); ::decode(metablob, bl); ::decode(client_map, bl); + if (struct_v >= 3) + ::decode(cmapv, bl); ::decode(reqid, bl); ::decode(had_slaves, bl); } diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 04b1a92..3f6d5eb 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -999,14 +999,24 @@ void EUpdate::replay(MDS *mds) mds->mdcache->add_uncommitted_master(reqid, _segment, slaves); } - // open client sessions? - map cm; - map seqm; if (client_map.length()) { - bufferlist::iterator blp = client_map.begin(); - ::decode(cm, blp); - mds->server->prepare_force_open_sessions(cm, seqm); - mds->server->finish_force_open_sessions(cm, seqm); + if (mds->sessionmap.version >= cmapv) { + dout(10) << "EUpdate.replay sessionmap v " << cmapv + << " <= table " << mds->sessionmap.version << dendl; + } else { + dout(10) << "EUpdate.replay sessionmap " << mds->sessionmap.version + << " < " << cmapv << dendl; + // open client sessions? + map cm; + map seqm; + bufferlist::iterator blp = client_map.begin(); + ::decode(cm, blp); + mds->server->prepare_force_open_sessions(cm, seqm); + mds->server->finish_force_open_sessions(cm, seqm); + + assert(mds->sessionmap.version = cmapv); + mds->sessionmap.projected = mds->sessionmap.version; + } } }