From patchwork Fri Aug 23 01:42:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 2848490 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7C5929F271 for ; Fri, 23 Aug 2013 01:42:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F205202FE for ; Fri, 23 Aug 2013 01:42:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A947820284 for ; Fri, 23 Aug 2013 01:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211Ab3HWBmg (ORCPT ); Thu, 22 Aug 2013 21:42:36 -0400 Received: from mga03.intel.com ([143.182.124.21]:12281 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038Ab3HWBmg (ORCPT ); Thu, 22 Aug 2013 21:42:36 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 22 Aug 2013 18:42:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,937,1367996400"; d="scan'208";a="350437824" Received: from zyan5-mobl.sh.intel.com ([10.239.13.8]) by azsmga001.ch.intel.com with ESMTP; 22 Aug 2013 18:42:33 -0700 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org Cc: sage@inktank.com, "Yan, Zheng" Subject: [PATCH] mds: update backtrace when old format inode is touched Date: Fri, 23 Aug 2013 09:42:30 +0800 Message-Id: <1377222150-4238-1-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.8.1.4 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Yan, Zheng" We updated inode format version to 7 when introducing inode backtrace. If we found a inode's format version < 7 when fetching the inode, set the inode's backtrace_version to 0, to indicate the inode's backtrace is out of data. When touching a inode with backtrace_version == 0, we also update its backtrace. Signed-off-by: Yan, Zheng --- src/mds/Locker.cc | 4 ++++ src/mds/Server.cc | 5 +++++ src/mds/mdstypes.cc | 2 ++ 3 files changed, 11 insertions(+) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 99bd761..e274204 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2898,6 +2898,10 @@ bool Locker::_do_cap_update(CInode *in, Capability *cap, wrlock_force(&in->xattrlock, mut); } + + // update backtrace for old format inode. (see inode_t::decode) + if (pi->backtrace_version == 0) + pi->update_backtrace(); mut->auth_pin(in); mdcache->predirty_journal_parents(mut, &le->metablob, in, 0, PREDIRTY_PRIMARY, 0, follows); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 466d481..b50169e 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3207,6 +3207,11 @@ void Server::handle_client_setattr(MDRequest *mdr) // log + wait le->metablob.add_client_req(req->get_reqid(), req->get_oldest_client_tid()); + + // update backtrace for old format inode. (see inode_t::decode) + if (pi->backtrace_version == 0) + pi->update_backtrace(); + mdcache->predirty_journal_parents(mdr, &le->metablob, cur, 0, PREDIRTY_PRIMARY, false); mdcache->journal_dirty_inode(mdr, &le->metablob, cur); diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 6886786..f8ec549 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -294,6 +294,8 @@ void inode_t::decode(bufferlist::iterator &p) ::decode(backtrace_version, p); if (struct_v >= 7) ::decode(old_pools, p); + else + backtrace_version = 0; // note inode which has no backtrace DECODE_FINISH(p); }