[PATCH] mds: sort dentries in CDdir in the same order as the tmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Yan, Zheng" <zheng.z.yan@xxxxxxxxx>

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 <zheng.z.yan@xxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux