bool BlueStore::exists(coll_t cid, const ghobject_t& oid)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return false;
+ return exists(c, oid);
+}
+
+bool BlueStore::exists(CollectionHandle &c_, const ghobject_t& oid)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(10) << __func__ << " " << c->cid << " " << oid << dendl;
+ if (!c->exists)
+ return false;
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists)
struct stat *st,
bool allow_eio)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return stat(c, oid, st, allow_eio);
+}
+
+int BlueStore::stat(
+ CollectionHandle &c_,
+ const ghobject_t& oid,
+ struct stat *st,
+ bool allow_eio)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ if (c->exists)
+ return -ENOENT;
+ dout(10) << __func__ << " " << c->get_cid() << " " << oid << dendl;
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists)
uint32_t op_flags,
bool allow_eio)
{
+ CollectionHandle c = _get_collection(cid);
+ if (!c)
+ return -ENOENT;
+ return read(c, oid, offset, length, bl, op_flags, allow_eio);
+}
+
+int BlueStore::read(
+ CollectionHandle &c_,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t length,
+ bufferlist& bl,
+ uint32_t op_flags,
+ bool allow_eio)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ const coll_t &cid = c->get_cid();
dout(15) << __func__ << " " << cid << " " << oid
<< " " << offset << "~" << length
<< dendl;
- bl.clear();
- CollectionRef c = _get_collection(cid);
- if (!c)
+ if (!c->exists)
return -ENOENT;
RWLock::RLocker l(c->lock);
+ bl.clear();
+
int r;
OnodeRef o = c->get_onode(oid, false);
size_t len,
bufferlist& bl)
{
- interval_set<uint64_t> m;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return fiemap(c, oid, offset, len, bl);
+}
+
+int BlueStore::fiemap(
+ CollectionHandle &c_,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t len,
+ bufferlist& bl)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ if (!c->exists)
+ return -ENOENT;
+ interval_set<uint64_t> m;
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
const char *name,
bufferptr& value)
{
- dout(15) << __func__ << " " << cid << " " << oid << " " << name << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return getattr(c, oid, name, value);
+}
+
+int BlueStore::getattr(
+ CollectionHandle &c_,
+ const ghobject_t& oid,
+ const char *name,
+ bufferptr& value)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->cid << " " << oid << " " << name << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r;
string k(name);
value = o->onode.attrs[k];
r = 0;
out:
- dout(10) << __func__ << " " << cid << " " << oid << " " << name
+ dout(10) << __func__ << " " << c->cid << " " << oid << " " << name
<< " = " << r << dendl;
return r;
}
+
int BlueStore::getattrs(
coll_t cid,
const ghobject_t& oid,
map<string,bufferptr>& aset)
{
- dout(15) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return getattrs(c, oid, aset);
+}
+
+int BlueStore::getattrs(
+ CollectionHandle &c_,
+ const ghobject_t& oid,
+ map<string,bufferptr>& aset)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r;
aset = o->onode.attrs;
r = 0;
out:
- dout(10) << __func__ << " " << cid << " " << oid
+ dout(10) << __func__ << " " << c->cid << " " << oid
<< " = " << r << dendl;
return r;
}
bool sort_bitwise, int max,
vector<ghobject_t> *ls, ghobject_t *pnext)
{
- dout(15) << __func__ << " " << cid
+ CollectionHandle c = _get_collection(cid);
+ if (!c)
+ return -ENOENT;
+ return collection_list(c, start, end, sort_bitwise, max, ls, pnext);
+}
+
+int BlueStore::collection_list(
+ CollectionHandle &c_, ghobject_t start, ghobject_t end,
+ bool sort_bitwise, int max,
+ vector<ghobject_t> *ls, ghobject_t *pnext)
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->cid
<< " start " << start << " end " << end << " max " << max << dendl;
+ if (!c->exists)
+ return -ENOENT;
if (!sort_bitwise)
return -EOPNOTSUPP;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
KeyValueDB::Iterator it;
start.hobj == hobject_t::get_max()) {
goto out;
}
- get_coll_key_range(cid, c->cnode.bits, &temp_start_key, &temp_end_key,
+ get_coll_key_range(c->cid, c->cnode.bits, &temp_start_key, &temp_end_key,
&start_key, &end_key);
dout(20) << __func__
<< " range " << pretty_binary_string(temp_start_key)
it = db->get_iterator(PREFIX_OBJ);
if (start == ghobject_t() ||
start.hobj == hobject_t() ||
- start == cid.get_min_hobj()) {
+ start == c->cid.get_min_hobj()) {
it->upper_bound(temp_start_key);
temp = true;
} else {
*pnext = ghobject_t::get_max();
}
out:
- dout(10) << __func__ << " " << cid
+ dout(10) << __func__ << " " << c->cid
<< " start " << start << " end " << end << " max " << max
<< " = " << r << ", ls.size() = " << ls->size()
<< ", next = " << *pnext << dendl;
map<string, bufferlist> *out /// < [out] Key to value map
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return omap_get(c, oid, header, out);
+}
+
+int BlueStore::omap_get(
+ CollectionHandle &c_, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ bufferlist *header, ///< [out] omap header
+ map<string, bufferlist> *out /// < [out] Key to value map
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
OnodeRef o = c->get_onode(oid, false);
}
}
out:
- dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+ dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
+ << dendl;
return r;
}
bool allow_eio ///< [in] don't assert on eio
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return omap_get_header(c, oid, header, allow_eio);
+}
+
+int BlueStore::omap_get_header(
+ CollectionHandle &c_, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ bufferlist *header, ///< [out] omap header
+ bool allow_eio ///< [in] don't assert on eio
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
OnodeRef o = c->get_onode(oid, false);
}
}
out:
- dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+ dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
+ << dendl;
return r;
}
set<string> *keys ///< [out] Keys defined on oid
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return omap_get_keys(c, oid, keys);
+}
+
+int BlueStore::omap_get_keys(
+ CollectionHandle &c_, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ set<string> *keys ///< [out] Keys defined on oid
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
OnodeRef o = c->get_onode(oid, false);
}
}
out:
- dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+ dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
+ << dendl;
return r;
}
map<string, bufferlist> *out ///< [out] Returned keys and values
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return omap_get_values(c, oid, keys, out);
+}
+
+int BlueStore::omap_get_values(
+ CollectionHandle &c_, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ const set<string> &keys, ///< [in] Keys to get
+ map<string, bufferlist> *out ///< [out] Returned keys and values
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
OnodeRef o = c->get_onode(oid, false);
}
}
out:
- dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+ dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
+ << dendl;
return r;
}
set<string> *out ///< [out] Subset of keys defined on oid
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c)
return -ENOENT;
+ return omap_check_keys(c, oid, keys, out);
+}
+
+int BlueStore::omap_check_keys(
+ CollectionHandle &c_, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ const set<string> &keys, ///< [in] Keys to check
+ set<string> *out ///< [out] Subset of keys defined on oid
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
+ if (!c->exists)
+ return -ENOENT;
RWLock::RLocker l(c->lock);
int r = 0;
OnodeRef o = c->get_onode(oid, false);
}
}
out:
- dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+ dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
+ << dendl;
return r;
}
const ghobject_t &oid ///< [in] object
)
{
-
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
+ CollectionHandle c = _get_collection(cid);
if (!c) {
dout(10) << __func__ << " " << cid << "doesn't exist" <<dendl;
return ObjectMap::ObjectMapIterator();
}
+ return get_omap_iterator(c, oid);
+}
+
+ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
+ CollectionHandle &c_, ///< [in] collection
+ const ghobject_t &oid ///< [in] object
+ )
+{
+ Collection *c = static_cast<Collection*>(c_.get());
+ dout(10) << __func__ << " " << c->get_cid() << " " << oid << dendl;
+ if (!c->exists) {
+ return ObjectMap::ObjectMapIterator();
+ }
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o) {
int statfs(struct statfs *buf);
bool exists(coll_t cid, const ghobject_t& oid);
+ bool exists(CollectionHandle &c, const ghobject_t& oid);
int stat(
coll_t cid,
const ghobject_t& oid,
struct stat *st,
- bool allow_eio = false); // struct stat?
+ bool allow_eio = false) override;
+ int stat(
+ CollectionHandle &c,
+ const ghobject_t& oid,
+ struct stat *st,
+ bool allow_eio = false) override;
int read(
coll_t cid,
const ghobject_t& oid,
size_t len,
bufferlist& bl,
uint32_t op_flags = 0,
- bool allow_eio = false);
+ bool allow_eio = false) override;
+ int read(
+ CollectionHandle &c,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t len,
+ bufferlist& bl,
+ uint32_t op_flags = 0,
+ bool allow_eio = false) override;
int _do_read(
OnodeRef o,
uint64_t offset,
bufferlist& bl,
uint32_t op_flags = 0);
- int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl);
- int getattr(coll_t cid, const ghobject_t& oid, const char *name, bufferptr& value);
- int getattrs(coll_t cid, const ghobject_t& oid, map<string,bufferptr>& aset);
+ int fiemap(coll_t cid, const ghobject_t& oid,
+ uint64_t offset, size_t len, bufferlist& bl) override;
+ int fiemap(CollectionHandle &c, const ghobject_t& oid,
+ uint64_t offset, size_t len, bufferlist& bl) override;
+
+ int getattr(coll_t cid, const ghobject_t& oid, const char *name,
+ bufferptr& value) override;
+ int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name,
+ bufferptr& value) override;
+
+ int getattrs(coll_t cid, const ghobject_t& oid,
+ map<string,bufferptr>& aset) override;
+ int getattrs(CollectionHandle &c, const ghobject_t& oid,
+ map<string,bufferptr>& aset) override;
+
+ int list_collections(vector<coll_t>& ls) override;
+
+ CollectionHandle open_collection(const coll_t &c) override;
- int list_collections(vector<coll_t>& ls);
bool collection_exists(coll_t c);
bool collection_empty(coll_t c);
int collection_list(coll_t cid, ghobject_t start, ghobject_t end,
bool sort_bitwise, int max,
- vector<ghobject_t> *ls, ghobject_t *next);
+ vector<ghobject_t> *ls, ghobject_t *next) override;
+ int collection_list(CollectionHandle &c, ghobject_t start, ghobject_t end,
+ bool sort_bitwise, int max,
+ vector<ghobject_t> *ls, ghobject_t *next) override;
int omap_get(
coll_t cid, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
bufferlist *header, ///< [out] omap header
map<string, bufferlist> *out /// < [out] Key to value map
- );
+ ) override;
+ int omap_get(
+ CollectionHandle &c, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ bufferlist *header, ///< [out] omap header
+ map<string, bufferlist> *out /// < [out] Key to value map
+ ) override;
/// Get omap header
int omap_get_header(
const ghobject_t &oid, ///< [in] Object containing omap
bufferlist *header, ///< [out] omap header
bool allow_eio = false ///< [in] don't assert on eio
- );
+ ) override;
+ int omap_get_header(
+ CollectionHandle &c, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ bufferlist *header, ///< [out] omap header
+ bool allow_eio = false ///< [in] don't assert on eio
+ ) override;
/// Get keys defined on oid
int omap_get_keys(
coll_t cid, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
set<string> *keys ///< [out] Keys defined on oid
+ ) override;
+ int omap_get_keys(
+ CollectionHandle &c, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ set<string> *keys ///< [out] Keys defined on oid
);
/// Get key values
const ghobject_t &oid, ///< [in] Object containing omap
const set<string> &keys, ///< [in] Keys to get
map<string, bufferlist> *out ///< [out] Returned keys and values
- );
+ ) override;
+ int omap_get_values(
+ CollectionHandle &c, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ const set<string> &keys, ///< [in] Keys to get
+ map<string, bufferlist> *out ///< [out] Returned keys and values
+ ) override;
/// Filters keys into out which are defined on oid
int omap_check_keys(
const ghobject_t &oid, ///< [in] Object containing omap
const set<string> &keys, ///< [in] Keys to check
set<string> *out ///< [out] Subset of keys defined on oid
- );
+ ) override;
+ int omap_check_keys(
+ CollectionHandle &c, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ const set<string> &keys, ///< [in] Keys to check
+ set<string> *out ///< [out] Subset of keys defined on oid
+ ) override;
ObjectMap::ObjectMapIterator get_omap_iterator(
coll_t cid, ///< [in] collection
const ghobject_t &oid ///< [in] object
- );
+ ) override;
+ ObjectMap::ObjectMapIterator get_omap_iterator(
+ CollectionHandle &c, ///< [in] collection
+ const ghobject_t &oid ///< [in] object
+ ) override;
void set_fsid(uuid_d u) {
fsid = u;