From: "Yan, Zheng" <[email protected]>

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 <[email protected]>
---
 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;
 }
 
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to