mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
os/bluestore: add pool prefix to omap keys
Set per-onode flag to indicate whether the object has per-pool keys or not. This will allow us to incrementally transition objects later. Put the new keys under a different prefix. Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
22a969acb1
commit
91f533be71
@ -73,6 +73,7 @@ const string PREFIX_COLL = "C"; // collection name -> cnode_t
|
||||
const string PREFIX_OBJ = "O"; // object name -> onode_t
|
||||
const string PREFIX_OMAP = "M"; // u64 + keyname -> value
|
||||
const string PREFIX_PGMETA_OMAP = "P"; // u64 + keyname -> value(for meta coll)
|
||||
const string PREFIX_PERPOOL_OMAP = "m"; // s64 + u64 + keyname -> value
|
||||
const string PREFIX_DEFERRED = "L"; // id -> deferred_transaction_t
|
||||
const string PREFIX_ALLOC = "B"; // u64 offset -> u64 length (freelist)
|
||||
const string PREFIX_ALLOC_BITMAP = "b";// (see BitmapFreelistManager)
|
||||
@ -3273,20 +3274,31 @@ void BlueStore::Onode::dump(Formatter* f) const
|
||||
|
||||
const string& BlueStore::Onode::get_omap_prefix()
|
||||
{
|
||||
return onode.is_pgmeta_omap() ? PREFIX_PGMETA_OMAP
|
||||
: PREFIX_OMAP;
|
||||
if (onode.is_pgmeta_omap()) {
|
||||
return PREFIX_PGMETA_OMAP;
|
||||
}
|
||||
if (onode.is_perpool_omap()) {
|
||||
return PREFIX_PERPOOL_OMAP;
|
||||
}
|
||||
return PREFIX_OMAP;
|
||||
}
|
||||
|
||||
// '-' < '.' < '~'
|
||||
|
||||
void BlueStore::Onode::get_omap_header(string *out)
|
||||
{
|
||||
if (onode.is_perpool_omap()) {
|
||||
_key_encode_u64(oid.hobj.pool, out);
|
||||
}
|
||||
_key_encode_u64(onode.nid, out);
|
||||
out->push_back('-');
|
||||
}
|
||||
|
||||
void BlueStore::Onode::get_omap_key(const string& key, string *out)
|
||||
{
|
||||
if (onode.is_perpool_omap()) {
|
||||
_key_encode_u64(oid.hobj.pool, out);
|
||||
}
|
||||
_key_encode_u64(onode.nid, out);
|
||||
out->push_back('.');
|
||||
out->append(key);
|
||||
@ -3294,19 +3306,29 @@ void BlueStore::Onode::get_omap_key(const string& key, string *out)
|
||||
|
||||
void BlueStore::Onode::rewrite_omap_key(const string& old, string *out)
|
||||
{
|
||||
if (onode.is_perpool_omap()) {
|
||||
_key_encode_u64(oid.hobj.pool, out);
|
||||
}
|
||||
_key_encode_u64(onode.nid, out);
|
||||
out->append(old.c_str() + out->length(), old.size() - out->length());
|
||||
}
|
||||
|
||||
void BlueStore::Onode::get_omap_tail(string *out)
|
||||
{
|
||||
if (onode.is_perpool_omap()) {
|
||||
_key_encode_u64(oid.hobj.pool, out);
|
||||
}
|
||||
_key_encode_u64(onode.nid, out);
|
||||
out->push_back('~');
|
||||
}
|
||||
|
||||
void BlueStore::Onode::decode_omap_key(const string& key, string *user_key)
|
||||
{
|
||||
*user_key = key.substr(sizeof(uint64_t) + 1);
|
||||
if (onode.is_perpool_omap()) {
|
||||
*user_key = key.substr(sizeof(uint64_t)*2 + 1);
|
||||
} else {
|
||||
*user_key = key.substr(sizeof(uint64_t) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8211,7 +8233,9 @@ void BlueStore::_get_statfs_overall(struct store_statfs_t *buf)
|
||||
{
|
||||
buf->reset();
|
||||
|
||||
buf->omap_allocated = db->estimate_prefix_size(PREFIX_OMAP, string());
|
||||
buf->omap_allocated =
|
||||
db->estimate_prefix_size(PREFIX_OMAP, string()) +
|
||||
db->estimate_prefix_size(PREFIX_PERPOOL_OMAP, string());
|
||||
|
||||
uint64_t bfree = alloc->get_free();
|
||||
|
||||
@ -13145,7 +13169,7 @@ int BlueStore::_omap_setkeys(TransContext *txc,
|
||||
auto p = bl.cbegin();
|
||||
__u32 num;
|
||||
if (!o->onode.has_omap()) {
|
||||
o->onode.set_omap_flag();
|
||||
o->onode.set_omap_flags();
|
||||
if (o->oid.is_pgmeta()) {
|
||||
o->onode.flags |= bluestore_onode_t::FLAG_PGMETA_OMAP;
|
||||
}
|
||||
@ -13189,7 +13213,7 @@ int BlueStore::_omap_setheader(TransContext *txc,
|
||||
int r;
|
||||
string key;
|
||||
if (!o->onode.has_omap()) {
|
||||
o->onode.set_omap_flag();
|
||||
o->onode.set_omap_flags();
|
||||
if (o->oid.is_pgmeta()) {
|
||||
o->onode.flags |= bluestore_onode_t::FLAG_PGMETA_OMAP;
|
||||
}
|
||||
@ -13344,7 +13368,7 @@ int BlueStore::_clone(TransContext *txc,
|
||||
}
|
||||
if (oldo->onode.has_omap()) {
|
||||
dout(20) << __func__ << " copying omap data" << dendl;
|
||||
newo->onode.set_omap_flag();
|
||||
newo->onode.set_omap_flags();
|
||||
if (newo->oid.is_pgmeta()) {
|
||||
newo->onode.flags |= bluestore_onode_t::FLAG_PGMETA_OMAP;
|
||||
}
|
||||
|
@ -913,6 +913,7 @@ struct bluestore_onode_t {
|
||||
enum {
|
||||
FLAG_OMAP = 1, ///< object may have omap data
|
||||
FLAG_PGMETA_OMAP = 2, ///< omap data is in meta omap prefix
|
||||
FLAG_PERPOOL_OMAP = 4, ///< omap data is in per-pool prefix; per-pool keys
|
||||
};
|
||||
|
||||
string get_flags_string() const {
|
||||
@ -920,6 +921,12 @@ struct bluestore_onode_t {
|
||||
if (flags & FLAG_OMAP) {
|
||||
s = "omap";
|
||||
}
|
||||
if (flags & FLAG_PGMETA_OMAP) {
|
||||
s += "+pgmeta_omap";
|
||||
}
|
||||
if (flags & FLAG_PERPOOL_OMAP) {
|
||||
s += "+perpool_omap";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -941,9 +948,12 @@ struct bluestore_onode_t {
|
||||
bool is_pgmeta_omap() const {
|
||||
return has_flag(FLAG_PGMETA_OMAP);
|
||||
}
|
||||
bool is_perpool_omap() const {
|
||||
return has_flag(FLAG_PERPOOL_OMAP);
|
||||
}
|
||||
|
||||
void set_omap_flag() {
|
||||
set_flag(FLAG_OMAP);
|
||||
void set_omap_flags() {
|
||||
set_flag(FLAG_OMAP | FLAG_PERPOOL_OMAP);
|
||||
}
|
||||
|
||||
void clear_omap_flag() {
|
||||
|
Loading…
Reference in New Issue
Block a user