From patchwork Thu Nov 22 07:48:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1788161 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 ACD073FC64 for ; Thu, 22 Nov 2012 20:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754618Ab2KVTOW (ORCPT ); Thu, 22 Nov 2012 14:14:22 -0500 Received: from mga09.intel.com ([134.134.136.24]:26772 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756556Ab2KVTON (ORCPT ); Thu, 22 Nov 2012 14:14:13 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 Nov 2012 23:48:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,298,1352102400"; d="scan'208";a="245703786" Received: from fhe5-mobl.ccr.corp.intel.com (HELO zyan5-mobl.sh.intel.com) ([10.239.36.12]) by orsmga002.jf.intel.com with ESMTP; 21 Nov 2012 23:48:49 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH] mds: fix CDir::_commit_partial() bug Date: Thu, 22 Nov 2012 15:48:47 +0800 Message-Id: <1353570527-10834-1-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.7 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: "Yan, Zheng" When a null dentry is encountered, CDir::_commit_partial() adds a OSD_TMAP_RM command to delete the dentry. But if the dentry is new, the osd will not find the dentry when handling the command and the tmap update operation will fail totally. Signed-off-by: Yan, Zheng --- src/mds/CDir.cc | 17 +++++++++-------- src/mds/CDir.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index c5220ed..4896f01 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1696,7 +1696,7 @@ class C_Dir_Committed : public Context { public: C_Dir_Committed(CDir *d, version_t v, version_t lrv) : dir(d), version(v), last_renamed_version(lrv) { } void finish(int r) { - dir->_committed(version, last_renamed_version); + dir->_committed(version, last_renamed_version, r); } }; @@ -1801,14 +1801,14 @@ CDir::map_t::iterator CDir::_commit_partial(ObjectOperation& m, if (!dn->is_dirty()) continue; // skip clean dentries - if (dn->get_linkage()->is_null()) { - dout(10) << " rm " << dn->name << " " << *dn << dendl; - finalbl.append(CEPH_OSD_TMAP_RM); - dn->key().encode(finalbl); - } else { + if (!dn->get_linkage()->is_null()) { dout(10) << " set " << dn->name << " " << *dn << dendl; finalbl.append(CEPH_OSD_TMAP_SET); _encode_dentry(dn, finalbl, snaps); + } else if (!dn->is_new()) { + dout(10) << " rm " << dn->name << " " << *dn << dendl; + finalbl.append(CEPH_OSD_TMAP_RM); + dn->key().encode(finalbl); } } @@ -1997,10 +1997,11 @@ void CDir::_commit(version_t want) * * @param v version i just committed */ -void CDir::_committed(version_t v, version_t lrv) +void CDir::_committed(version_t v, version_t lrv, int ret) { - dout(10) << "_committed v " << v << " (last renamed " << lrv << ") on " << *this << dendl; + dout(10) << "_committed ret " << ret << " v " << v << " (last renamed " << lrv << ") on " << *this << dendl; assert(is_auth()); + assert(ret == 0); bool stray = inode->is_stray(); diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 2222418..274e38b 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -487,7 +487,7 @@ private: unsigned max_write_size=-1, map_t::iterator last_committed_dn=map_t::iterator()); void _encode_dentry(CDentry *dn, bufferlist& bl, const set *snaps); - void _committed(version_t v, version_t last_renamed_version); + void _committed(version_t v, version_t last_renamed_version, int ret); void wait_for_commit(Context *c, version_t v=0); // -- dirtyness --