Skip to content

Commit

Permalink
Merge pull request ceph#11452 from liewegas/wip-bluestore-keys
Browse files Browse the repository at this point in the history
os/bluestore: fix onode vs extent key suffix
Reviewed-by: xie xingguo <[email protected]>
Reviewed-by: Igor Fedotov <[email protected]>
  • Loading branch information
Igor Fedotov authored Oct 13, 2016
2 parents cd2e18a + d51deba commit 3d3c61d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const string PREFIX_SHARED_BLOB = "X"; // u64 offset -> shared_blob_t
*
* encoded u64: snap
* encoded u64: generation
* 'o'
*/
#define ONODE_KEY_SUFFIX 'o'

/*
* string encoding in the key
Expand All @@ -103,8 +105,7 @@ const string PREFIX_SHARED_BLOB = "X"; // u64 offset -> shared_blob_t
*
* object prefix key
* u32
* 'x' (this char can be anything that is not part of a u64 (hex)
* encoding so we can distinguish this key from an object key)
* 'x'
*/
#define EXTENT_SHARD_KEY_SUFFIX 'x'

Expand Down Expand Up @@ -295,6 +296,8 @@ static void get_object_key(const ghobject_t& oid, string *key)
_key_encode_u64(oid.hobj.snap, key);
_key_encode_u64(oid.generation, key);

key->push_back(ONODE_KEY_SUFFIX);

// sanity check
if (true) {
ghobject_t t;
Expand Down Expand Up @@ -356,10 +359,15 @@ static int get_key_object(const string& key, ghobject_t *oid)

p = _key_decode_u64(p, &oid->hobj.snap.val);
p = _key_decode_u64(p, &oid->generation);

if (*p != ONODE_KEY_SUFFIX) {
return -7;
}
p++;
if (*p) {
// if we get something other than a null terminator here,
// something goes wrong.
return -7;
return -8;
}

return 0;
Expand Down

0 comments on commit 3d3c61d

Please sign in to comment.