]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: choose hash function according to dir layout
authorYan, Zheng <zheng.z.yan@intel.com>
Fri, 21 Feb 2014 07:51:16 +0000 (15:51 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Sat, 1 Mar 2014 05:04:07 +0000 (13:04 +0800)
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/client/Client.cc
src/client/Inode.h

index e75262ced1aa0d445ef3e274757b14b3b9ab0da0..2651e53e99089b0ccaafd24784e58055d31028b4 100644 (file)
@@ -877,8 +877,7 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session,
       // remove any skipped names
       while (pd != dir->dentry_map.end() && pd->first < dname) {
        if (pd->first < dname &&
-           diri->dirfragtree[ceph_str_hash_linux(pd->first.c_str(),
-                                                 pd->first.length())] == fg) {  // do not remove items in earlier frags
+           fg.contains(diri->hash_dentry_name(pd->first))) {  // do not remove items in earlier frags
          ldout(cct, 15) << "insert_trace  unlink '" << pd->first << "'" << dendl;
          Dentry *dn = pd->second;
          ++pd;
@@ -927,8 +926,7 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session,
     // remove trailing names
     if (end) {
       while (pd != dir->dentry_map.end()) {
-       if (diri->dirfragtree[ceph_str_hash_linux(pd->first.c_str(),
-                                                 pd->first.length())] == fg) {
+       if (fg.contains(diri->hash_dentry_name(pd->first))) {
          ldout(cct, 15) << "insert_trace  unlink '" << pd->first << "'" << dendl;
          Dentry *dn = pd->second;
          ++pd;
@@ -1081,9 +1079,7 @@ int Client::choose_target_mds(MetaRequest *req)
   if (in) {
     ldout(cct, 20) << "choose_target_mds starting with req->inode " << *in << dendl;
     if (req->path.depth()) {
-      hash = ceph_str_hash(in->dir_layout.dl_dir_hash,
-                          req->path[0].data(),
-                          req->path[0].length());
+      hash = in->hash_dentry_name(req->path[0]);
       ldout(cct, 20) << "choose_target_mds inode dir hash is " << (int)in->dir_layout.dl_dir_hash
               << " on " << req->path[0]
               << " => " << hash << dendl;
@@ -1095,9 +1091,7 @@ int Client::choose_target_mds(MetaRequest *req)
       ldout(cct, 20) << "choose_target_mds starting with req->dentry inode " << *in << dendl;
     } else {
       in = de->dir->parent_inode;
-      hash = ceph_str_hash(in->dir_layout.dl_dir_hash,
-                          de->name.data(),
-                          de->name.length());
+      hash = in->hash_dentry_name(de->name);
       ldout(cct, 20) << "choose_target_mds dentry dir hash is " << (int)in->dir_layout.dl_dir_hash
               << " on " << de->name
               << " => " << hash << dendl;
index 692e76ab9023a5f8ebae7760c9b2a83775f1638e..587a7ea6c45435764c89a0262562ef881195c6ee 100644 (file)
@@ -126,6 +126,13 @@ class Inode {
     return false;
   }
 
+  __u32 hash_dentry_name(const string &dn) {
+    int which = dir_layout.dl_dir_hash;
+    if (!which)
+      which = CEPH_STR_HASH_LINUX;
+    return ceph_str_hash(which, dn.data(), dn.length());
+  }
+
   unsigned flags;
 
   // about the dir (if this is one!)