shard_id_t shard;
{
spg_t pgid;
- snapid_t snap;
- if (c.is_temp(pgid)) {
+ if (c.is_temp(&pgid)) {
pool = -2 - pgid.pool();
shard = pgid.shard;
- } else if (c.is_pg(pgid, snap)) {
+ } else if (c.is_pg(&pgid)) {
pool = pgid.pool();
shard = pgid.shard;
} else if (c.is_meta()) {
return 0;
spg_t spgid;
- if (!c.is_pg_prefix(spgid))
+ if (!c.is_pg_prefix(&spgid))
return -EINVAL;
const ps_t ps = spgid.pgid.ps();
bool r = parse_object(long_name.c_str(), *out);
int64_t pool = -1;
spg_t pg;
- if (coll().is_pg_prefix(pg))
+ if (coll().is_pg_prefix(&pg))
pool = (int64_t)pg.pgid.pool();
out->hobj.pool = pool;
if (!r) return r;
int64_t pool = -1;
spg_t pg;
- if (coll().is_pg_prefix(pg))
+ if (coll().is_pg_prefix(&pg))
pool = (int64_t)pg.pgid.pool();
(*out) = ghobject_t(hobject_t(name, key, snap, hash, pool, ""));
return true;
it != ls.end();
++it) {
spg_t pgid;
- snapid_t snap;
-
- if (it->is_temp(pgid) ||
+ if (it->is_temp(&pgid) ||
it->is_removal(&pgid) ||
- (it->is_pg(pgid, snap) &&
- PG::_has_removal_flag(store, pgid))) {
+ (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
dout(10) << "load_pgs " << *it << " clearing temp" << dendl;
recursive_remove_collection(store, pgid, *it);
continue;
}
- if (it->is_pg(pgid, snap)) {
- if (snap != CEPH_NOSNAP) {
- dout(10) << "load_pgs skipping snapped dir " << *it
- << " (pg " << pgid << " snap " << snap << ")" << dendl;
- pgs[pgid].insert(snap);
- } else {
- pgs[pgid];
- head_pgs.insert(pgid);
- }
+ if (it->is_pg(&pgid)) {
+ pgs[pgid];
+ head_pgs.insert(pgid);
continue;
}
assert(bl);
{
// validate collection name
- spg_t pgid_temp;
- snapid_t snap;
- bool ok = coll.is_pg(pgid_temp, snap);
- assert(ok);
+ assert(coll.is_pg());
}
// try for v8
return false;
}
-bool coll_t::is_temp(spg_t& pgid) const
+bool coll_t::is_temp(spg_t *pgid) const
{
const char *cstr(str.c_str());
- if (!pgid.parse(cstr))
+ if (!pgid->parse(cstr))
return false;
const char *tmp_start = strchr(cstr, '_');
if (!tmp_start)
return false;
}
-bool coll_t::is_pg(spg_t& pgid, snapid_t& snap) const
+bool coll_t::is_pg(spg_t *pgid) const
{
const char *cstr(str.c_str());
- if (!pgid.parse(cstr))
+ if (!pgid->parse(cstr))
return false;
const char *snap_start = strchr(cstr, '_');
if (!snap_start)
return false;
- if (strncmp(snap_start, "_head", 5) == 0) {
- snap = CEPH_NOSNAP;
- } else {
- errno = 0;
- snap = strtoull(snap_start+1, 0, 16);
- if (errno)
- return false;
- }
+ if (strncmp(snap_start, "_head", 5) != 0)
+ return false;
return true;
}
-bool coll_t::is_pg_prefix(spg_t& pgid) const
+bool coll_t::is_pg_prefix(spg_t *pgid) const
{
const char *cstr(str.c_str());
- if (!pgid.parse(cstr))
+ if (!pgid->parse(cstr))
return false;
const char *snap_start = strchr(cstr, '_');
if (!snap_start)
bool is_meta() const {
return str == string("meta");
}
- bool is_pg_prefix(spg_t& pgid) const;
- bool is_pg(spg_t& pgid, snapid_t& snap) const;
- bool is_temp(spg_t& pgid) const;
+ bool is_pg_prefix(spg_t *pgid) const;
+ bool is_pg(spg_t *pgid) const;
+ bool is_pg() const {
+ spg_t pgid;
+ return is_pg(&pgid);
+ }
+ bool is_temp(spg_t *pgid) const;
bool is_temp() const;
bool is_removal(spg_t *pgid) const;
void encode(bufferlist& bl) const;
// which we presume is a pg collection.
coll_t get_temp() {
spg_t pgid;
- snapid_t snap;
- bool foo = is_pg(pgid, snap);
- assert(foo);
- assert(snap == CEPH_NOSNAP);
+ bool valid = is_pg(&pgid);
+ assert(valid);
return coll_t(str.substr(0, str.length() - 4) + "TEMP");
}
i != candidates.end();
++i) {
spg_t cand_pgid;
- snapid_t snap;
- if (!i->is_pg(cand_pgid, snap))
- continue;
- if (snap != CEPH_NOSNAP)
+ if (!i->is_pg(&cand_pgid))
continue;
// If an exact match or treat no shard as any shard
for (vector<coll_t>::iterator i = candidates.begin();
i != candidates.end();
++i) {
- spg_t pgid;
- snapid_t snap;
- if (i->is_pg(pgid, snap)) {
+ if (i->is_pg()) {
colls_to_check.push_back(*i);
}
}
void remove_coll(ObjectStore *store, const coll_t &coll)
{
spg_t pg;
- coll.is_pg_prefix(pg);
+ coll.is_pg_prefix(&pg);
OSDriver driver(
store,
coll_t(),
it != ls.end();
++it) {
spg_t pgid;
- snapid_t snap;
- if (it->is_temp(pgid) ||
+ if (it->is_temp(&pgid) ||
it->is_removal(&pgid) ||
- (it->is_pg(pgid, snap) && PG::_has_removal_flag(store, pgid))) {
+ (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
cout << "finish_remove_pgs " << *it << " removing " << pgid << std::endl;
OSD::recursive_remove_collection(store, pgid, *it);
continue;
coll_t(),
OSD::make_snapmapper_oid());
spg_t pg;
- coll.is_pg_prefix(pg);
+ coll.is_pg_prefix(&pg);
SnapMapper mapper(&driver, 0, 0, 0, pg.shard);
assert(g_ceph_context);
pg_t pgid = curmap.raw_pg_to_pg(raw_pgid);
spg_t coll_pgid;
- snapid_t coll_snap;
- if (coll.is_pg(coll_pgid, coll_snap) == false) {
+ if (coll.is_pg(&coll_pgid) == false) {
cerr << "INTERNAL ERROR: Bad collection during import" << std::endl;
return -EFAULT;
}
int do_remove_object(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
spg_t pg;
- coll.is_pg_prefix(pg);
+ coll.is_pg_prefix(&pg);
OSDriver driver(
store,
coll_t(),
// Find pg
for (it = ls.begin(); it != ls.end(); ++it) {
- snapid_t snap;
spg_t tmppgid;
- if (!it->is_pg(tmppgid, snap)) {
+ if (!it->is_pg(&tmppgid)) {
continue;
}
- if (it->is_temp(tmppgid)) {
+ if (it->is_temp(&tmppgid)) {
continue;
}
if (op != "list-pgs" && tmppgid != pgid) {
continue;
}
- if (snap != CEPH_NOSNAP) {
- if (debug)
- cerr << "skipping snapped dir " << *it
- << " (pg " << pgid << " snap " << snap << ")" << std::endl;
- continue;
- }
if (op != "list-pgs") {
//Found!