* Set of headers currently in use
*/
set<uint64_t> in_use;
- set<ghobject_t> map_header_in_use;
+ set<ghobject_t, ghobject_t::BitwiseComparator> map_header_in_use;
/**
* Takes the map_header_in_use entry in constructor, releases in
/// Implicit lock on Header->seq
typedef ceph::shared_ptr<_Header> Header;
Mutex cache_lock;
- SimpleLRU<ghobject_t, _Header> caches;
+ SimpleLRU<ghobject_t, _Header, ghobject_t::BitwiseComparator> caches;
string map_header_key(const ghobject_t &oid);
string header_key(uint64_t seq);
private:
CephContext *cct;
const int registry_shards;
- SharedLRU<ghobject_t, FD> *registry;
+ SharedLRU<ghobject_t, FD, ghobject_t::BitwiseComparator> *registry;
public:
FDCache(CephContext *cct) : cct(cct),
registry_shards(cct->_conf->filestore_fd_cache_shards) {
assert(cct);
cct->_conf->add_observer(this);
- registry = new SharedLRU<ghobject_t, FD>[registry_shards];
+ registry = new SharedLRU<ghobject_t, FD, ghobject_t::BitwiseComparator>[registry_shards];
for (int i = 0; i < registry_shards; ++i) {
registry[i].set_cct(cct);
registry[i].set_size(
// DEBUG read error injection, an object is removed from both on delete()
Mutex read_error_lock;
- set<ghobject_t> data_error_set; // read() will return -EIO
- set<ghobject_t> mdata_error_set; // getattr(),stat() will return -EIO
+ set<ghobject_t, ghobject_t::BitwiseComparator> data_error_set; // read() will return -EIO
+ set<ghobject_t, ghobject_t::BitwiseComparator> mdata_error_set; // getattr(),stat() will return -EIO
void inject_data_error(const ghobject_t &oid);
void inject_mdata_error(const ghobject_t &oid);
void debug_obj_on_delete(const ghobject_t &oid);
const vector<string> &path,
const ghobject_t *next_object,
set<string, CmpHexdigitStringBitwise> *hash_prefixes,
- set<pair<string, ghobject_t> > *objects)
+ set<pair<string, ghobject_t>, CmpPairBitwise> *objects)
{
map<string, ghobject_t> rev_objects;
int r;
vector<string> next_path = path;
next_path.push_back("");
set<string, CmpHexdigitStringBitwise> hash_prefixes;
- set<pair<string, ghobject_t> > objects;
+ set<pair<string, ghobject_t>, CmpPairBitwise> objects;
int r = get_path_contents_by_hash_bitwise(path,
next,
&hash_prefixes,
i != hash_prefixes.end();
++i) {
dout(20) << __func__ << " prefix " << *i << dendl;
- set<pair<string, ghobject_t> >::iterator j = objects.lower_bound(
+ set<pair<string, ghobject_t>, CmpPairBitwise>::iterator j = objects.lower_bound(
make_pair(*i, ghobject_t()));
if (j == objects.end() || j->first != *i) {
*(next_path.rbegin()) = *(i->rbegin());
vector<string> next_path = path;
next_path.push_back("");
set<string> hash_prefixes;
- set<pair<string, ghobject_t>, CmpPairNibblewise > objects;
+ set<pair<string, ghobject_t>, CmpPairNibblewise> objects;
int r = get_path_contents_by_hash_nibblewise(path,
next,
&hash_prefixes,
}
};
+ struct CmpPairBitwise {
+ bool operator()(const pair<string, ghobject_t>& l,
+ const pair<string, ghobject_t>& r)
+ {
+ if (l.first < r.first)
+ return true;
+ if (l.first > r.first)
+ return false;
+ if (cmp_bitwise(l.second, r.second) < 0)
+ return true;
+ return false;
+ }
+ };
+
struct CmpHexdigitStringBitwise {
bool operator()(const string& l, const string& r) {
return reverse_hexdigit_bits_string(l) < reverse_hexdigit_bits_string(r);
const vector<string> &path, /// [in] Path to list
const ghobject_t *next_object, /// [in] list > *next_object
set<string, CmpHexdigitStringBitwise> *hash_prefixes, /// [out] prefixes in dir
- set<pair<string, ghobject_t> > *objects /// [out] objects
+ set<pair<string, ghobject_t>, CmpPairBitwise> *objects /// [out] objects
);
int get_path_contents_by_hash_nibblewise(
const vector<string> &path, /// [in] Path to list
const ghobject_t *next_object, /// [in] list > *next_object
set<string> *hash_prefixes, /// [out] prefixes in dir
- set<pair<string, ghobject_t>, CmpPairNibblewise > *objects /// [out] objects
+ set<pair<string, ghobject_t>, CmpPairNibblewise> *objects /// [out] objects
);
/// List objects in collection in ghobject_t order
// 4. Clone or rename
struct BufferTransaction {
typedef pair<coll_t, ghobject_t> uniq_id;
- typedef map<uniq_id, StripObjectMap::StripObjectHeaderRef> StripHeaderMap;
+
+ struct CollGhobjectPairBitwiseComparator {
+ bool operator()(const uniq_id& l,
+ const uniq_id& r) const {
+ if (l.first < r.first)
+ return true;
+ if (l.first != r.first)
+ return false;
+ if (cmp_bitwise(l.second, r.second) < 0)
+ return true;
+ return false;
+ }
+ };
+
+ typedef map<uniq_id, StripObjectMap::StripObjectHeaderRef,
+ CollGhobjectPairBitwiseComparator> StripHeaderMap;
//Dirty records
StripHeaderMap strip_headers;
- map< uniq_id, map<pair<string, string>, bufferlist> > buffers; // pair(prefix, key),to buffer updated data in one transaction
+ map< uniq_id, map<pair<string, string>, bufferlist>,
+ CollGhobjectPairBitwiseComparator> buffers; // pair(prefix, key),to buffer updated data in one transaction
list<Context*> finishes;
f->close_section();
f->open_array_section("objects");
- for (map<ghobject_t,ObjectRef>::iterator q = p->second->object_map.begin();
+ for (map<ghobject_t,ObjectRef,ghobject_t::BitwiseComparator>::iterator q = p->second->object_map.begin();
q != p->second->object_map.end();
++q) {
f->open_object_section("object");
return -ENOENT;
RWLock::RLocker l(c->lock);
- map<ghobject_t,ObjectRef>::iterator p = c->object_map.lower_bound(start);
+ map<ghobject_t,ObjectRef,ghobject_t::BitwiseComparator>::iterator p = c->object_map.lower_bound(start);
while (p != c->object_map.end() &&
ls->size() < (unsigned)max &&
p->first < end) {
RWLock::WLocker l1(MIN(&(*sc), &(*dc))->lock);
RWLock::WLocker l2(MAX(&(*sc), &(*dc))->lock);
- map<ghobject_t,ObjectRef>::iterator p = sc->object_map.begin();
+ map<ghobject_t,ObjectRef,ghobject_t::BitwiseComparator>::iterator p = sc->object_map.begin();
while (p != sc->object_map.end()) {
if (p->first.match(bits, match)) {
dout(20) << " moving " << p->first << dendl;
struct Collection {
ceph::unordered_map<ghobject_t, ObjectRef> object_hash; ///< for lookup
- map<ghobject_t, ObjectRef> object_map; ///< for iteration
+ map<ghobject_t, ObjectRef,ghobject_t::BitwiseComparator> object_map; ///< for iteration
map<string,bufferptr> xattr;
RWLock lock; ///< for object_{map,hash}
::encode(xattr, bl);
uint32_t s = object_map.size();
::encode(s, bl);
- for (map<ghobject_t, ObjectRef>::const_iterator p = object_map.begin();
+ for (map<ghobject_t, ObjectRef,ghobject_t::BitwiseComparator>::const_iterator p = object_map.begin();
p != object_map.end();
++p) {
::encode(p->first, bl);
uint64_t used_bytes() const {
uint64_t result = 0;
- for (map<ghobject_t, ObjectRef>::const_iterator p = object_map.begin();
+ for (map<ghobject_t, ObjectRef,ghobject_t::BitwiseComparator>::const_iterator p = object_map.begin();
p != object_map.end();
++p) {
result += p->second->data.length();
bufferlist tbl;
map<coll_t, __le32> coll_index;
- map<ghobject_t, __le32> object_index;
+ map<ghobject_t, __le32, ghobject_t::BitwiseComparator> object_index;
__le32 coll_id;
__le32 object_id;
}
vector<__le32> om(other.object_index.size());
- map<ghobject_t, __le32>::iterator object_index_p;
+ map<ghobject_t, __le32, ghobject_t::BitwiseComparator>::iterator object_index_p;
for (object_index_p = other.object_index.begin();
object_index_p != other.object_index.end();
++object_index_p) {
colls[coll_index_p->second] = coll_index_p->first;
}
- map<ghobject_t, __le32>::iterator object_index_p;
+ map<ghobject_t, __le32, ghobject_t::BitwiseComparator>::iterator object_index_p;
for (object_index_p = t->object_index.begin();
object_index_p != t->object_index.end();
++object_index_p) {
return index_id;
}
__le32 _get_object_id(const ghobject_t& oid) {
- map<ghobject_t, __le32>::iterator o = object_index.find(oid);
+ map<ghobject_t, __le32, ghobject_t::BitwiseComparator>::iterator o = object_index.find(oid);
if (o != object_index.end())
return o->second;
r = store->apply_transaction(t);
ASSERT_EQ(r, 0);
}
- set<ghobject_t> all;
+ set<ghobject_t, ghobject_t::BitwiseComparator> all;
{
ObjectStore::Transaction t;
for (int i=0; i<200; ++i) {
ASSERT_EQ(r, 0);
}
for (int bitwise=0; bitwise<2; ++bitwise) {
- set<ghobject_t> saw;
+ set<ghobject_t, ghobject_t::BitwiseComparator> saw;
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
}
{
ObjectStore::Transaction t;
- for (set<ghobject_t>::iterator p = all.begin(); p != all.end(); ++p)
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator p = all.begin(); p != all.end(); ++p)
t.remove(cid, *p);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
r = store->apply_transaction(t);
ASSERT_EQ(r, 0);
}
- set<ghobject_t> all, saw;
+ set<ghobject_t, ghobject_t::BitwiseComparator> all, saw;
{
ObjectStore::Transaction t;
for (int i=0; i<200; ++i) {
}
{
ObjectStore::Transaction t;
- for (set<ghobject_t>::iterator p = all.begin(); p != all.end(); ++p)
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator p = all.begin(); p != all.end(); ++p)
t.remove(cid, *p);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
coll_t cid;
string base = "";
for (int i = 0; i < 100; ++i) base.append("aaaaa");
- set<ghobject_t> created;
+ set<ghobject_t, ghobject_t::BitwiseComparator> created;
{
ObjectStore::Transaction t;
t.create_collection(cid);
ASSERT_EQ(r, 0);
}
- for (set<ghobject_t>::iterator i = created.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = created.begin();
i != created.end();
++i) {
struct stat buf;
ASSERT_TRUE(!store->stat(cid, *i, &buf));
}
- set<ghobject_t> listed, listed2;
+ set<ghobject_t, ghobject_t::BitwiseComparator> listed, listed2;
vector<ghobject_t> objects;
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), true, INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_TRUE(listed.size() == created.size());
if (listed2.size())
ASSERT_EQ(listed.size(), listed2.size());
- for (set<ghobject_t>::iterator i = listed.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = listed.begin();
i != listed.end();
++i) {
ASSERT_TRUE(created.count(*i));
}
- for (set<ghobject_t>::iterator i = created.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = created.begin();
i != created.end();
++i) {
ObjectStore::Transaction t;
static const unsigned max_attr_value_len = 1024 * 4;
coll_t cid;
unsigned in_flight;
- map<ghobject_t, Object> contents;
- set<ghobject_t> available_objects;
- set<ghobject_t> in_flight_objects;
+ map<ghobject_t, Object, ghobject_t::BitwiseComparator> contents;
+ set<ghobject_t, ghobject_t::BitwiseComparator> available_objects;
+ set<ghobject_t, ghobject_t::BitwiseComparator> in_flight_objects;
ObjectGenerator *object_gen;
gen_type *rng;
ObjectStore *store;
cond.Wait(lock);
boost::uniform_int<> choose(0, available_objects.size() - 1);
int index = choose(*rng);
- set<ghobject_t>::iterator i = available_objects.begin();
+ set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = available_objects.begin();
for ( ; index > 0; --index, ++i) ;
ghobject_t ret = *i;
return ret;
while (in_flight)
cond.Wait(lock);
vector<ghobject_t> objects;
- set<ghobject_t> objects_set, objects_set2;
+ set<ghobject_t, ghobject_t::BitwiseComparator> objects_set, objects_set2;
ghobject_t next, current;
while (1) {
cerr << "scanning..." << std::endl;
current = next;
}
ASSERT_EQ(objects_set.size(), available_objects.size());
- for (set<ghobject_t>::iterator i = objects_set.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = objects_set.begin();
i != objects_set.end();
++i) {
ASSERT_GT(available_objects.count(*i), (unsigned)0);
ASSERT_EQ(r, 0);
objects_set2.insert(objects.begin(), objects.end());
ASSERT_EQ(objects_set2.size(), available_objects.size());
- for (set<ghobject_t>::iterator i = objects_set2.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = objects_set2.begin();
i != objects_set2.end();
++i) {
ASSERT_GT(available_objects.count(*i), (unsigned)0);
}
string base = "";
for (int i = 0; i < 100; ++i) base.append("aaaaa");
- set<ghobject_t> created;
+ set<ghobject_t, ghobject_t::BitwiseComparator> created;
for (int n = 0; n < 10; ++n) {
char nbuf[100];
sprintf(nbuf, "n%d", n);
vector<ghobject_t> objects;
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), true, INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
- set<ghobject_t> listed(objects.begin(), objects.end());
+ set<ghobject_t, ghobject_t::BitwiseComparator> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
ASSERT_TRUE(listed.size() == created.size());
objects.clear();
}
cerr << "listed.size() is " << listed.size() << std::endl;
ASSERT_TRUE(listed.size() == created.size());
- for (set<ghobject_t>::iterator i = listed.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = listed.begin();
i != listed.end();
++i) {
ASSERT_TRUE(created.count(*i));
}
- for (set<ghobject_t>::iterator i = created.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = created.begin();
i != created.end();
++i) {
ObjectStore::Transaction t;
ASSERT_EQ(r, 0);
}
string base = "aaaaa";
- set<ghobject_t> created;
+ set<ghobject_t, ghobject_t::BitwiseComparator> created;
for (int i = 0; i < 1000; ++i) {
char buf[100];
sprintf(buf, "%d", i);
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), true,
INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
- set<ghobject_t> listed(objects.begin(), objects.end());
+ set<ghobject_t, ghobject_t::BitwiseComparator> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
ASSERT_TRUE(listed.size() == created.size());
objects.clear();
}
cerr << "listed.size() is " << listed.size() << std::endl;
ASSERT_TRUE(listed.size() == created.size());
- for (set<ghobject_t>::iterator i = listed.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = listed.begin();
i != listed.end();
++i) {
ASSERT_TRUE(created.count(*i));
}
- for (set<ghobject_t>::iterator i = created.begin();
+ for (set<ghobject_t, ghobject_t::BitwiseComparator>::iterator i = created.begin();
i != created.end();
++i) {
ObjectStore::Transaction t;