Skip to content

Commit 0850828

Browse files
committed
os/bluestore: reduce dependencies of omap_iterate()'s loop on Onode
Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent a7c8195 commit 0850828

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/os/bluestore/BlueStore.cc

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4830,7 +4830,7 @@ void BlueStore::Onode::rewrite_omap_key(const string& old, string *out)
48304830
out->append(old.c_str() + out->length(), old.size() - out->length());
48314831
}
48324832

4833-
void BlueStore::Onode::decode_omap_key(const string& key, string *user_key)
4833+
size_t BlueStore::Onode::calc_userkey_offset_in_omap_key() const
48344834
{
48354835
size_t pos = sizeof(uint64_t) + 1;
48364836
if (!onode.is_pgmeta_omap()) {
@@ -4840,22 +4840,15 @@ void BlueStore::Onode::decode_omap_key(const string& key, string *user_key)
48404840
pos += sizeof(uint64_t);
48414841
}
48424842
}
4843-
*user_key = key.substr(pos);
4843+
return pos;
48444844
}
48454845

4846-
void BlueStore::Onode::decode_omap_key(const std::string_view& key, std::string_view *user_key)
4846+
void BlueStore::Onode::decode_omap_key(const string& key, string *user_key)
48474847
{
4848-
size_t pos = sizeof(uint64_t) + 1;
4849-
if (!onode.is_pgmeta_omap()) {
4850-
if (onode.is_perpg_omap()) {
4851-
pos += sizeof(uint64_t) + sizeof(uint32_t);
4852-
} else if (onode.is_perpool_omap()) {
4853-
pos += sizeof(uint64_t);
4854-
}
4855-
}
4856-
*user_key = key.substr(pos);
4848+
*user_key = key.substr(calc_userkey_offset_in_omap_key());
48574849
}
48584850

4851+
48594852
void BlueStore::Onode::finish_write(TransContext* txc, uint32_t offset, uint32_t length)
48604853
{
48614854
while (true) {
@@ -13807,15 +13800,16 @@ int BlueStore::omap_iterate(
1380713800

1380813801
// iterate!
1380913802
std::string tail;
13810-
ceph::timespan next_lat_acc{0};
1381113803
o->get_omap_tail(&tail);
13804+
const std::string_view::size_type userkey_offset_in_dbkey =
13805+
o->calc_userkey_offset_in_omap_key();
13806+
ceph::timespan next_lat_acc{0};
1381213807
while (it->valid()) {
1381313808
const auto& db_key = it->raw_key_as_sv().second;
1381413809
if (db_key >= tail) {
1381513810
break;
1381613811
}
13817-
std::string_view user_key;
13818-
o->decode_omap_key(db_key, &user_key);
13812+
std::string_view user_key = db_key.substr(userkey_offset_in_dbkey);
1381913813
omap_iter_ret_t ret = f(user_key, it->value_as_sv());
1382013814
if (ret == omap_iter_ret_t::STOP) {
1382113815
break;

src/os/bluestore/BlueStore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,8 @@ class BlueStore : public ObjectStore,
14571457
}
14581458

14591459
void rewrite_omap_key(const std::string& old, std::string *out);
1460+
size_t calc_userkey_offset_in_omap_key() const;
14601461
void decode_omap_key(const std::string& key, std::string *user_key);
1461-
void decode_omap_key(const std::string_view& key, std::string_view *user_key);
14621462

14631463
void finish_write(TransContext* txc, uint32_t offset, uint32_t length);
14641464

0 commit comments

Comments
 (0)