From d04f7d46d472b5f872dad3ab6766f7b222720f5a Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 10 Nov 2016 14:44:38 +0800 Subject: [PATCH] os/bluestore: speed up omap-key generation for same onode(the read paths) 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 --- src/os/bluestore/BlueStore.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f18a8a92be27..b1b63112d376 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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::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::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; } } -- 2.47.3