stbuf->st_gid = 0;
stbuf->st_mode = S_IFREG | 0700;
+ auto ch = fs->store->open_collection(cid);
+
switch (t) {
case FN_OBJECT_OMAP:
case FN_OBJECT_ATTR:
{
spg_t pgid;
if (cid.is_pg(&pgid)) {
- int bits = fs->store->collection_bits(cid);
+ if (!ch) {
+ return -ENOENT;
+ }
+ int bits = fs->store->collection_bits(ch);
if (bits >= 0 && !oid.match(bits, pgid.ps())) {
// sorry, not part of this PG
return -ENOENT;
case FN_OBJECT_OMAP:
case FN_OBJECT_ATTR:
case FN_OBJECT:
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
// fall-thru
case FN_ALL:
break;
case FN_OBJECT_HASH:
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
stbuf->st_size = 9;
return 0;
case FN_HASH_END:
- if (!fs->store->collection_exists(cid))
+ if (!ch)
return -ENOENT;
- if (fs->store->collection_bits(cid) < 0)
+ if (fs->store->collection_bits(ch) < 0)
return -ENOENT;
// fall-thru
case FN_HASH_START:
case FN_HASH_BITS:
{
- if (!fs->store->collection_exists(cid))
+ if (!ch)
return -ENOENT;
- int bits = fs->store->collection_bits(cid);
+ int bits = fs->store->collection_bits(ch);
if (bits < 0)
return -ENOENT;
char buf[8];
case FN_OBJECT_DATA:
{
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
- int r = fs->store->stat(cid, oid, stbuf);
+ int r = fs->store->stat(ch, oid, stbuf);
if (r < 0)
return r;
}
case FN_OBJECT_OMAP_HEADER:
{
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
bufferlist bl;
- fs->store->omap_get_header(cid, oid, &bl);
+ fs->store->omap_get_header(ch, oid, &bl);
stbuf->st_size = bl.length();
}
break;
case FN_OBJECT_OMAP_VAL:
{
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
set<string> k;
k.insert(key);
map<string,bufferlist> v;
- fs->store->omap_get_values(cid, oid, k, &v);
+ fs->store->omap_get_values(ch, oid, k, &v);
if (!v.count(key)) {
return -ENOENT;
}
case FN_OBJECT_ATTR_VAL:
{
- if (!fs->store->exists(cid, oid))
+ if (!fs->store->exists(ch, oid))
return -ENOENT;
bufferptr v;
- int r = fs->store->getattr(cid, oid, key.c_str(), v);
+ int r = fs->store->getattr(ch, oid, key.c_str(), v);
if (r == -ENODATA)
r = -ENOENT;
if (r < 0)
std::lock_guard<std::mutex> l(fs->lock);
+ auto ch = fs->store->open_collection(cid);
+
// we can't shift 32 bits or else off_t will go negative
const int hash_shift = 31;
case FN_COLLECTION:
{
+ if (!ch) {
+ return -ENOENT;
+ }
filler(buf, "bitwise_hash_start", NULL, 0);
- if (fs->store->collection_bits(cid) >= 0) {
+ if (fs->store->collection_bits(ch) >= 0) {
filler(buf, "bitwise_hash_end", NULL, 0);
filler(buf, "bitwise_hash_bits", NULL, 0);
}
filler(buf, "by_bitwise_hash", NULL, 0);
spg_t pgid;
if (cid.is_pg(&pgid) &&
- fs->store->exists(cid, pgid.make_pgmeta_oid())) {
+ fs->store->exists(ch, pgid.make_pgmeta_oid())) {
filler(buf, "pgmeta", NULL, 0);
}
}
while (true) {
vector<ghobject_t> ls;
int r = fs->store->collection_list(
- cid, next, last, 1000, &ls, &next);
+ ch, next, last, 1000, &ls, &next);
if (r < 0)
return r;
for (auto p : ls) {
case FN_OBJECT_OMAP:
{
set<string> keys;
- fs->store->omap_get_keys(cid, oid, &keys);
+ fs->store->omap_get_keys(ch, oid, &keys);
unsigned skip = offset;
for (auto k : keys) {
if (skip) {
case FN_OBJECT_ATTR:
{
map<string,bufferptr> aset;
- fs->store->getattrs(cid, oid, aset);
+ fs->store->getattrs(ch, oid, aset);
unsigned skip = offset;
for (auto a : aset) {
if (skip) {
std::lock_guard<std::mutex> l(fs->lock);
+ auto ch = fs->store->open_collection(cid);
+
bufferlist *pbl = 0;
switch (t) {
case FN_TYPE:
case FN_HASH_END:
{
+ if (!ch) {
+ return -ENOENT;
+ }
spg_t pgid;
unsigned long h;
if (cid.is_pg(&pgid)) {
- int hash_bits = fs->store->collection_bits(cid);
+ int hash_bits = fs->store->collection_bits(ch);
if (hash_bits >= 0) {
uint64_t rev_start = hobject_t::_reverse_bits(pgid.ps());
uint64_t rev_end = (rev_start | (0xffffffff >> hash_bits));
case FN_HASH_BITS:
{
- int r = fs->store->collection_bits(cid);
+ if (!ch) {
+ return -ENOENT;
+ }
+ int r = fs->store->collection_bits(ch);
if (r < 0)
return r;
char buf[8];
int r = fs->open_file(
path, fi,
[&](bufferlist *pbl) {
- return fs->store->read(cid, oid, 0, 0, *pbl);
+ return fs->store->read(ch, oid, 0, 0, *pbl);
});
if (r < 0) {
return r;
path, fi,
[&](bufferlist *pbl) {
bufferptr bp;
- int r = fs->store->getattr(cid, oid, key.c_str(), bp);
+ int r = fs->store->getattr(ch, oid, key.c_str(), bp);
if (r < 0)
return r;
pbl->append(bp);
set<string> k;
k.insert(key);
map<string,bufferlist> v;
- int r = fs->store->omap_get_values(cid, oid, k, &v);
+ int r = fs->store->omap_get_values(ch, oid, k, &v);
if (r < 0)
return r;
*pbl = v[key];
int r = fs->open_file(
path, fi,
[&](bufferlist *pbl) {
- return fs->store->omap_get_header(cid, oid, pbl);
+ return fs->store->omap_get_header(ch, oid, pbl);
});
if (r < 0)
return r;
switch (f) {
case FN_OBJECT:
{
+ ch = fs->store->open_collection(cid);
+ if (!ch) {
+ return -ENOENT;
+ }
spg_t pgid;
if (cid.is_pg(&pgid)) {
- int bits = fs->store->collection_bits(cid);
+ int bits = fs->store->collection_bits(ch);
if (bits >= 0 && !oid.match(bits, pgid.ps())) {
// sorry, not part of this PG
return -EINVAL;
mode = 0;
}
t.create_collection(cid, mode);
-
- ch = fs->store->open_collection(coll_t::meta());
+ ch = fs->store->create_new_collection(cid);
break;
default:
case FN_OBJECT_DATA:
{
pbl = new bufferlist;
- fs->store->read(cid, oid, 0, 0, *pbl);
+ fs->store->read(ch, oid, 0, 0, *pbl);
}
break;
{
pbl = new bufferlist;
bufferptr bp;
- int r = fs->store->getattr(cid, oid, key.c_str(), bp);
+ int r = fs->store->getattr(ch, oid, key.c_str(), bp);
if (r == -ENODATA) {
bufferlist empty;
t.setattr(cid, oid, key.c_str(), empty);
set<string> k;
k.insert(key);
map<string,bufferlist> v;
- fs->store->omap_get_values(cid, oid, k, &v);
+ fs->store->omap_get_values(ch, oid, k, &v);
if (v.count(key) == 0) {
map<string,bufferlist> aset;
aset[key] = bufferlist();
std::lock_guard<std::mutex> l(fs->lock);
- ObjectStore::CollectionHandle ch;
+ ObjectStore::CollectionHandle ch = fs->store->open_collection(cid);
ObjectStore::Transaction t;
switch (f) {
case FN_COLLECTION:
{
bool empty;
- int r = fs->store->collection_empty(cid, &empty);
+ int r = fs->store->collection_empty(ch, &empty);
if (r < 0)
return r;
if (!empty)
* @param oid oid of object
* @returns true if object exists, false otherwise
*/
- virtual bool exists(const coll_t& cid, const ghobject_t& oid) = 0; // useful?
- virtual bool exists(CollectionHandle& c, const ghobject_t& oid) {
- return exists(c->get_cid(), oid);
- }
+ virtual bool exists(CollectionHandle& c, const ghobject_t& oid) = 0;
/**
* set_collection_opts -- set pool options for a collectioninformation for an object
*
* @returns 0 on success, negative error code on failure.
*/
virtual int set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& c,
const pool_opts_t& opts) = 0;
/**
* @param allow_eio if false, assert on -EIO operation failure
* @returns 0 on success, negative error code on failure.
*/
- virtual int stat(
- const coll_t& cid,
- const ghobject_t& oid,
- struct stat *st,
- bool allow_eio = false) = 0; // struct stat?
virtual int stat(
CollectionHandle &c,
const ghobject_t& oid,
struct stat *st,
- bool allow_eio = false) {
- return stat(c->get_cid(), oid, st, allow_eio);
- }
-
+ bool allow_eio = false) = 0;
/**
* read -- read a byte range of data from an object
*
* @param op_flags is CEPH_OSD_OP_FLAG_*
* @returns number of bytes read on success, or negative error code on failure.
*/
- virtual int read(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- bufferlist& bl,
- uint32_t op_flags = 0) = 0;
virtual int read(
CollectionHandle &c,
const ghobject_t& oid,
uint64_t offset,
size_t len,
bufferlist& bl,
- uint32_t op_flags = 0) {
- return read(c->get_cid(), oid, offset, len, bl, op_flags);
- }
+ uint32_t op_flags = 0) = 0;
/**
* fiemap -- get extent map of data of an object
* @param bl output bufferlist for extent map information.
* @returns 0 on success, negative error code on failure.
*/
- virtual int fiemap(const coll_t& cid, const ghobject_t& oid,
- uint64_t offset, size_t len, bufferlist& bl) = 0;
- virtual int fiemap(const coll_t& cid, const ghobject_t& oid,
- uint64_t offset, size_t len,
- map<uint64_t, uint64_t>& destmap) = 0;
virtual int fiemap(CollectionHandle& c, const ghobject_t& oid,
- uint64_t offset, size_t len, bufferlist& bl) {
- return fiemap(c->get_cid(), oid, offset, len, bl);
- }
+ uint64_t offset, size_t len, bufferlist& bl) = 0;
virtual int fiemap(CollectionHandle& c, const ghobject_t& oid,
- uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) {
- return fiemap(c->get_cid(), oid, offset, len, destmap);
- }
+ uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) = 0;
/**
* getattr -- get an xattr of an object
* @param value place to put output result.
* @returns 0 on success, negative error code on failure.
*/
- virtual int getattr(const coll_t& cid, const ghobject_t& oid,
- const char *name, bufferptr& value) = 0;
virtual int getattr(CollectionHandle &c, const ghobject_t& oid,
- const char *name, bufferptr& value) {
- return getattr(c->get_cid(), oid, name, value);
- }
+ const char *name, bufferptr& value) = 0;
/**
* getattr -- get an xattr of an object
* @param value place to put output result.
* @returns 0 on success, negative error code on failure.
*/
- int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferlist& value) {
- bufferptr bp;
- int r = getattr(cid, oid, name, bp);
- if (bp.length())
- value.push_back(bp);
- return r;
- }
- int getattr(
- coll_t cid, const ghobject_t& oid,
- const string& name, bufferlist& value) {
- bufferptr bp;
- int r = getattr(cid, oid, name.c_str(), bp);
- value.push_back(bp);
- return r;
- }
int getattr(
CollectionHandle &c, const ghobject_t& oid,
const string& name, bufferlist& value) {
* @param aset place to put output result.
* @returns 0 on success, negative error code on failure.
*/
- virtual int getattrs(const coll_t& cid, const ghobject_t& oid,
- map<string,bufferptr>& aset) = 0;
virtual int getattrs(CollectionHandle &c, const ghobject_t& oid,
- map<string,bufferptr>& aset) {
- return getattrs(c->get_cid(), oid, aset);
- }
+ map<string,bufferptr>& aset) = 0;
/**
* getattrs -- get all of the xattrs of an object
* @param aset place to put output result.
* @returns 0 on success, negative error code on failure.
*/
- int getattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferlist>& aset) {
- map<string,bufferptr> bmap;
- int r = getattrs(cid, oid, bmap);
- for (map<string,bufferptr>::iterator i = bmap.begin();
- i != bmap.end();
- ++i) {
- aset[i->first].append(i->second);
- }
- return r;
- }
int getattrs(CollectionHandle &c, const ghobject_t& oid,
map<string,bufferlist>& aset) {
map<string,bufferptr> bmap;
* @param empty true if the specified collection is empty, false otherwise
* @returns 0 on success, negative error code on failure.
*/
- virtual int collection_empty(const coll_t& c, bool *empty) = 0;
+ virtual int collection_empty(CollectionHandle& c, bool *empty) = 0;
/**
* return the number of significant bits of the coll_t::pgid.
* set. A legacy backend may return -EAGAIN if the value is unavailable
* (because we upgraded from an older version, e.g., FileStore).
*/
- virtual int collection_bits(const coll_t& c) = 0;
+ virtual int collection_bits(CollectionHandle& c) = 0;
/**
* @param next [out] next item sorts >= this value
* @return zero on success, or negative error
*/
- virtual int collection_list(const coll_t& c,
- const ghobject_t& start, const ghobject_t& end,
- int max,
- vector<ghobject_t> *ls, ghobject_t *next) = 0;
virtual int collection_list(CollectionHandle &c,
const ghobject_t& start, const ghobject_t& end,
int max,
- vector<ghobject_t> *ls, ghobject_t *next) {
- return collection_list(c->get_cid(), start, end, max, ls, next);
- }
+ vector<ghobject_t> *ls, ghobject_t *next) = 0;
/// OMAP
/// Get omap contents
- virtual int omap_get(
- const coll_t& 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
- ) = 0;
virtual 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
- ) {
- return omap_get(c->get_cid(), oid, header, out);
- }
+ ) = 0;
/// Get omap header
- virtual int omap_get_header(
- const coll_t& 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
- ) = 0;
virtual 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
- ) {
- return omap_get_header(c->get_cid(), oid, header, allow_eio);
- }
+ ) = 0;
/// Get keys defined on oid
- virtual int omap_get_keys(
- const coll_t& c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- set<string> *keys ///< [out] Keys defined on oid
- ) = 0;
virtual 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
- ) {
- return omap_get_keys(c->get_cid(), oid, keys);
- }
+ ) = 0;
/// Get key values
- virtual int omap_get_values(
- const coll_t& 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
- ) = 0;
virtual 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
- ) {
- return omap_get_values(c->get_cid(), oid, keys, out);
- }
+ ) = 0;
/// Filters keys into out which are defined on oid
- virtual int omap_check_keys(
- const coll_t& 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
- ) = 0;
virtual 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
- ) {
- return omap_check_keys(c->get_cid(), oid, keys, out);
- }
+ ) = 0;
/**
* Returns an object map iterator
*
* @return iterator, null on error
*/
- virtual ObjectMap::ObjectMapIterator get_omap_iterator(
- const coll_t& c, ///< [in] collection
- const ghobject_t &oid ///< [in] object
- ) = 0;
virtual ObjectMap::ObjectMapIterator get_omap_iterator(
CollectionHandle &c, ///< [in] collection
const ghobject_t &oid ///< [in] object
- ) {
- return get_omap_iterator(c->get_cid(), oid);
- }
+ ) = 0;
virtual int flush_journal() { return -EOPNOTSUPP; }
return c;
}
-bool BlueStore::exists(const coll_t& cid, const ghobject_t& oid)
-{
- 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());
return r;
}
-int BlueStore::stat(
- const coll_t& cid,
- const ghobject_t& oid,
- struct stat *st,
- bool allow_eio)
-{
- 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,
return r;
}
int BlueStore::set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& ch,
const pool_opts_t& opts)
{
- CollectionHandle ch = _get_collection(cid);
- if (!ch)
- return -ENOENT;
Collection *c = static_cast<Collection *>(ch.get());
- dout(15) << __func__ << " " << cid << " options " << opts << dendl;
+ dout(15) << __func__ << " " << ch->cid << " options " << opts << dendl;
if (!c->exists)
return -ENOENT;
RWLock::WLocker l(c->lock);
return 0;
}
-int BlueStore::read(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t length,
- bufferlist& bl,
- uint32_t op_flags)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return read(c, oid, offset, length, bl, op_flags);
-}
-
int BlueStore::read(
CollectionHandle &c_,
const ghobject_t& oid,
return 0;
}
-int BlueStore::fiemap(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- bufferlist& bl)
-{
- 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,
return r;
}
-int BlueStore::fiemap(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- map<uint64_t, uint64_t>& destmap)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return fiemap(c, oid, offset, len, destmap);
-}
-
int BlueStore::fiemap(
CollectionHandle &c_,
const ghobject_t& oid,
return r;
}
-int BlueStore::getattr(
- const coll_t& cid,
- const ghobject_t& oid,
- const char *name,
- bufferptr& value)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return getattr(c, oid, name, value);
-}
-
int BlueStore::getattr(
CollectionHandle &c_,
const ghobject_t& oid,
return r;
}
-
-int BlueStore::getattrs(
- const coll_t& cid,
- const ghobject_t& oid,
- map<string,bufferptr>& aset)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return getattrs(c, oid, aset);
-}
-
int BlueStore::getattrs(
CollectionHandle &c_,
const ghobject_t& oid,
return coll_map.count(c);
}
-int BlueStore::collection_empty(const coll_t& cid, bool *empty)
+int BlueStore::collection_empty(CollectionHandle& ch, bool *empty)
{
- dout(15) << __func__ << " " << cid << dendl;
+ dout(15) << __func__ << " " << ch->cid << dendl;
vector<ghobject_t> ls;
ghobject_t next;
- int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), 1,
+ int r = collection_list(ch, ghobject_t(), ghobject_t::get_max(), 1,
&ls, &next);
if (r < 0) {
derr << __func__ << " collection_list returned: " << cpp_strerror(r)
return r;
}
*empty = ls.empty();
- dout(10) << __func__ << " " << cid << " = " << (int)(*empty) << dendl;
+ dout(10) << __func__ << " " << ch->cid << " = " << (int)(*empty) << dendl;
return 0;
}
-int BlueStore::collection_bits(const coll_t& cid)
+int BlueStore::collection_bits(CollectionHandle& ch)
{
- dout(15) << __func__ << " " << cid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
- dout(10) << __func__ << " " << cid << " = " << c->cnode.bits << dendl;
+ dout(10) << __func__ << " " << ch->cid << " = " << c->cnode.bits << dendl;
return c->cnode.bits;
}
-int BlueStore::collection_list(
- const coll_t& cid, const ghobject_t& start, const ghobject_t& end, int max,
- vector<ghobject_t> *ls, ghobject_t *pnext)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return collection_list(c, start, end, max, ls, pnext);
-}
-
int BlueStore::collection_list(
CollectionHandle &c_, const ghobject_t& start, const ghobject_t& end, int max,
vector<ghobject_t> *ls, ghobject_t *pnext)
return r;
}
-int BlueStore::omap_get(
- const 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
- )
-{
- 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
return r;
}
-int BlueStore::omap_get_header(
- const coll_t& cid, ///< [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
- )
-{
- 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
return r;
}
-int BlueStore::omap_get_keys(
- const coll_t& cid, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- set<string> *keys ///< [out] Keys defined on oid
- )
-{
- 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
return r;
}
-int BlueStore::omap_get_values(
- const coll_t& cid, ///< [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
- )
-{
- 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
return r;
}
-int BlueStore::omap_check_keys(
- const coll_t& cid, ///< [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
- )
-{
- 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
return r;
}
-ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
- const coll_t& cid, ///< [in] collection
- const ghobject_t &oid ///< [in] object
- )
-{
- 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
void collect_metadata(map<string,string> *pm) override;
- bool exists(const coll_t& cid, const ghobject_t& oid) override;
bool exists(CollectionHandle &c, const ghobject_t& oid) override;
int set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& c,
const pool_opts_t& opts) override;
- int stat(
- const coll_t& cid,
- const ghobject_t& oid,
- struct stat *st,
- bool allow_eio = false) override;
int stat(
CollectionHandle &c,
const ghobject_t& oid,
struct stat *st,
bool allow_eio = false) override;
- int read(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- bufferlist& bl,
- uint32_t op_flags = 0) override;
int read(
CollectionHandle &c,
const ghobject_t& oid,
int _fiemap(CollectionHandle &c_, const ghobject_t& oid,
uint64_t offset, size_t len, interval_set<uint64_t>& destset);
public:
- int fiemap(const 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 fiemap(const coll_t& cid, const ghobject_t& oid,
- uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
int fiemap(CollectionHandle &c, const ghobject_t& oid,
uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
- int getattr(const 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(const 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;
CollectionHandle create_new_collection(const coll_t& cid) override;
bool collection_exists(const coll_t& c) override;
- int collection_empty(const coll_t& c, bool *empty) override;
- int collection_bits(const coll_t& c) override;
+ int collection_empty(CollectionHandle& c, bool *empty) override;
+ int collection_bits(CollectionHandle& c) override;
- int collection_list(const coll_t& cid,
- const ghobject_t& start,
- const ghobject_t& end,
- int max,
- vector<ghobject_t> *ls, ghobject_t *next) override;
int collection_list(CollectionHandle &c,
const ghobject_t& start,
const ghobject_t& end,
int max,
vector<ghobject_t> *ls, ghobject_t *next) override;
- int omap_get(
- const 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
) override;
/// Get omap header
- int omap_get_header(
- const coll_t& cid, ///< [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;
int omap_get_header(
CollectionHandle &c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
) override;
/// Get keys defined on oid
- int omap_get_keys(
- const 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
) override;
/// Get key values
- int omap_get_values(
- const coll_t& cid, ///< [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;
int omap_get_values(
CollectionHandle &c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
) override;
/// Filters keys into out which are defined on oid
- int omap_check_keys(
- const coll_t& cid, ///< [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;
int omap_check_keys(
CollectionHandle &c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
set<string> *out ///< [out] Subset of keys defined on oid
) override;
- ObjectMap::ObjectMapIterator get_omap_iterator(
- const 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
// --------------------
// objects
-bool FileStore::exists(const coll_t& _cid, const ghobject_t& oid)
+bool FileStore::exists(CollectionHandle& ch, const ghobject_t& oid)
{
- tracepoint(objectstore, exists_enter, _cid.c_str());
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, exists_enter, ch->cid.c_str());
struct stat st;
- bool retval = stat(cid, oid, &st) == 0;
+ bool retval = stat(ch, oid, &st) == 0;
tracepoint(objectstore, exists_exit, retval);
return retval;
}
int FileStore::stat(
- const coll_t& _cid, const ghobject_t& oid, struct stat *st, bool allow_eio)
+ CollectionHandle& ch, const ghobject_t& oid, struct stat *st, bool allow_eio)
{
- tracepoint(objectstore, stat_enter, _cid.c_str());
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, stat_enter, ch->cid.c_str());
+ const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
int r = lfn_stat(cid, oid, st);
assert(allow_eio || !m_filestore_fail_eio || r != -EIO);
if (r < 0) {
- dout(10) << __FUNC__ << ": " << cid << "/" << oid
+ dout(10) << __FUNC__ << ": " << ch->cid << "/" << oid
<< " = " << r << dendl;
} else {
- dout(10) << __FUNC__ << ": " << cid << "/" << oid
+ dout(10) << __FUNC__ << ": " << ch->cid << "/" << oid
<< " = " << r
<< " (size " << st->st_size << ")" << dendl;
}
}
int FileStore::set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& ch,
const pool_opts_t& opts)
{
return -EOPNOTSUPP;
}
int FileStore::read(
- const coll_t& _cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
uint64_t offset,
size_t len,
uint32_t op_flags)
{
int got;
- tracepoint(objectstore, read_enter, _cid.c_str(), offset, len);
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, read_enter, ch->cid.c_str(), offset, len);
+ const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << cid << "/" << oid << " " << offset << "~" << len << dendl;
#endif
}
-int FileStore::fiemap(const coll_t& _cid, const ghobject_t& oid,
+int FileStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
uint64_t offset, size_t len,
bufferlist& bl)
{
map<uint64_t, uint64_t> exomap;
- int r = fiemap(_cid, oid, offset, len, exomap);
+ int r = fiemap(ch, oid, offset, len, exomap);
if (r >= 0) {
encode(exomap, bl);
}
return r;
}
-int FileStore::fiemap(const coll_t& _cid, const ghobject_t& oid,
+int FileStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
uint64_t offset, size_t len,
map<uint64_t, uint64_t>& destmap)
{
- tracepoint(objectstore, fiemap_enter, _cid.c_str(), offset, len);
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, fiemap_enter, ch->cid.c_str(), offset, len);
+ const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
destmap.clear();
if ((!backend->has_seek_data_hole() && !backend->has_fiemap()) ||
// objects
-int FileStore::getattr(const coll_t& _cid, const ghobject_t& oid, const char *name, bufferptr &bp)
+int FileStore::getattr(CollectionHandle& ch, const ghobject_t& oid, const char *name, bufferptr &bp)
{
- tracepoint(objectstore, getattr_enter, _cid.c_str());
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, getattr_enter, ch->cid.c_str());
+ const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << cid << "/" << oid << " '" << name << "'" << dendl;
FDRef fd;
int r = lfn_open(cid, oid, false, &fd);
}
}
-int FileStore::getattrs(const coll_t& _cid, const ghobject_t& oid, map<string,bufferptr>& aset)
+int FileStore::getattrs(CollectionHandle& ch, const ghobject_t& oid, map<string,bufferptr>& aset)
{
- tracepoint(objectstore, getattrs_enter, _cid.c_str());
- const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+ tracepoint(objectstore, getattrs_enter, ch->cid.c_str());
+ const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
set<string> omap_attrs;
map<string, bufferlist> omap_aset;
Index index;
return ret;
}
-int FileStore::collection_empty(const coll_t& c, bool *empty)
+int FileStore::collection_empty(const coll_t& cid, bool *empty)
{
- tracepoint(objectstore, collection_empty_enter, c.c_str());
- dout(15) << __FUNC__ << ": " << c << dendl;
+ tracepoint(objectstore, collection_empty_enter, cid.c_str());
+ dout(15) << __FUNC__ << ": " << cid << dendl;
Index index;
- int r = get_index(c, &index);
+ int r = get_index(cid, &index);
if (r < 0) {
derr << __FUNC__ << ": get_index returned: " << cpp_strerror(r)
<< dendl;
return r;
}
-int FileStore::collection_bits(const coll_t& c)
+int FileStore::collection_bits(CollectionHandle& ch)
{
char fn[PATH_MAX];
- get_cdir(c, fn, sizeof(fn));
+ get_cdir(ch->cid, fn, sizeof(fn));
dout(15) << __FUNC__ << ": " << fn << dendl;
int r;
char n[PATH_MAX];
return 0;
}
-int FileStore::omap_get(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_get(CollectionHandle& ch, const ghobject_t &hoid,
bufferlist *header,
map<string, bufferlist> *out)
{
- tracepoint(objectstore, omap_get_enter, _c.c_str());
- const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+ tracepoint(objectstore, omap_get_enter, ch->cid.c_str());
+ const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
Index index;
int r = get_index(c, &index);
}
int FileStore::omap_get_header(
- const coll_t& _c,
+ CollectionHandle& ch,
const ghobject_t &hoid,
bufferlist *bl,
bool allow_eio)
{
- tracepoint(objectstore, omap_get_header_enter, _c.c_str());
- const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+ tracepoint(objectstore, omap_get_header_enter, ch->cid.c_str());
+ const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
Index index;
int r = get_index(c, &index);
return 0;
}
-int FileStore::omap_get_keys(const coll_t& _c, const ghobject_t &hoid, set<string> *keys)
+int FileStore::omap_get_keys(CollectionHandle& ch, const ghobject_t &hoid, set<string> *keys)
{
- tracepoint(objectstore, omap_get_keys_enter, _c.c_str());
- const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+ tracepoint(objectstore, omap_get_keys_enter, ch->cid.c_str());
+ const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
Index index;
int r = get_index(c, &index);
return 0;
}
-int FileStore::omap_get_values(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_get_values(CollectionHandle& ch, const ghobject_t &hoid,
const set<string> &keys,
map<string, bufferlist> *out)
{
- tracepoint(objectstore, omap_get_values_enter, _c.c_str());
- const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+ tracepoint(objectstore, omap_get_values_enter, ch->cid.c_str());
+ const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
Index index;
const char *where = "()";
return r;
}
-int FileStore::omap_check_keys(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_check_keys(CollectionHandle& ch, const ghobject_t &hoid,
const set<string> &keys,
set<string> *out)
{
- tracepoint(objectstore, omap_check_keys_enter, _c.c_str());
- const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+ tracepoint(objectstore, omap_check_keys_enter, ch->cid.c_str());
+ const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
Index index;
return 0;
}
using ObjectStore::exists;
- bool exists(const coll_t& cid, const ghobject_t& oid) override;
+ bool exists(CollectionHandle& c, const ghobject_t& oid) override;
using ObjectStore::stat;
int stat(
- const coll_t& cid,
+ CollectionHandle& c,
const ghobject_t& oid,
struct stat *st,
bool allow_eio = false) override;
using ObjectStore::set_collection_opts;
int set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& c,
const pool_opts_t& opts) override;
using ObjectStore::read;
int read(
- const coll_t& cid,
+ CollectionHandle& c,
const ghobject_t& oid,
uint64_t offset,
size_t len,
int _do_seek_hole_data(int fd, uint64_t offset, size_t len,
map<uint64_t, uint64_t> *m);
using ObjectStore::fiemap;
- int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override;
- int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+ int fiemap(CollectionHandle& c, 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, map<uint64_t, uint64_t>& destmap) override;
int _touch(const coll_t& cid, const ghobject_t& oid);
int _write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len,
// attrs
using ObjectStore::getattr;
using ObjectStore::getattrs;
- int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr &bp) override;
- int getattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferptr>& aset) override;
+ int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, bufferptr &bp) override;
+ int getattrs(CollectionHandle& c, const ghobject_t& oid, map<string,bufferptr>& aset) override;
int _setattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferptr>& aset,
const SequencerPosition &spos);
// collections
using ObjectStore::collection_list;
- int collection_bits(const coll_t& c) override;
- int collection_list(const coll_t& c,
+ int collection_bits(CollectionHandle& c) override;
+ int collection_list(CollectionHandle& c,
const ghobject_t& start, const ghobject_t& end, int max,
- vector<ghobject_t> *ls, ghobject_t *next) override;
+ vector<ghobject_t> *ls, ghobject_t *next) override {
+ return collection_list(c->cid, start, end, max, ls, next);
+ }
+ int collection_list(const coll_t& cid,
+ const ghobject_t& start, const ghobject_t& end, int max,
+ vector<ghobject_t> *ls, ghobject_t *next);
int list_collections(vector<coll_t>& ls) override;
int list_collections(vector<coll_t>& ls, bool include_temp);
int collection_stat(const coll_t& c, struct stat *st);
bool collection_exists(const coll_t& c) override;
- int collection_empty(const coll_t& c, bool *empty) override;
+ int collection_empty(CollectionHandle& c, bool *empty) override {
+ return collection_empty(c->cid, empty);
+ }
+ int collection_empty(const coll_t& cid, bool *empty);
// omap (see ObjectStore.h for documentation)
using ObjectStore::omap_get;
- int omap_get(const coll_t& c, const ghobject_t &oid, bufferlist *header,
+ int omap_get(CollectionHandle& c, const ghobject_t &oid, bufferlist *header,
map<string, bufferlist> *out) override;
using ObjectStore::omap_get_header;
int omap_get_header(
- const coll_t& c,
+ CollectionHandle& c,
const ghobject_t &oid,
bufferlist *out,
bool allow_eio = false) override;
using ObjectStore::omap_get_keys;
- int omap_get_keys(const coll_t& c, const ghobject_t &oid, set<string> *keys) override;
+ int omap_get_keys(CollectionHandle& c, const ghobject_t &oid, set<string> *keys) override;
using ObjectStore::omap_get_values;
- int omap_get_values(const coll_t& c, const ghobject_t &oid, const set<string> &keys,
+ int omap_get_values(CollectionHandle& c, const ghobject_t &oid, const set<string> &keys,
map<string, bufferlist> *out) override;
using ObjectStore::omap_check_keys;
- int omap_check_keys(const coll_t& c, const ghobject_t &oid, const set<string> &keys,
+ int omap_check_keys(CollectionHandle& c, const ghobject_t &oid, const set<string> &keys,
set<string> *out) override;
using ObjectStore::get_omap_iterator;
- ObjectMap::ObjectMapIterator get_omap_iterator(const coll_t& c, const ghobject_t &oid) override;
+ ObjectMap::ObjectMapIterator get_omap_iterator(CollectionHandle& c, const ghobject_t &oid) override {
+ return get_omap_iterator(c->cid, oid);
+ }
+ ObjectMap::ObjectMapIterator get_omap_iterator(const coll_t& cid, const ghobject_t &oid);
int _create_collection(const coll_t& c, int bits,
const SequencerPosition &spos);
// ---------------
// read operations
-bool KStore::exists(const coll_t& cid, const ghobject_t& oid)
+bool KStore::exists(CollectionHandle& ch, const ghobject_t& oid)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return false;
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists)
}
int KStore::stat(
- const coll_t& cid,
- const ghobject_t& oid,
- struct stat *st,
- bool allow_eio)
+ CollectionHandle& ch,
+ const ghobject_t& oid,
+ struct stat *st,
+ bool allow_eio)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists)
}
int KStore::set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& ch,
const pool_opts_t& opts)
{
return -EOPNOTSUPP;
}
int KStore::read(
- const coll_t& cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
uint64_t offset,
size_t length,
bufferlist& bl,
uint32_t op_flags)
{
- dout(15) << __func__ << " " << cid << " " << oid
+ dout(15) << __func__ << " " << ch->cid << " " << oid
<< " " << offset << "~" << length
<< dendl;
bl.clear();
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
int r;
r = _do_read(o, offset, length, bl, op_flags);
out:
- dout(10) << __func__ << " " << cid << " " << oid
+ dout(10) << __func__ << " " << ch->cid << " " << oid
<< " " << offset << "~" << length
<< " = " << r << dendl;
return r;
}
int KStore::fiemap(
- const coll_t& cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
uint64_t offset,
size_t len,
bufferlist& bl)
{
map<uint64_t, uint64_t> m;
- int r = fiemap(cid, oid, offset, len, m);
+ int r = fiemap(ch, oid, offset, len, m);
if (r >= 0) {
encode(m, bl);
}
-
return r;
}
int KStore::fiemap(
- const coll_t& cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
uint64_t offset,
size_t len,
map<uint64_t, uint64_t>& destmap)
{
- CollectionRef c = _get_collection(cid);
+ CollectionRef c = static_cast<Collection*>(ch.get());
if (!c)
return -ENOENT;
RWLock::RLocker l(c->lock);
}
int KStore::getattr(
- const coll_t& cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
const char *name,
bufferptr& value)
{
- dout(15) << __func__ << " " << cid << " " << oid << " " << name << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " " << oid << " " << name << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " " << oid << " " << name
<< " = " << r << dendl;
return r;
}
int KStore::getattrs(
- const coll_t& cid,
+ CollectionHandle& ch,
const ghobject_t& oid,
map<string,bufferptr>& aset)
{
- dout(15) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
int r;
aset = o->onode.attrs;
r = 0;
out:
- dout(10) << __func__ << " " << cid << " " << oid
+ dout(10) << __func__ << " " << ch->cid << " " << oid
<< " = " << r << dendl;
return r;
}
return coll_map.count(c);
}
-int KStore::collection_empty(const coll_t& cid, bool *empty)
+int KStore::collection_empty(CollectionHandle& ch, bool *empty)
{
- dout(15) << __func__ << " " << cid << dendl;
+ dout(15) << __func__ << " " << ch->cid << dendl;
vector<ghobject_t> ls;
ghobject_t next;
- int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), 1,
+ int r = collection_list(ch, ghobject_t(), ghobject_t::get_max(), 1,
&ls, &next);
if (r < 0) {
derr << __func__ << " collection_list returned: " << cpp_strerror(r)
return r;
}
*empty = ls.empty();
- dout(10) << __func__ << " " << cid << " = " << (int)(*empty) << dendl;
+ dout(10) << __func__ << " " << ch->cid << " = " << (int)(*empty) << dendl;
return 0;
}
-int KStore::collection_bits(const coll_t& cid)
+int KStore::collection_bits(CollectionHandle& ch)
{
- dout(15) << __func__ << " " << cid << dendl;
- CollectionHandle ch = _get_collection(cid);
- if (!ch)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << dendl;
Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
- dout(10) << __func__ << " " << cid << " = " << c->cnode.bits << dendl;
+ dout(10) << __func__ << " " << ch->cid << " = " << c->cnode.bits << dendl;
return c->cnode.bits;
}
-int KStore::collection_list(
- const coll_t& cid, const ghobject_t& start, const ghobject_t& end, int max,
- vector<ghobject_t> *ls, ghobject_t *pnext)
-{
- CollectionHandle c = _get_collection(cid);
- if (!c)
- return -ENOENT;
- return collection_list(c, start, end, max, ls, pnext);
-}
-
int KStore::collection_list(
CollectionHandle &c_, const ghobject_t& start, const ghobject_t& end, int max,
vector<ghobject_t> *ls, ghobject_t *pnext)
}
int KStore::omap_get(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& ch, ///< [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
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
return r;
}
int KStore::omap_get_header(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& ch, ///< [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
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
return r;
}
int KStore::omap_get_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& ch, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
set<string> *keys ///< [out] Keys defined on oid
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
return r;
}
int KStore::omap_get_values(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& ch, ///< [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
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
return r;
}
int KStore::omap_check_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& ch, ///< [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
)
{
- dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
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__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
return r;
}
ObjectMap::ObjectMapIterator KStore::get_omap_iterator(
- const coll_t& cid, ///< [in] collection
+ CollectionHandle& ch, ///< [in] collection
const ghobject_t &oid ///< [in] object
)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = _get_collection(cid);
- if (!c) {
- dout(10) << __func__ << " " << cid << "doesn't exist" <<dendl;
- return ObjectMap::ObjectMapIterator();
- }
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists) {
CollectionHandle create_new_collection(const coll_t& c) override;
using ObjectStore::exists;
- bool exists(const coll_t& cid, const ghobject_t& oid) override;
+ bool exists(CollectionHandle& c, const ghobject_t& oid) override;
using ObjectStore::stat;
int stat(
- const coll_t& cid,
+ CollectionHandle& c,
const ghobject_t& oid,
struct stat *st,
bool allow_eio = false) override; // struct stat?
int set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& c,
const pool_opts_t& opts) override;
using ObjectStore::read;
int read(
- const coll_t& cid,
+ CollectionHandle& c,
const ghobject_t& oid,
uint64_t offset,
size_t len,
uint32_t op_flags = 0);
using ObjectStore::fiemap;
- int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override;
- int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+ int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+ int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& outbl) override;
using ObjectStore::getattr;
- int getattr(const 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;
using ObjectStore::getattrs;
- int getattrs(const 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;
bool collection_exists(const coll_t& c) override;
- int collection_empty(const coll_t& c, bool *empty) override;
- int collection_bits(const coll_t& c) override;
- int collection_list(
- const coll_t& cid, const ghobject_t& start, const ghobject_t& end,
- int max,
- vector<ghobject_t> *ls, ghobject_t *next) override;
+ int collection_empty(CollectionHandle& c, bool *empty) override;
+ int collection_bits(CollectionHandle& c) override;
int collection_list(
CollectionHandle &c, const ghobject_t& start, const ghobject_t& end,
int max,
using ObjectStore::omap_get;
int omap_get(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_get_header;
/// Get omap header
int omap_get_header(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_get_keys;
/// Get keys defined on oid
int omap_get_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
set<string> *keys ///< [out] Keys defined on oid
) override;
using ObjectStore::omap_get_values;
/// Get key values
int omap_get_values(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_check_keys;
/// Filters keys into out which are defined on oid
int omap_check_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::get_omap_iterator;
ObjectMap::ObjectMapIterator get_omap_iterator(
- const coll_t& cid, ///< [in] collection
+ CollectionHandle& c, ///< [in] collection
const ghobject_t &oid ///< [in] object
) override;
// ---------------
// read operations
-bool MemStore::exists(const coll_t& cid, const ghobject_t& oid)
-{
- CollectionHandle c = get_collection(cid);
- if (!c)
- return false;
- return exists(c, oid);
-}
-
bool MemStore::exists(CollectionHandle &c_, const ghobject_t& oid)
{
Collection *c = static_cast<Collection*>(c_.get());
return (bool)c->get_object(oid);
}
-int MemStore::stat(
- const coll_t& cid,
- const ghobject_t& oid,
- struct stat *st,
- bool allow_eio)
-{
- CollectionHandle c = get_collection(cid);
- if (!c)
- return -ENOENT;
- return stat(c, oid, st, allow_eio);
-}
-
int MemStore::stat(
CollectionHandle &c_,
const ghobject_t& oid,
}
int MemStore::set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& ch,
const pool_opts_t& opts)
{
return -EOPNOTSUPP;
}
-int MemStore::read(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- bufferlist& bl,
- uint32_t op_flags)
-{
- CollectionHandle c = get_collection(cid);
- if (!c)
- return -ENOENT;
- return read(c, oid, offset, len, bl, op_flags);
-}
-
int MemStore::read(
CollectionHandle &c_,
const ghobject_t& oid,
return o->read(offset, l, bl);
}
-int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid,
+int MemStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
uint64_t offset, size_t len, bufferlist& bl)
{
map<uint64_t, uint64_t> destmap;
- int r = fiemap(cid, oid, offset, len, destmap);
+ int r = fiemap(ch, oid, offset, len, destmap);
if (r >= 0)
encode(destmap, bl);
return r;
}
-int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid,
+int MemStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap)
{
- dout(10) << __func__ << " " << cid << " " << oid << " " << offset << "~"
+ dout(10) << __func__ << " " << ch->cid << " " << oid << " " << offset << "~"
<< len << dendl;
- CollectionRef c = get_collection(cid);
+ Collection *c = static_cast<Collection*>(ch.get());
if (!c)
return -ENOENT;
return 0;
}
-int MemStore::getattr(const coll_t& cid, const ghobject_t& oid,
- const char *name, bufferptr& value)
-{
- CollectionHandle c = get_collection(cid);
- if (!c)
- return -ENOENT;
- return getattr(c, oid, name, value);
-}
-
int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid,
const char *name, bufferptr& value)
{
return 0;
}
-int MemStore::getattrs(const coll_t& cid, const ghobject_t& oid,
- map<string,bufferptr>& aset)
-{
- CollectionHandle c = get_collection(cid);
- if (!c)
- return -ENOENT;
- return getattrs(c, oid, aset);
-}
-
int MemStore::getattrs(CollectionHandle &c_, const ghobject_t& oid,
map<string,bufferptr>& aset)
{
return coll_map.count(cid);
}
-int MemStore::collection_empty(const coll_t& cid, bool *empty)
+int MemStore::collection_empty(CollectionHandle& ch, bool *empty)
{
- dout(10) << __func__ << " " << cid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(10) << __func__ << " " << ch->cid << dendl;
+ CollectionRef c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
*empty = c->object_map.empty();
return 0;
}
-int MemStore::collection_bits(const coll_t& cid)
+int MemStore::collection_bits(CollectionHandle& ch)
{
- dout(10) << __func__ << " " << cid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(10) << __func__ << " " << ch->cid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
return c->bits;
}
-int MemStore::collection_list(const coll_t& cid,
+int MemStore::collection_list(CollectionHandle& ch,
const ghobject_t& start,
const ghobject_t& end,
int max,
vector<ghobject_t> *ls, ghobject_t *next)
{
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
+ Collection *c = static_cast<Collection*>(ch.get());
RWLock::RLocker l(c->lock);
- dout(10) << __func__ << " cid " << cid << " start " << start
+ dout(10) << __func__ << " cid " << ch->cid << " start " << start
<< " end " << end << dendl;
map<ghobject_t,ObjectRef>::iterator p = c->object_map.lower_bound(start);
while (p != c->object_map.end() &&
else
*next = p->first;
}
- dout(10) << __func__ << " cid " << cid << " got " << ls->size() << dendl;
+ dout(10) << __func__ << " cid " << ch->cid << " got " << ls->size() << dendl;
return 0;
}
int MemStore::omap_get(
- const 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
- )
+ CollectionHandle& ch, ///< [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
+ )
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
}
int MemStore::omap_get_header(
- const coll_t& cid, ///< [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
- )
+ CollectionHandle& ch, ///< [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
+ )
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
-
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
return -ENOENT;
}
int MemStore::omap_get_keys(
- const coll_t& cid, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- set<string> *keys ///< [out] Keys defined on oid
- )
+ CollectionHandle& ch, ///< [in] Collection containing oid
+ const ghobject_t &oid, ///< [in] Object containing omap
+ set<string> *keys ///< [out] Keys defined on oid
+ )
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
-
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
return -ENOENT;
}
int MemStore::omap_get_values(
- const coll_t& cid, ///< [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
- )
+ CollectionHandle& ch, ///< [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
+ )
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
-
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
return -ENOENT;
}
int MemStore::omap_check_keys(
- const coll_t& cid, ///< [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
- )
+ CollectionHandle& ch, ///< [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
+ )
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
-
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
return -ENOENT;
}
};
-ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(const coll_t& cid,
- const ghobject_t& oid)
+ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(
+ CollectionHandle& ch,
+ const ghobject_t& oid)
{
- dout(10) << __func__ << " " << cid << " " << oid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return ObjectMap::ObjectMapIterator();
-
+ dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+ Collection *c = static_cast<Collection*>(ch.get());
ObjectRef o = c->get_object(oid);
if (!o)
return ObjectMap::ObjectMapIterator();
int statfs(struct store_statfs_t *buf) override;
- bool exists(const coll_t& cid, const ghobject_t& oid) override;
bool exists(CollectionHandle &c, const ghobject_t& oid) override;
- int stat(const coll_t& cid, const ghobject_t& oid,
- struct stat *st, bool allow_eio = false) override;
int stat(CollectionHandle &c, const ghobject_t& oid,
struct stat *st, bool allow_eio = false) override;
int set_collection_opts(
- const coll_t& cid,
+ CollectionHandle& c,
const pool_opts_t& opts) override;
- int read(
- const coll_t& cid,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- bufferlist& bl,
- uint32_t op_flags = 0) override;
int read(
CollectionHandle &c,
const ghobject_t& oid,
bufferlist& bl,
uint32_t op_flags = 0) override;
using ObjectStore::fiemap;
- int fiemap(const coll_t& cid, const ghobject_t& oid,
+ int fiemap(CollectionHandle& c, const ghobject_t& oid,
uint64_t offset, size_t len, bufferlist& bl) override;
- int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset,
+ int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset,
size_t len, map<uint64_t, uint64_t>& destmap) override;
- int getattr(const 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(const 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;
}
CollectionHandle create_new_collection(const coll_t& c) override;
bool collection_exists(const coll_t& c) override;
- int collection_empty(const coll_t& c, bool *empty) override;
- int collection_bits(const coll_t& c) override;
- using ObjectStore::collection_list;
- int collection_list(const coll_t& cid,
+ int collection_empty(CollectionHandle& c, bool *empty) override;
+ int collection_bits(CollectionHandle& c) override;
+ int collection_list(CollectionHandle& cid,
const ghobject_t& start, const ghobject_t& end, int max,
vector<ghobject_t> *ls, ghobject_t *next) override;
using ObjectStore::omap_get;
int omap_get(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_get_header;
/// Get omap header
int omap_get_header(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_get_keys;
/// Get keys defined on oid
int omap_get_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ CollectionHandle& c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
set<string> *keys ///< [out] Keys defined on oid
) override;
using ObjectStore::omap_get_values;
/// Get key values
int omap_get_values(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::omap_check_keys;
/// Filters keys into out which are defined on oid
int omap_check_keys(
- const coll_t& cid, ///< [in] Collection containing oid
+ 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
using ObjectStore::get_omap_iterator;
ObjectMap::ObjectMapIterator get_omap_iterator(
- const coll_t& cid, ///< [in] collection
+ CollectionHandle& c, ///< [in] collection
const ghobject_t &oid ///< [in] object
) override;
}
if (logger)
logger->inc(l_osd_map_bl_cache_miss);
- found = store->read(coll_t::meta(),
+ found = store->read(meta_ch,
OSD::get_osdmap_pobject_name(e), 0, 0, bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
if (found) {
}
if (logger)
logger->inc(l_osd_map_bl_cache_miss);
- found = store->read(coll_t::meta(),
+ found = store->read(meta_ch,
OSD::get_inc_osdmap_pobject_name(e), 0, 0, bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
if (found) {
dout(20) << __func__ << " " << pool << " loading" << dendl;
ghobject_t oid = OSD::make_final_pool_info_oid(pool);
bufferlist bl;
- int r = store->read(coll_t::meta(), oid, 0, 0, bl);
+ int r = store->read(meta_ch, oid, 0, 0, bl);
ceph_assert(r >= 0);
auto blp = bl.begin();
pg_pool_t pi;
OSDSuperblock sb;
bufferlist sbbl;
+ ObjectStore::CollectionHandle ch;
// if we are fed a uuid for this osd, use it.
store->set_fsid(cct->_conf->osd_uuid);
goto free_store;
}
- ret = store->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, sbbl);
- if (ret >= 0) {
+ ch = store->open_collection(coll_t::meta());
+ if (ch) {
+ ret = store->read(ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, sbbl);
+ if (ret < 0) {
+ derr << "OSD::mkfs: have meta collection but no superblock" << dendl;
+ goto free_store;
+ }
/* if we already have superblock, check content of superblock */
dout(0) << " have superblock" << dendl;
bufferlist::iterator p;
if (c.is_pg(&pgid) &&
!osdmap->have_pg_pool(pgid.pool())) {
ghobject_t oid = make_final_pool_info_oid(pgid.pool());
- if (!store->exists(coll_t::meta(), oid)) {
+ if (!store->exists(service.meta_ch, oid)) {
derr << __func__ << " missing pg_pool_t for deleted pool "
<< pgid.pool() << " for pg " << pgid
<< "; please downgrade to luminous and allow "
}
// make sure snap mapper object exists
- if (!store->exists(coll_t::meta(), OSD::make_snapmapper_oid())) {
+ if (!store->exists(service.meta_ch, OSD::make_snapmapper_oid())) {
dout(10) << "init creating/touching snapmapper object" << dendl;
ObjectStore::Transaction t;
t.touch(coll_t::meta(), OSD::make_snapmapper_oid());
int OSD::read_superblock()
{
bufferlist bl;
- int r = store->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
+ int r = store->read(service.meta_ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
if (r < 0)
return r;
ghobject_t next;
while (1) {
vector<ghobject_t> objects;
- store->collection_list(*p, next, ghobject_t::get_max(),
+ auto ch = store->open_collection(*p);
+ assert(ch);
+ store->collection_list(ch, next, ghobject_t::get_max(),
store->get_ideal_list_max(),
&objects, &next);
if (objects.empty())
SnapMapper mapper(cct, &driver, 0, 0, 0, pgid.shard);
vector<ghobject_t> objects;
- store->collection_list(tmp, ghobject_t(), ghobject_t::get_max(),
+ store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
generic_dout(10) << __func__ << " " << objects << dendl;
// delete them.
// pool was deleted; grab final pg_pool_t off disk.
ghobject_t oid = make_final_pool_info_oid(pgid.pool());
bufferlist bl;
- int r = store->read(coll_t::meta(), oid, 0, 0, bl);
+ int r = store->read(service.meta_ch, oid, 0, 0, bl);
ceph_assert(r >= 0);
auto p = bl.begin();
decode(pi, p);
//Debug: Output entire omap
bufferlist hdrbl;
map<string, bufferlist> keyvals;
- r = store->omap_get(coll_t(pgid), ghobject_t(obj), &hdrbl, &keyvals);
- if (r >= 0) {
+ auto ch = store->open_collection(coll_t(pgid));
+ if (!ch) {
+ ss << "unable to open collection for " << pgid;
+ r = -ENOENT;
+ } else {
+ r = store->omap_get(ch, ghobject_t(obj), &hdrbl, &keyvals);
+ if (r >= 0) {
ss << "header=" << string(hdrbl.c_str(), hdrbl.length());
for (map<string, bufferlist>::iterator it = keyvals.begin();
- it != keyvals.end(); ++it)
+ it != keyvals.end(); ++it)
ss << " key=" << (*it).first << " val="
<< string((*it).second.c_str(), (*it).second.length());
- } else {
+ } else {
ss << "error=" << r;
+ }
}
} else if (command == "truncobj") {
int64_t trunclen;
set<string> keys;
keys.insert("_remove");
map<string,bufferlist> values;
- if (store->omap_get_values(coll, pgmeta_oid, keys, &values) == 0 &&
+ auto ch = store->open_collection(coll);
+ assert(ch);
+ if (store->omap_get_values(ch, pgmeta_oid, keys, &values) == 0 &&
values.size() == 1)
return true;
keys.insert(infover_key);
keys.insert(epoch_key);
map<string,bufferlist> values;
- int r = store->omap_get_values(coll, pgmeta_oid, keys, &values);
+ auto ch = store->open_collection(coll);
+ assert(ch);
+ int r = store->omap_get_values(ch, pgmeta_oid, keys, &values);
if (r == 0) {
assert(values.size() == 2);
keys.insert(fastinfo_key);
ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
map<string,bufferlist> values;
- int r = store->omap_get_values(coll, pgmeta_oid, keys, &values);
+ auto ch = store->open_collection(coll);
+ assert(ch);
+ int r = store->omap_get_values(ch, pgmeta_oid, keys, &values);
assert(r == 0);
assert(values.size() == 3 ||
values.size() == 4);
ostringstream oss;
pg_log.read_log_and_missing(
store,
- coll,
+ ch,
pgmeta_oid,
info,
oss,
void PG::update_store_with_options()
{
- auto r = osd->store->set_collection_opts(coll, pool.info.opts);
+ auto r = osd->store->set_collection_opts(ch, pool.info.opts);
if(r < 0 && r != -EOPNOTSUPP) {
derr << __func__ << " set_collection_opts returns error:" << r << dendl;
}
{
if (osd->store->get_type() == "filestore") {
// legacy filestore didn't store collection bit width; fix.
- int bits = osd->store->collection_bits(coll);
+ int bits = osd->store->collection_bits(ch);
if (bits < 0) {
assert(!coll.is_meta()); // otherwise OSD::load_pgs() did a bad thing
bits = info.pgid.get_split_bits(pool.info.get_pg_num());
(int)cct->_conf->osd_target_transaction_size);
ghobject_t next;
osd->store->collection_list(
- coll,
+ ch,
next,
ghobject_t::get_max(),
max,
t.omap_rmkeys(coll, log_oid, to_remove);
}
-void PGLog::rebuild_missing_set_with_deletes(ObjectStore *store,
- coll_t pg_coll,
- const pg_info_t &info)
+void PGLog::rebuild_missing_set_with_deletes(
+ ObjectStore *store,
+ ObjectStore::CollectionHandle& ch,
+ const pg_info_t &info)
{
// save entries not generated from the current log (e.g. added due
// to repair, EIO handling, or divergent_priors).
bufferlist bv;
int r = store->getattr(
- pg_coll,
+ ch,
ghobject_t(i->soid, ghobject_t::NO_GEN, info.pgid.shard),
OI_ATTR,
bv);
pg_missing_t& omissing, pg_shard_t from) const;
void rebuild_missing_set_with_deletes(ObjectStore *store,
- coll_t pg_coll,
+ ObjectStore::CollectionHandle& ch,
const pg_info_t &info);
protected:
void read_log_and_missing(
ObjectStore *store,
- coll_t pg_coll,
+ ObjectStore::CollectionHandle& ch,
ghobject_t pgmeta_oid,
const pg_info_t &info,
ostringstream &oss,
bool debug_verify_stored_missing = false
) {
return read_log_and_missing(
- store, pg_coll, pgmeta_oid, info,
+ store, ch, pgmeta_oid, info,
log, missing, oss,
tolerate_divergent_missing_log,
&clear_divergent_priors,
template <typename missing_type>
static void read_log_and_missing(
ObjectStore *store,
- coll_t pg_coll,
+ ObjectStore::CollectionHandle &ch,
ghobject_t pgmeta_oid,
const pg_info_t &info,
IndexedLog &log,
set<string> *log_keys_debug = nullptr,
bool debug_verify_stored_missing = false
) {
- ldpp_dout(dpp, 20) << "read_log_and_missing coll " << pg_coll
+ ldpp_dout(dpp, 20) << "read_log_and_missing coll " << ch->cid
<< " " << pgmeta_oid << dendl;
// legacy?
struct stat st;
- int r = store->stat(pg_coll, pgmeta_oid, &st);
+ int r = store->stat(ch, pgmeta_oid, &st);
assert(r == 0);
assert(st.st_size == 0);
// will get overridden below if it had been recorded
eversion_t on_disk_can_rollback_to = info.last_update;
eversion_t on_disk_rollback_info_trimmed_to = eversion_t();
- ObjectMap::ObjectMapIterator p = store->get_omap_iterator(pg_coll,
+ ObjectMap::ObjectMapIterator p = store->get_omap_iterator(ch,
pgmeta_oid);
map<eversion_t, hobject_t> divergent_priors;
bool must_rebuild = false;
bufferlist bv;
int r = store->getattr(
- pg_coll,
+ ch,
ghobject_t(i->soid, ghobject_t::NO_GEN, info.pgid.shard),
OI_ATTR,
bv);
}
bufferlist bv;
int r = store->getattr(
- pg_coll,
+ ch,
ghobject_t(i.first, ghobject_t::NO_GEN, info.pgid.shard),
OI_ATTR,
bv);
did.insert(i->second);
bufferlist bv;
int r = store->getattr(
- pg_coll,
+ ch,
ghobject_t(i->second, ghobject_t::NO_GEN, info.pgid.shard),
OI_ATTR,
bv);
bool truncated = false;
if (oi.is_omap()) {
ObjectMap::ObjectMapIterator iter = osd->store->get_omap_iterator(
- coll, ghobject_t(soid)
+ ch, ghobject_t(soid)
);
assert(iter);
iter->upper_bound(start_after);
bufferlist bl;
if (oi.is_omap()) {
ObjectMap::ObjectMapIterator iter = osd->store->get_omap_iterator(
- coll, ghobject_t(soid)
+ ch, ghobject_t(soid)
);
if (!iter) {
result = -ENOENT;
}
bufferlist omap_data;
ObjectMap::ObjectMapIterator iter =
- osd->store->get_omap_iterator(coll, ghobject_t(oi.soid));
+ osd->store->get_omap_iterator(ch, ghobject_t(oi.soid));
assert(iter);
iter->upper_bound(cursor.omap_offset);
for (; iter->valid(); iter->next(false)) {
dout(20) << __func__ << " checking missing set deletes flag. missing = " << pg_log.get_missing() << dendl;
if (!pg_log.get_missing().may_include_deletes &&
get_osdmap()->test_flag(CEPH_OSDMAP_RECOVERY_DELETES)) {
- pg_log.rebuild_missing_set_with_deletes(osd->store, coll, info);
+ pg_log.rebuild_missing_set_with_deletes(osd->store, ch, info);
}
assert(pg_log.get_missing().may_include_deletes == get_osdmap()->test_flag(CEPH_OSDMAP_RECOVERY_DELETES));
}
bufferlist hdrbl;
r = store->omap_get_header(
- coll,
+ ch,
ghobject_t(
poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
&hdrbl, true);
// omap
ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(
- coll,
+ ch,
ghobject_t(
poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard));
assert(iter);
eversion_t v = recovery_info.version;
if (progress.first) {
- int r = store->omap_get_header(coll, ghobject_t(recovery_info.soid), &out_op->omap_header);
+ int r = store->omap_get_header(ch, ghobject_t(recovery_info.soid), &out_op->omap_header);
if(r < 0) {
dout(1) << __func__ << " get omap header failed: " << cpp_strerror(-r) << dendl;
return r;
uint64_t available = cct->_conf->osd_recovery_max_chunk;
if (!progress.omap_complete) {
ObjectMap::ObjectMapIterator iter =
- store->get_omap_iterator(coll,
+ store->get_omap_iterator(ch,
ghobject_t(recovery_info.soid));
assert(iter);
for (iter->lower_bound(progress.omap_recovered_to);
const std::set<std::string> &keys,
std::map<std::string, bufferlist> *out)
{
- return os->omap_get_values(cid, hoid, keys, out);
+ return os->omap_get_values(ch, hoid, keys, out);
}
int OSDriver::get_next(
pair<std::string, bufferlist> *next)
{
ObjectMap::ObjectMapIterator iter =
- os->get_omap_iterator(cid, hoid);
+ os->get_omap_iterator(ch, hoid);
if (!iter) {
ceph_abort();
return -EINVAL;
class OSDriver : public MapCacher::StoreDriver<std::string, bufferlist> {
ObjectStore *os;
- coll_t cid;
+ ObjectStore::CollectionHandle ch;
ghobject_t hoid;
public:
OSTransaction get_transaction(
ObjectStore::Transaction *t) {
- return OSTransaction(cid, hoid, t);
+ return OSTransaction(ch->cid, hoid, t);
}
- OSDriver(ObjectStore *os, coll_t cid, const ghobject_t &hoid) :
- os(os), cid(cid), hoid(hoid) {}
+ OSDriver(ObjectStore *os, const coll_t& cid, const ghobject_t &hoid) :
+ os(os),
+ hoid(hoid) {
+ ch = os->open_collection(cid);
+ }
int get_keys(
const std::set<std::string> &keys,
std::map<std::string, bufferlist> *out) override;
t.create_collection(cid, 0);
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
}
{
}
{
bufferlist bl;
- store->fiemap(cid, oid, 0, 100000, bl);
+ store->fiemap(ch, oid, 0, 100000, bl);
map<uint64_t,uint64_t> m, e;
bufferlist::iterator p = bl.begin();
decode(m, p);
{
//fiemap test from 0 to SKIP_STEP * (MAX_EXTENTS - 1) + 3
bufferlist bl;
- store->fiemap(cid, oid, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3, bl);
+ store->fiemap(ch, oid, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3, bl);
map<uint64_t,uint64_t> m, e;
bufferlist::iterator p = bl.begin();
decode(m, p);
{
// fiemap test from SKIP_STEP to SKIP_STEP * (MAX_EXTENTS - 2) + 3
bufferlist bl;
- store->fiemap(cid, oid, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 2) + 3, bl);
+ store->fiemap(ch, oid, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 2) + 3, bl);
map<uint64_t,uint64_t> m, e;
auto p = bl.begin();
decode(m, p);
ASSERT_EQ(r, 0);
bufferlist in, exp;
- r = store->read(cid, hoid, 0, 0x4000, in);
+ r = store->read(ch, hoid, 0, 0x4000, in);
ASSERT_EQ(0x1000, r);
exp.append(a);
ASSERT_TRUE(bl_eq(exp, in));
ASSERT_EQ(r, 0);
bufferlist in, exp;
- r = store->read(cid, hoid, 0, 0x4000, in);
+ r = store->read(ch, hoid, 0, 0x4000, in);
ASSERT_EQ(0x2000, r);
exp.append(a);
exp.append(b);
ASSERT_EQ(r, 0);
bufferlist in, exp;
- r = store->read(cid, hoid, 0, 0x4000, in);
+ r = store->read(ch, hoid, 0, 0x4000, in);
ASSERT_EQ(0x4000, r);
exp.append(a);
exp.append(b);
ASSERT_EQ(r, 0);
bufferlist in, exp;
- r = store->read(cid, hoid, 0, 0x4000, in);
+ r = store->read(ch, hoid, 0, 0x4000, in);
ASSERT_EQ(0x4000, r);
exp.append(a);
exp.append(b);
}
{
bufferlist in, exp;
- r = store->read(cid, hoid, 0, 0x4000, in);
+ r = store->read(ch, hoid, 0, 0x4000, in);
ASSERT_EQ(0x4000, r);
exp.append(c);
exp.append(b);
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
- bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
ASSERT_EQ(r, 0);
}
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
{
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 15, newdata);
+ r = store->read(ch, hoid, 0, 15, newdata);
ASSERT_EQ(r, 15);
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 15, newdata);
+ r = store->read(ch, hoid, 0, 15, newdata);
ASSERT_EQ(r, 15);
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 30, newdata);
+ r = store->read(ch, hoid, 0, 30, newdata);
ASSERT_EQ(r, 30);
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 40, newdata);
+ r = store->read(ch, hoid, 0, 40, newdata);
ASSERT_EQ(r, 40);
{
bufferlist expected;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
- bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
ASSERT_EQ(r, 0);
}
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
std::string data;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, data.size() , newdata);
+ r = store->read(ch, hoid, 0, data.size() , newdata);
ASSERT_EQ(r, (int)data.size());
{
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0, 711 , newdata);
+ r = store->read(ch, hoid, 0, 711 , newdata);
ASSERT_EQ(r, 711);
{
bufferlist expected;
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0xf00f, data.size(), newdata);
+ r = store->read(ch, hoid, 0xf00f, data.size(), newdata);
ASSERT_EQ(r, int(data.size() - 0xf00f) );
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 0x10000, newdata);
+ r = store->read(ch, hoid, 0, 0x10000, newdata);
ASSERT_EQ(r, (int)0x10000);
{
bufferlist expected;
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0x9000, 711 , newdata);
+ r = store->read(ch, hoid, 0x9000, 711 , newdata);
ASSERT_EQ(r, 711);
{
bufferlist expected;
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0x0, 0x40000, newdata);
+ r = store->read(ch, hoid, 0x0, 0x40000, newdata);
ASSERT_EQ(r, int(0x40000) );
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0, 0x3e000 - 1, newdata);
+ r = store->read(ch, hoid, 0, 0x3e000 - 1, newdata);
ASSERT_EQ(r, (int)0x3e000 - 1);
{
bufferlist expected;
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0x3e000-1, 0x2001, newdata);
+ r = store->read(ch, hoid, 0x3e000-1, 0x2001, newdata);
ASSERT_EQ(r, 0x2001);
{
bufferlist expected;
ASSERT_TRUE(bl_eq(expected, newdata));
}
newdata.clear();
- r = store->read(cid, hoid, 0x0, 0x40000, newdata);
+ r = store->read(ch, hoid, 0x0, 0x40000, newdata);
ASSERT_EQ(r, int(0x40000) );
{
bufferlist expected;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 0x3e000, 0x2000, newdata);
+ r = store->read(ch, hoid, 0x3e000, 0x2000, newdata);
ASSERT_EQ(r, (int)0x2000);
{
bufferlist expected;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
- bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
ASSERT_EQ(r, 0);
}
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
{
ASSERT_EQ(r, 0);
bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
+ r = store->read(ch, hoid, 0, 5, in);
ASSERT_EQ(5, r);
ASSERT_TRUE(bl_eq(orig, in));
}
ASSERT_EQ(r, 0);
bufferlist in;
- r = store->read(cid, hoid, 0, 10, in);
+ r = store->read(ch, hoid, 0, 10, in);
ASSERT_EQ(10, r);
ASSERT_TRUE(bl_eq(exp, in));
}
ASSERT_EQ(r, 0);
bufferlist in;
- r = store->read(cid, hoid, 0, 10, in);
+ r = store->read(ch, hoid, 0, 10, in);
ASSERT_EQ(10, r);
ASSERT_TRUE(bl_eq(exp, in));
}
bufferlist in, exp;
exp.append("abcabcdede");
- r = store->read(cid, hoid, 0, 10, in);
+ r = store->read(ch, hoid, 0, 10, in);
ASSERT_EQ(10, r);
in.hexdump(cout);
ASSERT_TRUE(bl_eq(exp, in));
bufferlist in, exp;
exp.append("abcdefghij");
- r = store->read(cid, hoid, 0, 10, in);
+ r = store->read(ch, hoid, 0, 10, in);
ASSERT_EQ(10, r);
in.hexdump(cout);
ASSERT_TRUE(bl_eq(exp, in));
ASSERT_EQ(r, 0);
bufferlist in;
- r = store->read(cid, hoid, 0, bl.length(), in);
+ r = store->read(ch, hoid, 0, bl.length(), in);
ASSERT_EQ((int)bl.length(), r);
in.hexdump(cout);
ASSERT_TRUE(bl_eq(bl, in));
//test: offset=len=0 mean read all data
bufferlist in;
- r = store->read(cid, hoid, 0, 0, in);
+ r = store->read(ch, hoid, 0, 0, in);
ASSERT_EQ((int)bl.length(), r);
in.hexdump(cout);
ASSERT_TRUE(bl_eq(bl, in));
exp1.append(s1);
exp2.append(s2);
exp3.append(s3);
- r = store->read(cid, hoid, 0x1000-1, 1, in);
+ r = store->read(ch, hoid, 0x1000-1, 1, in);
ASSERT_EQ(1, r);
ASSERT_TRUE(bl_eq(exp1, in));
in.clear();
- r = store->read(cid, hoid, 0x1000, 0x1000, in);
+ r = store->read(ch, hoid, 0x1000, 0x1000, in);
ASSERT_EQ(0x1000, r);
ASSERT_TRUE(bl_eq(exp2, in));
ASSERT_EQ(r, 0);
}
in.clear();
- r = store->read(cid, hoid, 1, 2, in);
+ r = store->read(ch, hoid, 1, 2, in);
ASSERT_EQ(2, r);
ASSERT_TRUE(bl_eq(exp3, in));
in.clear();
- r = store->read(cid, hoid, 0x1000-1, 1, in);
+ r = store->read(ch, hoid, 0x1000-1, 1, in);
ASSERT_EQ(1, r);
ASSERT_TRUE(bl_eq(exp1, in));
in.clear();
- r = store->read(cid, hoid, 0x1000, 0x1000, in);
+ r = store->read(ch, hoid, 0x1000, 0x1000, in);
ASSERT_EQ(0x1000, r);
ASSERT_TRUE(bl_eq(exp2, in));
ghobject_t hoid2 = hoid;
hoid2.hobj.snap = 1;
{
- bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
ASSERT_EQ(r, 0);
}
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
{
ASSERT_EQ(r, 0);
}
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
{
ASSERT_EQ(0x20000, statfs.stored);
ASSERT_EQ(0x20000, statfs.allocated);
- r = store->read(cid, hoid, 0, data.size(), newdata);
+ r = store->read(ch, hoid, 0, data.size(), newdata);
ASSERT_EQ(r, (int)data.size());
{
bufferlist expected;
}
newdata.clear();
- r = store->read(cid, hoid, 1, data.size()-2, newdata);
+ r = store->read(ch, hoid, 1, data.size()-2, newdata);
ASSERT_EQ(r, (int)data.size()-2);
{
bufferlist expected;
ASSERT_EQ(0x20000, statfs.allocated);
ASSERT_EQ(0x20000, statfs.stored);
- r = store->read(cid, hoid, 0x20000-1, 21, newdata);
+ r = store->read(ch, hoid, 0x20000-1, 21, newdata);
ASSERT_EQ(r, (int)21);
{
bufferlist expected;
ASSERT_EQ(0x30000, statfs.allocated);
ASSERT_EQ(0x20003, statfs.stored);
- r = store->read(cid, hoid, 0x10000-1, 0x10000+22, newdata);
+ r = store->read(ch, hoid, 0x10000-1, 0x10000+22, newdata);
ASSERT_EQ(r, (int)0x10000+22);
{
bufferlist expected;
ASSERT_EQ(0x10000, statfs.allocated);
ASSERT_EQ(0x10000, statfs.stored);
- r = store->read(cid, hoid, 0, 0x30000, newdata);
+ r = store->read(ch, hoid, 0, 0x30000, newdata);
ASSERT_EQ(r, (int)0x30000);
{
bufferlist expected;
d.wait();
{
bufferlist bl2;
- r = store->read(cid, a, 0, 16000, bl2);
+ r = store->read(ch, a, 0, 16000, bl2);
ASSERT_GE(r, 0);
}
{
}
{
bufferlist bl;
- ASSERT_EQ(8192, store->read(cid, a, 0, 8192, bl));
+ ASSERT_EQ(8192, store->read(ch, a, 0, 8192, bl));
for (unsigned i=0; i<4096; ++i)
ASSERT_EQ(0, bl[i]);
for (unsigned i=4096; i<8192; ++i)
bufferlist actual;
{
ASSERT_EQ((int)final.length(),
- store->read(cid, a, 0, final.length(), actual));
+ store->read(ch, a, 0, final.length(), actual));
ASSERT_TRUE(bl_eq(final, actual));
}
{
bufferlist actual;
{
ASSERT_EQ((int)final.length(),
- store->read(cid, a, 0, final.length(), actual));
+ store->read(ch, a, 0, final.length(), actual));
final.hexdump(cout);
actual.hexdump(cout);
ASSERT_TRUE(bl_eq(final, actual));
}
{
bufferlist inbl;
- int r = store->read(cid, a, 524288 + 131072, 1024, inbl);
+ int r = store->read(ch, a, 524288 + 131072, 1024, inbl);
ASSERT_EQ(r, 1024);
ASSERT_EQ(inbl.length(), 1024u);
ASSERT_TRUE(inbl.is_zero());
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+ ASSERT_EQ(0, store->stat(ch, hoid, &stat));
ASSERT_EQ(5, stat.st_size);
{
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+ ASSERT_EQ(0, store->stat(ch, hoid, &stat));
ASSERT_EQ(5, stat.st_size);
{
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+ ASSERT_EQ(0, store->stat(ch, hoid, &stat));
ASSERT_EQ(203, stat.st_size);
{
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+ ASSERT_EQ(0, store->stat(ch, hoid, &stat));
ASSERT_EQ(100200, stat.st_size);
}
ASSERT_EQ(r, 0);
}
struct stat stat;
- r = store->stat(cid, hoid, &stat);
+ r = store->stat(ch, hoid, &stat);
ASSERT_EQ(0, r);
ASSERT_EQ(0, stat.st_size);
bufferlist newdata;
- r = store->read(cid, hoid, 0, 1048576, newdata);
+ r = store->read(ch, hoid, 0, 1048576, newdata);
ASSERT_EQ(0, r);
}
ASSERT_EQ(0, r);
}
struct stat stat;
- r = store->stat(cid, hoid, &stat);
+ r = store->stat(ch, hoid, &stat);
ASSERT_EQ(0, r);
ASSERT_EQ(0, stat.st_size);
bufferlist newdata;
- r = store->read(cid, hoid, 0, 1048576, newdata);
+ r = store->read(ch, hoid, 0, 1048576, newdata);
ASSERT_EQ(0, r);
}
val.append("value");
val.append("value2");
{
- bufferptr bp;
- map<string,bufferptr> aset;
- r = store->getattr(cid, hoid, "nofoo", bp);
- ASSERT_EQ(-ENOENT, r);
- r = store->getattrs(cid, hoid, aset);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
ch->flush();
{
bool empty;
- int r = store->collection_empty(cid, &empty);
+ int r = store->collection_empty(ch, &empty);
ASSERT_EQ(0, r);
ASSERT_TRUE(empty);
}
{
bufferptr bp;
- r = store->getattr(cid, hoid, "nofoo", bp);
+ r = store->getattr(ch, hoid, "nofoo", bp);
ASSERT_EQ(-ENOENT, r);
}
{
ch->flush();
{
bool empty;
- int r = store->collection_empty(cid, &empty);
+ int r = store->collection_empty(ch, &empty);
ASSERT_EQ(0, r);
ASSERT_TRUE(!empty);
}
{
bufferptr bp;
- r = store->getattr(cid, hoid, "nofoo", bp);
+ r = store->getattr(ch, hoid, "nofoo", bp);
ASSERT_EQ(-ENODATA, r);
- r = store->getattr(cid, hoid, "foo", bp);
+ r = store->getattr(ch, hoid, "foo", bp);
ASSERT_EQ(0, r);
bufferlist bl;
bl.append(bp);
ASSERT_TRUE(bl_eq(val, bl));
map<string,bufferptr> bm;
- r = store->getattrs(cid, hoid, bm);
+ r = store->getattrs(ch, hoid, bm);
ASSERT_EQ(0, r);
}
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
- int r = store->collection_list(cid, current, ghobject_t::get_max(),
+ int r = store->collection_list(ch, current, ghobject_t::get_max(),
50,
&objects, &next);
ASSERT_EQ(r, 0);
end.hobj.pool = 1;
vector<ghobject_t> objects;
ghobject_t next;
- int r = store->collection_list(cid, ghobject_t(), end, 500,
+ int r = store->collection_list(ch, ghobject_t(), end, 500,
&objects, &next);
ASSERT_EQ(r, 0);
for (auto &p : objects) {
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
- int r = store->collection_list(cid, current, ghobject_t::get_max(), 50,
+ int r = store->collection_list(ch, current, ghobject_t::get_max(), 50,
&objects, &next);
ASSERT_EQ(r, 0);
cout << " got " << objects.size() << " next " << next << std::endl;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid, 10, 5, newdata);
+ r = store->read(ch, hoid, 10, 5, newdata);
ASSERT_EQ(r, 5);
ASSERT_TRUE(bl_eq(large, newdata));
newdata.clear();
- r = store->read(cid, hoid, 0, 5, newdata);
+ r = store->read(ch, hoid, 0, 5, newdata);
ASSERT_EQ(r, 5);
ASSERT_TRUE(bl_eq(small, newdata));
newdata.clear();
- r = store->read(cid, hoid2, 10, 5, newdata);
+ r = store->read(ch, hoid2, 10, 5, newdata);
ASSERT_EQ(r, 5);
ASSERT_TRUE(bl_eq(small, newdata));
- r = store->getattr(cid, hoid2, "attr2", attr);
+ r = store->getattr(ch, hoid2, "attr2", attr);
ASSERT_EQ(r, 0);
ASSERT_TRUE(bl_eq(small, attr));
attr.clear();
- r = store->getattr(cid, hoid2, "attr3", attr);
+ r = store->getattr(ch, hoid2, "attr3", attr);
ASSERT_EQ(r, 0);
ASSERT_TRUE(bl_eq(xlarge, attr));
attr.clear();
- r = store->getattr(cid, hoid, "attr1", attr);
+ r = store->getattr(ch, hoid, "attr1", attr);
ASSERT_EQ(r, 0);
ASSERT_TRUE(bl_eq(large, attr));
}
ASSERT_EQ(r, 0);
bufferlist rl;
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
ASSERT_TRUE(bl_eq(rl, final));
}
{
ASSERT_EQ(r, 0);
bufferlist rl;
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
ASSERT_TRUE(bl_eq(rl, final));
}
{
ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
bufferlist rl;
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
/*cout << "expected:\n";
final.hexdump(cout);
cout << "got:\n";
end.substr_of(pl, al.length()*2, pl.length() - al.length()*2);
final.append(end);
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
/*cout << "expected:\n";
final.hexdump(cout);
cout << "got:\n";
end.substr_of(pl, final.length(), pl.length() - final.length());
final.append(end);
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
/*cout << "expected:\n";
final.hexdump(cout);
cout << "got:\n";
end.substr_of(pl, final.length(), pl.length() - final.length());
final.append(end);
ASSERT_EQ((int)final.length(),
- store->read(cid, hoid, 0, final.length(), rl));
+ store->read(ch, hoid, 0, final.length(), rl));
/*cout << "expected:\n";
final.hexdump(cout);
cout << "got:\n";
{
bufferlist h;
map<string,bufferlist> r;
- store->omap_get(cid, hoid, &h, &r);
+ store->omap_get(ch, hoid, &h, &r);
ASSERT_TRUE(bl_eq(header, h));
ASSERT_EQ(r.size(), km.size());
cout << "r: " << r << std::endl;
// test iterator with seek_to_first
{
map<string,bufferlist> r;
- ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+ ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, hoid);
for (iter->seek_to_first(); iter->valid(); iter->next(false)) {
r[iter->key()] = iter->value();
}
// test iterator with initial lower_bound
{
map<string,bufferlist> r;
- ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+ ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, hoid);
for (iter->lower_bound(string()); iter->valid(); iter->next(false)) {
r[iter->key()] = iter->value();
}
{
map<string,bufferlist> r;
bufferlist h;
- store->omap_get(cid, hoid2, &h, &r);
+ store->omap_get(ch, hoid2, &h, &r);
ASSERT_TRUE(bl_eq(header, h));
ASSERT_EQ(r.size(), km.size());
}
cerr << "Clone range object" << std::endl;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- r = store->read(cid, hoid2, 10, 5, newdata);
+ r = store->read(ch, hoid2, 10, 5, newdata);
ASSERT_EQ(r, 5);
ASSERT_TRUE(bl_eq(small, newdata));
}
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct stat stat, stat2;
- r = store->stat(cid, hoid, &stat);
- r = store->stat(cid, hoid2, &stat2);
+ r = store->stat(ch, hoid, &stat);
+ r = store->stat(ch, hoid2, &stat2);
ASSERT_EQ(stat.st_size, stat2.st_size);
ASSERT_EQ(1024*1024, stat2.st_size);
}
i != created.end();
++i) {
struct stat buf;
- ASSERT_TRUE(!store->stat(cid, *i, &buf));
+ ASSERT_TRUE(!store->stat(ch, *i, &buf));
}
ch->flush();
set<ghobject_t> listed, listed2;
vector<ghobject_t> objects;
- r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+ r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
cerr << "objects.size() is " << objects.size() << std::endl;
ghobject_t start, next;
objects.clear();
r = store->collection_list(
- cid,
+ ch,
ghobject_t::get_max(),
ghobject_t::get_max(),
50,
listed.clear();
ghobject_t start2, next2;
while (1) {
- r = store->collection_list(cid, start, ghobject_t::get_max(),
+ r = store->collection_list(ch, start, ghobject_t::get_max(),
50,
&objects,
&next);
state->cond.Signal();
bufferlist r2;
- r = state->store->read(state->cid, hoid, 0, state->contents[hoid].data.length(), r2);
+ r = state->store->read(state->ch, hoid, 0, state->contents[hoid].data.length(), r2);
assert(bl_eq(state->contents[hoid].data, r2));
state->cond.Signal();
}
--(state->in_flight);
bufferlist r2;
r = state->store->read(
- state->cid, noid, 0,
+ state->ch, noid, 0,
state->contents[noid].data.length(), r2);
assert(bl_eq(state->contents[noid].data, r2));
state->cond.Signal();
state->available_objects.insert(noid);
--(state->in_flight);
bufferlist r2;
- r = state->store->read(state->cid, noid, 0, state->contents[noid].data.length(), r2);
+ r = state->store->read(state->ch, noid, 0, state->contents[noid].data.length(), r2);
assert(bl_eq(state->contents[noid].data, r2));
state->cond.Signal();
}
while (1) {
ch->flush();
vector<ghobject_t> objects;
- int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+ int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
10, &objects, 0);
assert(r >= 0);
if (objects.empty())
<< " size " << expected.length()
<< " offset " << offset
<< " len " << len << std::endl;
- r = store->read(cid, obj, offset, len, result);
+ r = store->read(ch, obj, offset, len, result);
if (offset >= expected.length()) {
ASSERT_EQ(r, 0);
} else {
expected = contents[obj].attrs;
}
map<string, bufferlist> attrs;
- int r = store->getattrs(cid, obj, attrs);
+ int r = store->getattrs(ch, obj, attrs);
ASSERT_TRUE(r == 0);
ASSERT_TRUE(attrs.size() == expected.size());
for (map<string, bufferlist>::iterator it = expected.begin();
}
bufferlist bl;
- r = store->getattr(cid, obj, it->first, bl);
+ r = store->getattr(ch, obj, it->first, bl);
ASSERT_EQ(r, 0);
ASSERT_TRUE(bl_eq(it->second, bl));
}
ghobject_t next, current;
while (1) {
//cerr << "scanning..." << std::endl;
- int r = store->collection_list(cid, current, ghobject_t::get_max(), 100,
+ int r = store->collection_list(ch, current, ghobject_t::get_max(), 100,
&objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
ASSERT_GT(available_objects.count(*i), (unsigned)0);
}
- int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+ int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
objects_set2.insert(objects.begin(), objects.end());
expected = contents[hoid].data.length();
}
struct stat buf;
- int r = store->stat(cid, hoid, &buf);
+ int r = store->stat(ch, hoid, &buf);
ASSERT_EQ(0, r);
assert((uint64_t)buf.st_size == expected);
ASSERT_TRUE((uint64_t)buf.st_size == expected);
}
vector<ghobject_t> objects;
ch->flush();
- r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+ r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
listed.clear();
ghobject_t current, next;
while (1) {
- r = store->collection_list(cid, current, ghobject_t::get_max(), 60,
+ r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
&objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
ch->flush();
vector<ghobject_t> objects;
- r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+ r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
listed.clear();
ghobject_t current, next;
while (1) {
- r = store->collection_list(cid, current, ghobject_t::get_max(), 60,
+ r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
&objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
ObjectStore::Transaction t;
bufferlist bl;
map<string, bufferlist> cur_attrs;
- r = store->omap_get(cid, hoid, &bl, &cur_attrs);
+ r = store->omap_get(ch, hoid, &bl, &cur_attrs);
ASSERT_EQ(r, 0);
for (map<string, bufferlist>::iterator j = attrs.begin();
j != attrs.end();
ObjectStore::Transaction t;
bufferlist bl;
map<string, bufferlist> cur_attrs;
- r = store->omap_get(cid, hoid, &bl, &cur_attrs);
+ r = store->omap_get(ch, hoid, &bl, &cur_attrs);
ASSERT_EQ(r, 0);
for (map<string, bufferlist>::iterator j = attrs.begin();
j != attrs.end();
bufferlist bl3;
map<string, bufferlist> cur_attrs;
- r = store->omap_get(cid, hoid, &bl3, &cur_attrs);
+ r = store->omap_get(ch, hoid, &bl3, &cur_attrs);
ASSERT_EQ(r, 0);
ASSERT_EQ(cur_attrs.size(), size_t(1));
ASSERT_TRUE(bl_eq(bl1, bl3));
set<string> keys;
- r = store->omap_get_keys(cid, hoid, &keys);
+ r = store->omap_get_keys(ch, hoid, &keys);
ASSERT_EQ(r, 0);
ASSERT_EQ(keys.size(), size_t(1));
}
{
bufferlist hdr;
map<string,bufferlist> m;
- store->omap_get(cid, hoid, &hdr, &m);
+ store->omap_get(ch, hoid, &hdr, &m);
ASSERT_EQ(6u, hdr.length());
ASSERT_TRUE(m.count("2"));
ASSERT_TRUE(!m.count("3"));
{
bufferlist hdr;
map<string,bufferlist> m;
- store->omap_get(cid, hoid, &hdr, &m);
+ store->omap_get(ch, hoid, &hdr, &m);
ASSERT_EQ(0u, hdr.length());
ASSERT_EQ(0u, m.size());
}
// FileStore may deadlock two active iterators over the same data
iter = ObjectMap::ObjectMapIterator();
- iter = store->get_omap_iterator(cid, hoid);
+ iter = store->get_omap_iterator(ch, hoid);
for (iter->seek_to_first(), count=0; iter->valid(); iter->next(), count++) {
string key = iter->key();
bufferlist value = iter->value();
ASSERT_EQ(r, 0);
}
- iter = store->get_omap_iterator(cid, hoid);
+ iter = store->get_omap_iterator(ch, hoid);
//lower bound
string bound_key = "key-5";
iter->lower_bound(bound_key);
}
map<string, bufferptr> aset;
- store->getattrs(cid, hoid, aset);
+ store->getattrs(ch, hoid, aset);
ASSERT_EQ(aset.size(), attrs.size());
for (map<string, bufferptr>::iterator i = aset.begin();
i != aset.end();
}
aset.clear();
- store->getattrs(cid, hoid, aset);
+ store->getattrs(ch, hoid, aset);
ASSERT_EQ(aset.size(), attrs.size());
for (map<string, bufferptr>::iterator i = aset.begin();
i != aset.end();
}
bufferptr bp;
- r = store->getattr(cid, hoid, "attr2", bp);
+ r = store->getattr(ch, hoid, "attr2", bp);
ASSERT_EQ(r, -ENODATA);
- r = store->getattr(cid, hoid, "attr3", bp);
+ r = store->getattr(ch, hoid, "attr3", bp);
ASSERT_EQ(r, 0);
bufferlist bl2;
bl2.push_back(bp);
ch->flush();
ObjectStore::Transaction t;
vector<ghobject_t> objects;
- r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+ r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
ch->flush();
objects.clear();
- r = store->collection_list(tid, ghobject_t(), ghobject_t::get_max(),
+ r = store->collection_list(tch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
ghobject_t o;
o.hobj.set_hash((i << 16) | 0xA1);
o.hobj.pool = -1;
- bool exists = store->exists(cid, o);
+ bool exists = store->exists(ch, o);
ASSERT_EQ(exists, false);
}
{
ghobject_t o;
o.hobj.set_hash(0xA1);
o.hobj.pool = -1;
- bool exists = store->exists(cid, o);
+ bool exists = store->exists(ch, o);
ASSERT_EQ(exists, true);
}
std::cout << "Cleanup" << std::endl;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, srcoid));
+ ASSERT_TRUE(store->exists(ch, srcoid));
{
ObjectStore::Transaction t;
t.collection_move_rename(cid, srcoid, cid, dstoid);
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, srcoid));
- ASSERT_TRUE(store->exists(cid, dstoid));
+ ASSERT_TRUE(store->exists(ch, srcoid));
+ ASSERT_TRUE(store->exists(ch, dstoid));
{
bufferlist bl;
- store->read(cid, srcoid, 0, 3, bl);
+ store->read(ch, srcoid, 0, 3, bl);
ASSERT_TRUE(bl_eq(b, bl));
- store->read(cid, dstoid, 0, 3, bl);
+ store->read(ch, dstoid, 0, 3, bl);
ASSERT_TRUE(bl_eq(a, bl));
}
{
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, dstoid));
- ASSERT_FALSE(store->exists(cid, srcoid));
+ ASSERT_TRUE(store->exists(ch, dstoid));
+ ASSERT_FALSE(store->exists(ch, srcoid));
{
bufferlist bl;
- store->read(cid, dstoid, 0, 3, bl);
+ store->read(ch, dstoid, 0, 3, bl);
ASSERT_TRUE(bl_eq(b, bl));
}
{
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, oid));
+ ASSERT_TRUE(store->exists(ch, oid));
bufferlist data, attr;
map<string, bufferlist> omap;
data.append("data payload");
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, temp_oid));
+ ASSERT_TRUE(store->exists(ch, temp_oid));
{
ObjectStore::Transaction t;
t.remove(cid, oid);
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- ASSERT_TRUE(store->exists(cid, oid));
- ASSERT_FALSE(store->exists(cid, temp_oid));
+ ASSERT_TRUE(store->exists(ch, oid));
+ ASSERT_FALSE(store->exists(ch, temp_oid));
{
bufferlist newdata;
- r = store->read(cid, oid, 0, 1000, newdata);
+ r = store->read(ch, oid, 0, 1000, newdata);
ASSERT_GE(r, 0);
ASSERT_TRUE(bl_eq(data, newdata));
bufferlist newattr;
- r = store->getattr(cid, oid, "attr", newattr);
+ r = store->getattr(ch, oid, "attr", newattr);
ASSERT_EQ(r, 0);
ASSERT_TRUE(bl_eq(attr, newattr));
set<string> keys;
keys.insert("omap_key");
map<string, bufferlist> newomap;
- r = store->omap_get_values(cid, oid, keys, &newomap);
+ r = store->omap_get_values(ch, oid, keys, &newomap);
ASSERT_GE(r, 0);
ASSERT_EQ(1u, newomap.size());
ASSERT_TRUE(newomap.count("omap_key"));
{
vector<ghobject_t> objects;
- r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+ r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), 1u);
ASSERT_EQ(objects[0], oid2);
}
- ASSERT_FALSE(store->exists(cid, oid));
+ ASSERT_FALSE(store->exists(ch, oid));
{
ObjectStore::Transaction t;
ASSERT_EQ(r, 0);
}
struct stat st;
- ASSERT_EQ(store->stat(cid, hoid, &st), -ENOENT);
- ASSERT_EQ(store->stat(cid, hoid2, &st), 0);
+ ASSERT_EQ(store->stat(ch, hoid, &st), -ENOENT);
+ ASSERT_EQ(store->stat(ch, hoid2, &st), 0);
}
#if defined(WITH_BLUESTORE)
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
- bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
- ASSERT_EQ(-ENOENT, r);
+ auto ch = store->open_collection(cid);
+ ASSERT_FALSE(ch);
}
auto ch = store->create_new_collection(cid);
{
g_conf->apply_changes(NULL);
bufferlist in;
- r = store->read(cid, hoid, 0, block_size, in);
+ r = store->read(ch, hoid, 0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
g_conf->apply_changes(NULL);
bufferlist in;
- r = store->read(cid, hoid, 0, block_size, in);
+ r = store->read(ch, hoid, 0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
}
ASSERT_EQ(r, 0);
bufferlist in;
- r = store->read(cid, hoid, 0, block_size, in);
+ r = store->read(ch, hoid, 0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
in.clear();
- r = store->read(cid, hoid, block_size*2, block_size, in);
+ r = store->read(ch, hoid, block_size*2, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
g_conf->set_val("bluestore_csum_type", "crc32c");
g_conf->apply_changes(NULL);
in.clear();
- r = store->read(cid, hoid, 0, block_size, in);
+ r = store->read(ch, hoid, 0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
in.clear();
- r = store->read(cid, hoid, block_size*2, block_size, in);
+ r = store->read(ch, hoid, block_size*2, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
}
orig.append( std::string(block_size0 - block_size, 'a'));
bufferlist in;
- r = store->read(cid, hoid, 0, block_size0, in);
+ r = store->read(ch, hoid, 0, block_size0, in);
ASSERT_EQ((int)block_size0, r);
ASSERT_TRUE(bl_eq(orig, in));
- r = store->read(cid, hoid, block_size0, block_size, in);
+ r = store->read(ch, hoid, block_size0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig2, in));
in.clear();
orig = bl;
orig.append( std::string(block_size - block_size2, 'b'));
- r = store->read(cid, hoid, block_size0, block_size, in);
+ r = store->read(ch, hoid, block_size0, block_size, in);
ASSERT_EQ((int)block_size, r);
ASSERT_TRUE(bl_eq(orig, in));
}
{
bufferlist bl;
for (size_t i = 0; i < obj_size; i += 0x1000) {
- store->read(cid, hoid, i, 0x1000, bl);
+ store->read(ch, hoid, i, 0x1000, bl);
}
}
get_mempool_stats(&total_bytes, &total_onodes);
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, 0, block_size, bl);
+ r = store->read(ch, hoid, 0, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'b'));
ASSERT_TRUE(bl_eq(expected, bl));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, 0, block_size, bl);
+ r = store->read(ch, hoid, 0, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'b'));
ASSERT_TRUE(bl_eq(expected, bl));
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, 0, block_size, bl);
+ r = store->read(ch, hoid, 0, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'b'));
ASSERT_TRUE(bl_eq(expected, bl));
bl.clear();
expected.clear();
- r = store->read(cid, hoid, block_size, block_size, bl);
+ r = store->read(ch, hoid, block_size, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'a'));
ASSERT_TRUE(bl_eq(expected, bl));
bl.clear();
expected.clear();
- r = store->read(cid, hoid, block_size * 2, block_size * 2, bl);
+ r = store->read(ch, hoid, block_size * 2, block_size * 2, bl);
ASSERT_EQ(r, (int)block_size * 2);
expected.append(string(block_size * 2, 'c'));
ASSERT_TRUE(bl_eq(expected, bl));
bl.clear();
expected.clear();
- r = store->read(cid, hoid, block_size * 4, block_size, bl);
+ r = store->read(ch, hoid, block_size * 4, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'f'));
ASSERT_TRUE(bl_eq(expected, bl));
bl.clear();
expected.clear();
- r = store->read(cid, hoid, block_size * 5, block_size, bl);
+ r = store->read(ch, hoid, block_size * 5, block_size, bl);
ASSERT_EQ(r, (int)block_size);
expected.append(string(block_size, 'd'));
ASSERT_TRUE(bl_eq(expected, bl));
bl.clear();
expected.clear();
- r = store->read(cid, hoid, block_size * 5, block_size * 3, bl);
+ r = store->read(ch, hoid, block_size * 5, block_size * 3, bl);
ASSERT_EQ(r, (int)block_size * 3);
expected.append(string(block_size, 'd'));
expected.append(string(block_size * 2, 'e'));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, block_size * 9, block_size * 2, bl);
+ r = store->read(ch, hoid, block_size * 9, block_size * 2, bl);
ASSERT_EQ(r, (int)block_size * 2);
expected.append(string(block_size, 'b'));
expected.append(string(block_size, 'a'));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, block_size * 7, block_size * 3, bl);
+ r = store->read(ch, hoid, block_size * 7, block_size * 3, bl);
ASSERT_EQ(r, (int)block_size * 3);
expected.append(string(block_size, 'c'));
expected.append(string(block_size, 0));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, block_size * 11, block_size * 3, bl);
+ r = store->read(ch, hoid, block_size * 11, block_size * 3, bl);
ASSERT_EQ(r, (int)block_size * 3);
expected.append(string(block_size, 'a'));
expected.append(string(block_size, 0));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, block_size * 17, block_size * 3, bl);
+ r = store->read(ch, hoid, block_size * 17, block_size * 3, bl);
ASSERT_EQ(r, (int)block_size * 3);
expected.append(string(block_size, 'e'));
expected.append(string(block_size, 0));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, block_size * 16, block_size * 4, bl);
+ r = store->read(ch, hoid, block_size * 16, block_size * 4, bl);
ASSERT_EQ(r, (int)block_size * 4);
expected.append(string(block_size, 'f'));
expected.append(string(block_size, 'e'));
// thread to update stats.
sleep(1);
bufferlist bl, expected;
- r = store->read(cid, hoid, 0, block_size * 3, bl);
+ r = store->read(ch, hoid, 0, block_size * 3, bl);
ASSERT_EQ(r, (int)block_size * 3);
expected.append(string(block_size, 'a'));
expected.append(string(1, 0));
ObjectStore::Transaction t;
bufferlist bl, expected;
- r = store->read(cid, hoid1, 0x70000, 0x9c00, bl);
+ r = store->read(ch, hoid1, 0x70000, 0x9c00, bl);
ASSERT_EQ(r, (int)0x9c00);
expected.append(string(0x19e0, 'a'));
expected.append(string(0x220, 0));
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
bufferlist in;
- r = store->read(cid, hoid, 0, 5, in);
+ r = store->read(ch, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
{
{
{
- bool exists = store->exists(cid, hoid);
+ bool exists = store->exists(ch, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
- exists = store->exists(cid, hoid);
+ exists = store->exists(ch, hoid);
ASSERT_EQ(true, exists);
}
bufferlist bl;
t.write(cid, dst, 0, 12, dstbl);
t.clone_range(cid, src, dst, 2, 8, 2);
ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
- ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+ ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
ASSERT_EQ(expected, result);
}
t.write(cid, dst, 0, 12, dstbl);
t.clone_range(cid, src, dst, 2, 8, 2);
ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
- ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+ ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
ASSERT_EQ(expected, result);
}
t.write(cid, dst, 0, 12, dstbl);
t.clone_range(cid, src, dst, 2, 8, 2);
ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
- ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+ ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
ASSERT_EQ(expected, result);
}
t.write(cid, dst, 0, 12, dstbl);
t.clone_range(cid, src, dst, 2, 8, 2);
ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
- ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+ ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
ASSERT_EQ(expected, result);
}
t.write(cid, dst, 0, 12, dstbl);
t.clone_range(cid, src, dst, 2, 8, 2);
ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
- ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+ ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
ASSERT_EQ(expected, result);
}
hobject_t existing_oid, nonexistent_oid;
void run_rebuild_missing_test(const map<hobject_t, pg_missing_item> &expected_missing_items) {
- rebuild_missing_set_with_deletes(store.get(), test_coll, info);
+ rebuild_missing_set_with_deletes(store.get(), ch, info);
ASSERT_EQ(expected_missing_items, missing.get_items());
}
};
auto orig_dups = log.dups;
clear();
ostringstream err;
- read_log_and_missing(store.get(), test_coll, log_oid,
+ read_log_and_missing(store.get(), ch, log_oid,
pg_info_t(), err, false);
ASSERT_EQ(orig_dups.size(), log.dups.size());
ASSERT_EQ(orig_dups, log.dups);
int _action_on_all_objects_in_pg(ObjectStore *store, coll_t coll, action_on_object_t &action, bool debug)
{
+ auto ch = store->open_collection(coll);
unsigned LIST_AT_A_TIME = 100;
ghobject_t next;
while (!next.is_max()) {
vector<ghobject_t> list;
- int r = store->collection_list(
- coll,
+ int r = store->collection_list(ch,
next,
ghobject_t::get_max(),
LIST_AT_A_TIME,
object_info_t oi;
if (coll != coll_t::meta()) {
bufferlist attr;
- r = store->getattr(coll, *obj, OI_ATTR, attr);
+ r = store->getattr(ch, *obj, OI_ATTR, attr);
if (r < 0) {
cerr << "Error getting attr on : " << make_pair(coll, *obj) << ", "
<< cpp_strerror(r) << std::endl;
}
int get_log(ObjectStore *fs, __u8 struct_ver,
- coll_t coll, spg_t pgid, const pg_info_t &info,
+ spg_t pgid, const pg_info_t &info,
PGLog::IndexedLog &log, pg_missing_t &missing)
{
try {
+ auto ch = fs->open_collection(coll_t(pgid));
+ if (!ch) {
+ return -ENOENT;
+ }
ostringstream oss;
assert(struct_ver > 0);
PGLog::read_log_and_missing(
- fs, coll,
+ fs, ch,
pgid.make_pgmeta_oid(),
info, log, missing,
oss,
mysize_t total;
footer ft;
- int ret = store->stat(cid, obj, &st);
+ auto ch = store->open_collection(cid);
+ int ret = store->stat(ch, obj, &st);
if (ret < 0)
return ret;
{
bufferptr bp;
bufferlist bl;
- ret = store->getattr(cid, obj, OI_ATTR, bp);
+ ret = store->getattr(ch, obj, OI_ATTR, bp);
if (ret < 0) {
cerr << "getattr failure object_info " << ret << std::endl;
return ret;
if (len > total)
len = total;
- ret = store->read(cid, obj, offset, len, rawdatabl);
+ ret = store->read(ch, obj, offset, len, rawdatabl);
if (ret < 0)
return ret;
if (ret == 0)
//Handle attrs for this object
map<string,bufferptr> aset;
- ret = store->getattrs(cid, obj, aset);
+ ret = store->getattrs(ch, obj, aset);
if (ret) return ret;
attr_section as(aset);
ret = write_section(TYPE_ATTRS, as, file_fd);
//Handle omap information
bufferlist hdrbuf;
- ret = store->omap_get_header(cid, obj, &hdrbuf, true);
+ ret = store->omap_get_header(ch, obj, &hdrbuf, true);
if (ret < 0) {
cerr << "omap_get_header: " << cpp_strerror(ret) << std::endl;
return ret;
if (ret)
return ret;
- ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, obj);
+ ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, obj);
if (!iter) {
ret = -ENOENT;
cerr << "omap_get_iterator: " << cpp_strerror(ret) << std::endl;
int ObjectStoreTool::export_files(ObjectStore *store, coll_t coll)
{
ghobject_t next;
-
+ auto ch = store->open_collection(coll);
while (!next.is_max()) {
vector<ghobject_t> objects;
- int r = store->collection_list(coll, next, ghobject_t::get_max(), 300,
+ int r = store->collection_list(ch, next, ghobject_t::get_max(), 300,
&objects, &next);
if (r < 0)
return r;
return -EINVAL;
}
}
+ auto ch = store->open_collection(coll_t::meta());
const ghobject_t inc_oid = OSD::get_inc_osdmap_pobject_name(e);
- if (!store->exists(coll_t::meta(), inc_oid)) {
+ if (!store->exists(ch, inc_oid)) {
cerr << "inc-osdmap (" << inc_oid << ") does not exist." << std::endl;
if (!force) {
return -ENOENT;
}
if (dry_run)
return 0;
- ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
ObjectStore::Transaction t;
t.write(coll_t::meta(), inc_oid, 0, bl.length(), bl);
t.truncate(coll_t::meta(), inc_oid, bl.length());
int get_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl)
{
- if (store->read(coll_t::meta(),
+ auto ch = store->open_collection(coll_t::meta());
+ if (store->read(ch,
OSD::get_inc_osdmap_pobject_name(e),
0, 0, bl) < 0) {
return -ENOENT;
return -EINVAL;
}
}
+ auto ch = store->open_collection(coll_t::meta());
const ghobject_t full_oid = OSD::get_osdmap_pobject_name(e);
- if (!store->exists(coll_t::meta(), full_oid)) {
+ if (!store->exists(ch, full_oid)) {
cerr << "osdmap (" << full_oid << ") does not exist." << std::endl;
if (!force) {
return -ENOENT;
if (dry_run)
return 0;
ObjectStore::Transaction t;
- ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
t.write(coll_t::meta(), full_oid, 0, bl.length(), bl);
t.truncate(coll_t::meta(), full_oid, bl.length());
int ret = store->apply_transaction(ch, std::move(t));
int get_osdmap(ObjectStore *store, epoch_t e, OSDMap &osdmap, bufferlist& bl)
{
+ ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
bool found = store->read(
- coll_t::meta(), OSD::get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
+ ch, OSD::get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
if (!found) {
cerr << "Can't find OSDMap for pg epoch " << e << std::endl;
return -ENOENT;
cerr << "Exporting " << pgid << " info " << info << std::endl;
- int ret = get_log(fs, struct_ver, coll, pgid, info, log, missing);
+ int ret = get_log(fs, struct_ver, pgid, info, log, missing);
if (ret > 0)
return ret;
attr_section as;
as.decode(ebliter);
+ auto ch = store->open_collection(coll);
if (debug)
cerr << "\tattrs: len " << as.data.size() << std::endl;
t->setattrs(coll, hoid, as.data);
ghobject_t clone = hoid;
clone.hobj.snap = p.first;
set<snapid_t> snaps(p.second.begin(), p.second.end());
- if (!store->exists(coll, clone)) {
+ if (!store->exists(ch, clone)) {
// no clone, skip. this is probably a cache pool. this works
// because we use a separate transaction per object and clones
// come before head in the archive.
int do_remove_object(ObjectStore *store, coll_t coll,
ghobject_t &ghobj, bool all, bool force)
{
+ auto ch = store->open_collection(coll);
spg_t pg;
coll.is_pg_prefix(&pg);
OSDriver driver(
SnapMapper mapper(g_ceph_context, &driver, 0, 0, 0, pg.shard);
struct stat st;
- int r = store->stat(coll, ghobj, &st);
+ int r = store->stat(ch, ghobj, &st);
if (r < 0) {
cerr << "remove: " << cpp_strerror(r) << std::endl;
return r;
cout << "remove " << ghobj << std::endl;
- auto ch = store->open_collection(coll);
if (!dry_run) {
r = remove_object(coll, ghobj, mapper, &_t, &t);
if (r < 0)
int do_list_attrs(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
+ auto ch = store->open_collection(coll);
map<string,bufferptr> aset;
- int r = store->getattrs(coll, ghobj, aset);
+ int r = store->getattrs(ch, ghobj, aset);
if (r < 0) {
cerr << "getattrs: " << cpp_strerror(r) << std::endl;
return r;
int do_list_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
- ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(coll, ghobj);
+ auto ch = store->open_collection(coll);
+ ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, ghobj);
if (!iter) {
cerr << "omap_get_iterator: " << cpp_strerror(ENOENT) << std::endl;
return -ENOENT;
int do_get_bytes(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
{
+ auto ch = store->open_collection(coll);
struct stat st;
mysize_t total;
- int ret = store->stat(coll, ghobj, &st);
+ int ret = store->stat(ch, ghobj, &st);
if (ret < 0) {
cerr << "get-bytes: " << cpp_strerror(ret) << std::endl;
return ret;
if (len > total)
len = total;
- ret = store->read(coll, ghobj, offset, len, rawdatabl);
+ ret = store->read(ch, ghobj, offset, len, rawdatabl);
if (ret < 0)
return ret;
if (ret == 0)
int do_get_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
{
+ auto ch = store->open_collection(coll);
bufferptr bp;
- int r = store->getattr(coll, ghobj, key.c_str(), bp);
+ int r = store->getattr(ch, ghobj, key.c_str(), bp);
if (r < 0) {
cerr << "getattr: " << cpp_strerror(r) << std::endl;
return r;
int do_get_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
{
+ auto ch = store->open_collection(coll);
set<string> keys;
map<string, bufferlist> out;
keys.insert(key);
- int r = store->omap_get_values(coll, ghobj, keys, &out);
+ int r = store->omap_get_values(ch, ghobj, keys, &out);
if (r < 0) {
cerr << "omap_get_values: " << cpp_strerror(r) << std::endl;
return r;
int do_get_omaphdr(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
+ auto ch = store->open_collection(coll);
bufferlist hdrbl;
- int r = store->omap_get_header(coll, ghobj, &hdrbl, true);
+ int r = store->omap_get_header(ch, ghobj, &hdrbl, true);
if (r < 0) {
cerr << "omap_get_header: " << cpp_strerror(r) << std::endl;
return r;
int get_snapset(ObjectStore *store, coll_t coll, ghobject_t &ghobj, SnapSet &ss, bool silent = false)
{
+ auto ch = store->open_collection(coll);
bufferlist attr;
- int r = store->getattr(coll, ghobj, SS_ATTR, attr);
+ int r = store->getattr(ch, ghobj, SS_ATTR, attr);
if (r < 0) {
if (!silent)
cerr << "Error getting snapset on : " << make_pair(coll, ghobj) << ", "
int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter* formatter)
{
+ auto ch = store->open_collection(coll);
int r = 0;
formatter->open_object_section("obj");
formatter->open_object_section("id");
formatter->close_section();
bufferlist attr;
- int gr = store->getattr(coll, ghobj, OI_ATTR, attr);
+ int gr = store->getattr(ch, ghobj, OI_ATTR, attr);
if (gr < 0) {
r = gr;
cerr << "Error getting attr on : " << make_pair(coll, ghobj) << ", "
}
}
struct stat st;
- int sr = store->stat(coll, ghobj, &st, true);
+ int sr = store->stat(ch, ghobj, &st, true);
if (sr < 0) {
r = sr;
cerr << "Error stat on : " << make_pair(coll, ghobj) << ", "
ObjectStore *store, coll_t coll, ghobject_t &ghobj, uint64_t setsize, Formatter* formatter,
bool corrupt)
{
+ auto ch = store->open_collection(coll);
if (ghobj.hobj.is_snapdir()) {
cerr << "Can't set the size of a snapdir" << std::endl;
return -EINVAL;
}
bufferlist attr;
- int r = store->getattr(coll, ghobj, OI_ATTR, attr);
+ int r = store->getattr(ch, ghobj, OI_ATTR, attr);
if (r < 0) {
cerr << "Error getting attr on : " << make_pair(coll, ghobj) << ", "
<< cpp_strerror(r) << std::endl;
return r;
}
struct stat st;
- r = store->stat(coll, ghobj, &st, true);
+ r = store->stat(ch, ghobj, &st, true);
if (r < 0) {
cerr << "Error stat on : " << make_pair(coll, ghobj) << ", "
<< cpp_strerror(r) << std::endl;
i = 1;
for (auto cid : collections) {
cout << i++ << "/" << num << " " << cid << std::endl;
- auto ch = dst->create_new_collection(cid);
+ auto ch = src->open_collection(cid);
+ auto dch = dst->create_new_collection(cid);
{
ObjectStore::Transaction t;
- int bits = src->collection_bits(cid);
+ int bits = src->collection_bits(ch);
if (bits < 0) {
if (src->get_type() == "filestore" && cid.is_meta()) {
bits = 0;
}
}
t.create_collection(cid, bits);
- dst->apply_transaction(ch, std::move(t));
+ dst->apply_transaction(dch, std::move(t));
}
ghobject_t pos;
uint64_t bytes = 0, keys = 0;
while (true) {
vector<ghobject_t> ls;
- r = src->collection_list(cid, pos, ghobject_t::get_max(), 1000, &ls, &pos);
+ r = src->collection_list(ch, pos, ghobject_t::get_max(), 1000, &ls, &pos);
if (r < 0) {
cerr << "collection_list on " << cid << " from " << pos << " got: "
<< cpp_strerror(r) << std::endl;
t.touch(cid, oid);
map<string,bufferptr> attrs;
- src->getattrs(cid, oid, attrs);
+ src->getattrs(ch, oid, attrs);
if (!attrs.empty()) {
t.setattrs(cid, oid, attrs);
}
bufferlist bl;
- src->read(cid, oid, 0, 0, bl);
+ src->read(ch, oid, 0, 0, bl);
if (bl.length()) {
t.write(cid, oid, 0, bl.length(), bl);
bytes += bl.length();
bufferlist header;
map<string,bufferlist> omap;
- src->omap_get(cid, oid, &header, &omap);
+ src->omap_get(ch, oid, &header, &omap);
if (header.length()) {
t.omap_setheader(cid, oid, header);
++keys;
t.omap_setkeys(cid, oid, omap);
}
- dst->apply_transaction(ch, std::move(t));
+ dst->apply_transaction(dch, std::move(t));
}
}
cout << " " << std::setw(16) << n << " objects, "
bufferlist bl;
OSDSuperblock superblock;
+ auto ch = fs->open_collection(coll_t::meta());
bufferlist::iterator p;
- ret = fs->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
+ ret = fs->read(ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
if (ret < 0) {
cerr << "Failure to read OSD superblock: " << cpp_strerror(ret) << std::endl;
goto out;
} else if (op == "log") {
PGLog::IndexedLog log;
pg_missing_t missing;
- ret = get_log(fs, struct_ver, coll, pgid, info, log, missing);
+ ret = get_log(fs, struct_ver, pgid, info, log, missing);
if (ret < 0)
goto out;
unsigned nadded = 0;
+ auto ch = fs.open_collection(coll_t::meta());
OSDMap osdmap;
for (auto e = std::max(last_committed+1, sb.oldest_map);
e <= sb.newest_map; e++) {
{
const auto oid = OSD::get_inc_osdmap_pobject_name(e);
bufferlist bl;
- int nread = fs.read(coll_t::meta(), oid, 0, 0, bl);
+ int nread = fs.read(ch, oid, 0, 0, bl);
if (nread <= 0) {
cerr << "missing " << oid << std::endl;
return -EINVAL;
{
const auto oid = OSD::get_osdmap_pobject_name(e);
bufferlist bl;
- int nread = fs.read(coll_t::meta(), oid, 0, 0, bl);
+ int nread = fs.read(ch, oid, 0, 0, bl);
if (nread <= 0) {
cerr << "missing " << oid << std::endl;
return -EINVAL;