]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: speed up omap-key generation for same onode(the read paths) 11894/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 10 Nov 2016 06:44:38 +0000 (14:44 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 10 Nov 2016 09:30:27 +0000 (17:30 +0800)
In https://github.com/ceph/ceph/pull/11807 we only modify the write paths,
this patch fixes the read parts too, which are more time-sensitive.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index f18a8a92be27065459fb2fff1c6e39c7a1f8b081..b1b63112d376609c1f9124d594fa560ee0a8e0d7 100644 (file)
@@ -6001,6 +6001,7 @@ int BlueStore::omap_get_values(
     return -ENOENT;
   RWLock::RLocker l(c->lock);
   int r = 0;
+  string final_key;
   OnodeRef o = c->get_onode(oid, false);
   if (!o || !o->exists) {
     r = -ENOENT;
@@ -6009,12 +6010,14 @@ int BlueStore::omap_get_values(
   if (!o->onode.omap_head)
     goto out;
   o->flush();
+  _key_encode_u64(o->onode.omap_head, &final_key);
+  final_key.push_back('.');
   for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
-    string key;
-    get_omap_key(o->onode.omap_head, *p, &key);
+    final_key.resize(9); // keep prefix
+    final_key += *p;
     bufferlist val;
-    if (db->get(PREFIX_OMAP, key, &val) >= 0) {
-      dout(30) << __func__ << "  got " << pretty_binary_string(key)
+    if (db->get(PREFIX_OMAP, final_key, &val) >= 0) {
+      dout(30) << __func__ << "  got " << pretty_binary_string(final_key)
               << " -> " << *p << dendl;
       out->insert(make_pair(*p, val));
     }
@@ -6051,6 +6054,7 @@ int BlueStore::omap_check_keys(
     return -ENOENT;
   RWLock::RLocker l(c->lock);
   int r = 0;
+  string final_key;
   OnodeRef o = c->get_onode(oid, false);
   if (!o || !o->exists) {
     r = -ENOENT;
@@ -6059,16 +6063,18 @@ int BlueStore::omap_check_keys(
   if (!o->onode.omap_head)
     goto out;
   o->flush();
+  _key_encode_u64(o->onode.omap_head, &final_key);
+  final_key.push_back('.');
   for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
-    string key;
-    get_omap_key(o->onode.omap_head, *p, &key);
+    final_key.resize(9); // keep prefix
+    final_key += *p;
     bufferlist val;
-    if (db->get(PREFIX_OMAP, key, &val) >= 0) {
-      dout(30) << __func__ << "  have " << pretty_binary_string(key)
+    if (db->get(PREFIX_OMAP, final_key, &val) >= 0) {
+      dout(30) << __func__ << "  have " << pretty_binary_string(final_key)
               << " -> " << *p << dendl;
       out->insert(*p);
     } else {
-      dout(30) << __func__ << "  miss " << pretty_binary_string(key)
+      dout(30) << __func__ << "  miss " << pretty_binary_string(final_key)
               << " -> " << *p << dendl;
     }
   }