}
}
// omap
- if (o->onode.omap_head) {
- if (used_omap_head.count(o->onode.omap_head)) {
- derr << __func__ << " " << oid << " omap_head " << o->onode.omap_head
+ if (o->onode.has_omap()) {
+ if (used_omap_head.count(o->onode.nid)) {
+ derr << __func__ << " " << oid << " omap_head " << o->onode.nid
<< " already in use" << dendl;
++errors;
} else {
- used_omap_head.insert(o->onode.omap_head);
+ used_omap_head.insert(o->onode.nid);
}
}
}
: c(c), o(o), it(it)
{
RWLock::RLocker l(c->lock);
- if (o->onode.omap_head) {
- get_omap_key(o->onode.omap_head, string(), &head);
- get_omap_tail(o->onode.omap_head, &tail);
+ if (o->onode.has_omap()) {
+ get_omap_key(o->onode.nid, string(), &head);
+ get_omap_tail(o->onode.nid, &tail);
it->lower_bound(head);
}
}
int BlueStore::OmapIteratorImpl::seek_to_first()
{
RWLock::RLocker l(c->lock);
- if (o->onode.omap_head) {
+ if (o->onode.has_omap()) {
it->lower_bound(head);
} else {
it = KeyValueDB::Iterator();
int BlueStore::OmapIteratorImpl::upper_bound(const string& after)
{
RWLock::RLocker l(c->lock);
- if (o->onode.omap_head) {
+ if (o->onode.has_omap()) {
string key;
- get_omap_key(o->onode.omap_head, after, &key);
+ get_omap_key(o->onode.nid, after, &key);
it->upper_bound(key);
} else {
it = KeyValueDB::Iterator();
int BlueStore::OmapIteratorImpl::lower_bound(const string& to)
{
RWLock::RLocker l(c->lock);
- if (o->onode.omap_head) {
+ if (o->onode.has_omap()) {
string key;
- get_omap_key(o->onode.omap_head, to, &key);
+ get_omap_key(o->onode.nid, to, &key);
it->lower_bound(key);
} else {
it = KeyValueDB::Iterator();
bool BlueStore::OmapIteratorImpl::valid()
{
RWLock::RLocker l(c->lock);
- return o->onode.omap_head && it->valid() && it->raw_key().second <= tail;
+ return o->onode.has_omap() && it->valid() && it->raw_key().second <= tail;
}
int BlueStore::OmapIteratorImpl::next(bool validate)
{
RWLock::RLocker l(c->lock);
- if (o->onode.omap_head) {
+ if (o->onode.has_omap()) {
it->next();
return 0;
} else {
r = -ENOENT;
goto out;
}
- if (!o->onode.omap_head)
+ if (!o->onode.has_omap())
goto out;
o->flush();
{
KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
string head, tail;
- get_omap_header(o->onode.omap_head, &head);
- get_omap_tail(o->onode.omap_head, &tail);
+ get_omap_header(o->onode.nid, &head);
+ get_omap_tail(o->onode.nid, &tail);
it->lower_bound(head);
while (it->valid()) {
if (it->key() == head) {
r = -ENOENT;
goto out;
}
- if (!o->onode.omap_head)
+ if (!o->onode.has_omap())
goto out;
o->flush();
{
string head;
- get_omap_header(o->onode.omap_head, &head);
+ get_omap_header(o->onode.nid, &head);
if (db->get(PREFIX_OMAP, head, header) >= 0) {
dout(30) << __func__ << " got header" << dendl;
} else {
r = -ENOENT;
goto out;
}
- if (!o->onode.omap_head)
+ if (!o->onode.has_omap())
goto out;
o->flush();
{
KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
string head, tail;
- get_omap_key(o->onode.omap_head, string(), &head);
- get_omap_tail(o->onode.omap_head, &tail);
+ get_omap_key(o->onode.nid, string(), &head);
+ get_omap_tail(o->onode.nid, &tail);
it->lower_bound(head);
while (it->valid()) {
if (it->key() >= tail) {
r = -ENOENT;
goto out;
}
- if (!o->onode.omap_head)
+ if (!o->onode.has_omap())
goto out;
o->flush();
- _key_encode_u64(o->onode.omap_head, &final_key);
+ _key_encode_u64(o->onode.nid, &final_key);
final_key.push_back('.');
for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
final_key.resize(9); // keep prefix
r = -ENOENT;
goto out;
}
- if (!o->onode.omap_head)
+ if (!o->onode.has_omap())
goto out;
o->flush();
- _key_encode_u64(o->onode.omap_head, &final_key);
+ _key_encode_u64(o->onode.nid, &final_key);
final_key.push_back('.');
for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
final_key.resize(9); // keep prefix
return ObjectMap::ObjectMapIterator();
}
o->flush();
- dout(10) << __func__ << " header = " << o->onode.omap_head <<dendl;
+ dout(10) << __func__ << " has_omap = " << (int)o->onode.has_omap() <<dendl;
KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
return ObjectMap::ObjectMapIterator(new OmapIteratorImpl(c, o, it));
}
int r = _do_truncate(txc, c, o, 0);
if (r < 0)
return r;
- if (o->onode.omap_head) {
- _do_omap_clear(txc, o->onode.omap_head);
+ if (o->onode.has_omap()) {
+ _do_omap_clear(txc, o->onode.nid);
}
o->exists = false;
o->onode = bluestore_onode_t();
{
dout(15) << __func__ << " " << c->cid << " " << o->oid << dendl;
int r = 0;
- if (o->onode.omap_head != 0) {
- _do_omap_clear(txc, o->onode.omap_head);
- o->onode.omap_head = 0;
+ if (o->onode.has_omap()) {
+ _do_omap_clear(txc, o->onode.nid);
+ o->onode.clear_omap_flag();
txc->write_onode(o);
}
dout(10) << __func__ << " " << c->cid << " " << o->oid << " = " << r << dendl;
int r;
bufferlist::iterator p = bl.begin();
__u32 num;
- if (!o->onode.omap_head) {
- o->onode.omap_head = o->onode.nid;
+ if (!o->onode.has_omap()) {
+ o->onode.set_omap_flag();
txc->write_onode(o);
}
string final_key;
- _key_encode_u64(o->onode.omap_head, &final_key);
+ _key_encode_u64(o->onode.nid, &final_key);
final_key.push_back('.');
::decode(num, p);
while (num--) {
dout(15) << __func__ << " " << c->cid << " " << o->oid << dendl;
int r;
string key;
- if (!o->onode.omap_head) {
- o->onode.omap_head = o->onode.nid;
+ if (!o->onode.has_omap()) {
+ o->onode.set_omap_flag();
txc->write_onode(o);
}
- get_omap_header(o->onode.omap_head, &key);
+ get_omap_header(o->onode.nid, &key);
txc->t->set(PREFIX_OMAP, key, bl);
r = 0;
dout(10) << __func__ << " " << c->cid << " " << o->oid << " = " << r << dendl;
__u32 num;
string final_key;
- if (!o->onode.omap_head) {
+ if (!o->onode.has_omap()) {
goto out;
}
- _key_encode_u64(o->onode.omap_head, &final_key);
+ _key_encode_u64(o->onode.nid, &final_key);
final_key.push_back('.');
::decode(num, p);
while (num--) {
KeyValueDB::Iterator it;
string key_first, key_last;
int r = 0;
- if (!o->onode.omap_head) {
+ if (!o->onode.has_omap()) {
goto out;
}
it = db->get_iterator(PREFIX_OMAP);
- get_omap_key(o->onode.omap_head, first, &key_first);
- get_omap_key(o->onode.omap_head, last, &key_last);
+ get_omap_key(o->onode.nid, first, &key_first);
+ get_omap_key(o->onode.nid, last, &key_last);
it->lower_bound(key_first);
while (it->valid()) {
if (it->key() >= key_last) {
newo->onode.attrs = oldo->onode.attrs;
// clone omap
- if (newo->onode.omap_head) {
+ if (newo->onode.has_omap()) {
dout(20) << __func__ << " clearing old omap data" << dendl;
- _do_omap_clear(txc, newo->onode.omap_head);
+ _do_omap_clear(txc, newo->onode.nid);
}
- if (oldo->onode.omap_head) {
+ if (oldo->onode.has_omap()) {
dout(20) << __func__ << " copying omap data" << dendl;
- if (!newo->onode.omap_head) {
- newo->onode.omap_head = newo->onode.nid;
+ if (!newo->onode.has_omap()) {
+ newo->onode.set_omap_flag();
}
KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
string head, tail;
- get_omap_header(oldo->onode.omap_head, &head);
- get_omap_tail(oldo->onode.omap_head, &tail);
+ get_omap_header(oldo->onode.nid, &head);
+ get_omap_tail(oldo->onode.nid, &tail);
it->lower_bound(head);
while (it->valid()) {
if (it->key() >= tail) {
dout(30) << __func__ << " got header/data "
<< pretty_binary_string(it->key()) << dendl;
string key;
- rewrite_omap_key(newo->onode.omap_head, it->key(), &key);
+ rewrite_omap_key(newo->onode.nid, it->key(), &key);
txc->t->set(PREFIX_OMAP, key, it->value());
}
it->next();