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);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
unsigned LIST_AT_A_TIME = 100;
ghobject_t next;
try {
auto ch = fs->open_collection(coll_t(pgid));
if (!ch) {
+ cerr << "pgid " << pgid << " does not exist" << std::endl;
return -ENOENT;
}
ostringstream oss;
ghobject_t oid = pgid.make_pgmeta_oid();
struct stat st;
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "pgid " << pgid << " does not exist" << std::endl;
+ return -ENOENT;
+ }
int r = store->stat(ch, oid, &st);
ceph_assert(r == 0);
ceph_assert(st.st_size == 0);
footer ft;
auto ch = store->open_collection(cid);
+ if (!ch) {
+ cerr << "Collection " << cid << " does not exist" << std::endl;
+ return -ENOENT;
+ }
int ret = store->stat(ch, obj, &st);
if (ret < 0)
return ret;
{
ghobject_t next;
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
while (!next.is_max()) {
vector<ghobject_t> objects;
int r = store->collection_list(ch, next, ghobject_t::get_max(), 300,
}
}
auto ch = store->open_collection(coll_t::meta());
+ if (!ch) {
+ return -ENOENT;
+ }
const ghobject_t inc_oid = OSD::get_inc_osdmap_pobject_name(e);
if (!store->exists(ch, inc_oid)) {
cerr << "inc-osdmap (" << inc_oid << ") does not exist." << std::endl;
int get_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl)
{
auto ch = store->open_collection(coll_t::meta());
+ if (!ch) {
+ cerr << "Collection " << coll_t::meta() << " does not exist" << std::endl;
+ return -ENOENT;
+ }
if (store->read(ch,
OSD::get_inc_osdmap_pobject_name(e),
0, 0, bl) < 0) {
}
}
auto ch = store->open_collection(coll_t::meta());
+ if (!ch) {
+ cerr << "Collection " << coll_t::meta() << " does not exist" << std::endl;
+ return -ENOENT;
+ }
const ghobject_t full_oid = OSD::get_osdmap_pobject_name(e);
if (!store->exists(ch, full_oid)) {
cerr << "osdmap (" << full_oid << ") does not exist." << std::endl;
pg_missing_t missing;
auto ch = fs->open_collection(coll_t(pgid));
if (!ch) {
+ cerr << "pgid " << pgid << " does not exist" << std::endl;
return -ENOENT;
}
ostringstream oss;
as.decode(ebliter);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
if (debug)
cerr << "\tattrs: len " << as.data.size() << std::endl;
t->setattrs(coll, hoid, as.data);
ceph_assert(g_ceph_context);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
if (ob.hoid.hobj.nspace != g_ceph_context->_conf->osd_hit_set_namespace) {
object_t oid = ob.hoid.hobj.oid;
object_locator_t loc(ob.hoid.hobj);
spg_t coll_pgid;
if (coll.is_pg(&coll_pgid) == false) {
- cerr << "INTERNAL ERROR: Bad collection during import" << std::endl;
+ cerr << "INTERNAL ERROR: Bad collection during import: "
+ << coll_pgid << " does not exist" << std::endl;
return -EFAULT;
}
if (coll_pgid.shard != ob.hoid.shard_id) {
ghobject_t &ghobj, bool all, bool force, enum rmtype type)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
spg_t pg;
coll.is_pg_prefix(&pg);
OSDriver driver(
int do_list_attrs(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
map<string,bufferptr,less<>> aset;
int r = store->getattrs(ch, ghobj, aset);
if (r < 0) {
int do_list_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, ghobj);
if (!iter) {
cerr << "omap_get_iterator: " << cpp_strerror(ENOENT) << std::endl;
int do_get_bytes(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
struct stat st;
mysize_t total;
} while(true);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
if (!dry_run)
store->queue_transaction(ch, std::move(*t));
return 0;
int do_get_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
bufferptr bp;
int r = store->getattr(ch, ghobj, key.c_str(), bp);
t->setattr(coll, ghobj, key, bl);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
store->queue_transaction(ch, std::move(*t));
return 0;
}
t->rmattr(coll, ghobj, key);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
store->queue_transaction(ch, std::move(*t));
return 0;
}
int do_get_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
set<string> keys;
map<string, bufferlist> out;
t->omap_setkeys(coll, ghobj, attrset);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
store->queue_transaction(ch, std::move(*t));
return 0;
}
t->omap_rmkey(coll, ghobj, key);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
store->queue_transaction(ch, std::move(*t));
return 0;
}
int do_get_omaphdr(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
bufferlist hdrbl;
int r = store->omap_get_header(ch, ghobj, &hdrbl, true);
t->omap_setheader(coll, ghobj, hdrbl);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
store->queue_transaction(ch, std::move(*t));
return 0;
}
int get_snapset(ObjectStore *store, coll_t coll, ghobject_t &ghobj, SnapSet &ss, bool silent = false)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
bufferlist attr;
int r = store->getattr(ch, ghobj, SS_ATTR, attr);
if (r < 0) {
int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter* formatter)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
int r = 0;
formatter->open_object_section("obj");
formatter->open_object_section("id");
int corrupt_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter* formatter)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
bufferlist attr;
int r = store->getattr(ch, ghobj, OI_ATTR, attr);
if (r < 0) {
encode(oi, attr, -1); /* fixme: using full features */
t.setattr(coll, ghobj, OI_ATTR, attr);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
r = store->queue_transaction(ch, std::move(t));
if (r < 0) {
cerr << "Error writing object info: " << make_pair(coll, ghobj) << ", "
bool corrupt)
{
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
if (ghobj.hobj.is_snapdir()) {
cerr << "Can't set the size of a snapdir" << std::endl;
return -EINVAL;
t.setattr(coll, head, SS_ATTR, snapattr);
}
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
r = store->queue_transaction(ch, std::move(t));
if (r < 0) {
cerr << "Error writing object info: " << make_pair(coll, ghobj) << ", "
int clear_data_digest(ObjectStore *store, coll_t coll, ghobject_t &ghobj) {
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
bufferlist attr;
int r = store->getattr(ch, ghobj, OI_ATTR, attr);
if (r < 0) {
ObjectStore::Transaction t;
t.setattr(coll, ghobj, OI_ATTR, attr);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
r = store->queue_transaction(ch, std::move(t));
if (r < 0) {
cerr << "Error writing object info: " << make_pair(coll, ghobj) << ", "
ObjectStore::Transaction t;
t.setattr(coll, ghobj, SS_ATTR, bl);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
int r = store->queue_transaction(ch, std::move(t));
if (r < 0) {
cerr << "Error setting snapset on : " << make_pair(coll, ghobj) << ", "
ObjectStore::Transaction t;
t.setattr(coll, ghobj, SS_ATTR, bl);
auto ch = store->open_collection(coll);
+ if (!ch) {
+ cerr << "Collection " << coll << " does not exist" << std::endl;
+ return -ENOENT;
+ }
int r = store->queue_transaction(ch, std::move(t));
if (r < 0) {
cerr << "Error setting snapset on : " << make_pair(coll, ghobj) << ", "
for (auto cid : collections) {
cout << i++ << "/" << num << " " << cid << std::endl;
auto ch = src->open_collection(cid);
+ if (!ch) {
+ cerr << "Collection " << cid << " does not exist" << std::endl;
+ return -ENOENT;
+ }
auto dch = dst->create_new_collection(cid);
+ if (!dch) {
+ return -ENOENT;
+ }
{
ObjectStore::Transaction t;
int bits = src->collection_bits(ch);
if (ls.empty()) {
break;
}
-
+
for (auto& oid : ls) {
//cout << " " << cid << " " << oid << std::endl;
if (n % 100 == 0) {
fs->queue_transaction(ch, std::move(*t));
}
cout << "Reseting last_complete succeeded" << std::endl;
-
+
} else if (op == "pg-log-inject-dups") {
if (!vm.count("file") || file == "-") {
cerr << "Must provide file containing JSON dups entries" << std::endl;