From patchwork Fri Nov 23 08:06:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 1794081 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 1C1A23FCAE for ; Fri, 23 Nov 2012 08:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030213Ab2KWIGm (ORCPT ); Fri, 23 Nov 2012 03:06:42 -0500 Received: from mga02.intel.com ([134.134.136.20]:58090 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964804Ab2KWIGm (ORCPT ); Fri, 23 Nov 2012 03:06:42 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 23 Nov 2012 00:06:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,306,1352102400"; d="scan'208";a="246090933" Received: from zyan5-mobl.sh.intel.com ([10.239.36.23]) by orsmga002.jf.intel.com with ESMTP; 23 Nov 2012 00:06:40 -0800 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org, sage@inktank.com Cc: "Yan, Zheng" Subject: [PATCH] mds: sort dentries in CDdir in the same order as the tmap Date: Fri, 23 Nov 2012 16:06:39 +0800 Message-Id: <1353657999-14182-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" CDir::_commit_partial() uses tmap update operation to write dirty dentries to object store. tmap update requires that tmap command keys are provides in ascending order. But the code compares dentry_key_t and tmap key in different ways and may get different results. For example: dentry_key_t "f1" > dentry_key_t "f" string "f1_head" < string "f_head" The fix is comparing CDentries in the same way as comparing the tmap keys. Signed-off-by: Yan, Zheng --- src/mds/mdstypes.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 22e754e..dcd23f3 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -709,12 +709,17 @@ inline ostream& operator<<(ostream& out, const dentry_key_t &k) inline bool operator<(const dentry_key_t& k1, const dentry_key_t& k2) { - /* - * order by name, then snap - */ - int c = strcmp(k1.name, k2.name); - return - c < 0 || (c == 0 && k1.snapid < k2.snapid); + bufferlist bl; + k1.encode(bl); + k2.encode(bl); + + string str1; + string str2; + bufferlist::iterator ip = bl.begin(); + ::decode(str1, ip); + ::decode(str2, ip); + + return str1 < str2; }