From patchwork Mon Nov 19 02:43:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1762111 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 7C34A3FCF7 for ; Mon, 19 Nov 2012 02:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752849Ab2KSCnz (ORCPT ); Sun, 18 Nov 2012 21:43:55 -0500 Received: from mga11.intel.com ([192.55.52.93]:27822 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752841Ab2KSCny (ORCPT ); Sun, 18 Nov 2012 21:43:54 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Nov 2012 18:43:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,275,1352102400"; d="scan'208";a="251134073" Received: from zyan5-mobl.sh.intel.com ([10.239.36.18]) by fmsmga002.fm.intel.com with ESMTP; 18 Nov 2012 18:43:52 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH 02/16] mds: fix anchor table update Date: Mon, 19 Nov 2012 10:43:34 +0800 Message-Id: <1353293028-15238-3-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1353293028-15238-1-git-send-email-zheng.z.yan@intel.com> References: <1353293028-15238-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" The reference count of an anchor table entry that corresponds to directory is number of anchored inodes under the directory. But when updating anchor trace for an directory inode, the code only increases/decreases its new/old ancestor anchor table entries' reference counts by one. This patch probably resolves BUG #1850. Signed-off-by: Yan, Zheng --- src/mds/AnchorServer.cc | 13 +++++++------ src/mds/AnchorServer.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc index 731ec96..cd2e625 100644 --- a/src/mds/AnchorServer.cc +++ b/src/mds/AnchorServer.cc @@ -73,7 +73,7 @@ bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash, return true; } -void AnchorServer::inc(inodeno_t ino) +void AnchorServer::inc(inodeno_t ino, int ref) { dout(7) << "inc " << ino << dendl; @@ -81,7 +81,7 @@ void AnchorServer::inc(inodeno_t ino) while (1) { Anchor &anchor = anchor_map[ino]; - anchor.nref++; + anchor.nref += ref; anchor.updated = version; dout(10) << "inc now " << anchor << dendl; @@ -92,14 +92,14 @@ void AnchorServer::inc(inodeno_t ino) } } -void AnchorServer::dec(inodeno_t ino) +void AnchorServer::dec(inodeno_t ino, int ref) { dout(7) << "dec " << ino << dendl; assert(anchor_map.count(ino)); while (true) { Anchor &anchor = anchor_map[ino]; - anchor.nref--; + anchor.nref -= ref; anchor.updated = version; if (anchor.nref == 0) { @@ -186,13 +186,14 @@ void AnchorServer::_commit(version_t tid) if (anchor_map.count(ino)) { dout(7) << "commit " << tid << " update " << ino << dendl; + int ref = anchor_map[ino].nref; // remove old - dec(ino); + dec(ino, ref); // add new for (unsigned i=0; i