]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: refactor object key helpers a bit
authorSage Weil <sage@newdream.net>
Thu, 9 Sep 2021 16:15:22 +0000 (11:15 -0500)
committerSage Weil <sage@newdream.net>
Fri, 29 Oct 2021 13:55:57 +0000 (09:55 -0400)
We want methods that work on partial keys.

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/bluestore/BlueStore.cc

index 8899981b851142f94f1f033cfcb22376b433004d..89774211114048c383f13c57da3a5004b1f652d0 100644 (file)
@@ -379,20 +379,12 @@ static const char *_key_decode_prefix(const char *p, ghobject_t *oid)
 
 #define ENCODED_KEY_PREFIX_LEN (1 + 8 + 4)
 
-template<typename S>
-static int get_key_object(const S& key, ghobject_t *oid)
+static int _get_key_object(const char *p, ghobject_t *oid)
 {
   int r;
-  const char *p = key.c_str();
-
-  if (key.length() < ENCODED_KEY_PREFIX_LEN)
-    return -1;
 
   p = _key_decode_prefix(p, oid);
 
-  if (key.length() == ENCODED_KEY_PREFIX_LEN)
-    return -2;
-
   r = decode_escaped(p, &oid->hobj.nspace);
   if (r < 0)
     return -2;
@@ -437,10 +429,19 @@ static int get_key_object(const S& key, ghobject_t *oid)
 }
 
 template<typename S>
-static void get_object_key(CephContext *cct, const ghobject_t& oid, S *key)
+static int get_key_object(const S& key, ghobject_t *oid)
 {
-  key->clear();
+  if (key.length() < ENCODED_KEY_PREFIX_LEN)
+    return -1;
+  if (key.length() == ENCODED_KEY_PREFIX_LEN)
+    return -2;
+  const char *p = key.c_str();
+  return _get_key_object(p, oid);
+}
 
+template<typename S>
+static void _get_object_key(const ghobject_t& oid, S *key)
+{
   size_t max_len = ENCODED_KEY_PREFIX_LEN +
                   (oid.hobj.nspace.length() * 3 + 1) +
                   (oid.hobj.get_key().length() * 3 + 1) +
@@ -475,6 +476,13 @@ static void get_object_key(CephContext *cct, const ghobject_t& oid, S *key)
   _key_encode_u64(oid.generation, key);
 
   key->push_back(ONODE_KEY_SUFFIX);
+}
+
+template<typename S>
+static void get_object_key(CephContext *cct, const ghobject_t& oid, S *key)
+{
+  key->clear();
+  _get_object_key(oid, key);
 
   // sanity check
   if (true) {