}
//Based on RemoveWQ::_process()
-void remove_coll(ObjectStore *store, const coll_t &coll)
+void remove_coll(ObjectStore *store, const coll_t &coll,
+ ObjectStore::Sequencer &osr)
{
spg_t pg;
coll.is_pg_prefix(&pg);
- ObjectStore::Sequencer osr(__func__);
OSDriver driver(
store,
coll_t(),
return 0;
}
-int initiate_new_remove_pg(ObjectStore *store, spg_t r_pgid)
+int initiate_new_remove_pg(ObjectStore *store, spg_t r_pgid,
+ ObjectStore::Sequencer &osr)
{
if (!dry_run)
finish_remove_pgs(store);
if (dry_run)
return 0;
ObjectStore::Transaction *rmt = new ObjectStore::Transaction;
- ObjectStore::Sequencer osr(__func__);
int r = mark_pg_for_removal(store, r_pgid, rmt);
if (r < 0) {
delete rmt;
return 0;
}
-int set_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
+int set_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force,
+ ObjectStore::Sequencer &osr) {
OSDMap::Incremental inc;
bufferlist::iterator it = bl.begin();
inc.decode(it);
cout << "Creating a new epoch." << std::endl;
}
ObjectStore::Transaction t;
- ObjectStore::Sequencer osr(__func__);
t.write(coll_t::meta(), inc_oid, 0, bl.length(), bl);
t.truncate(coll_t::meta(), inc_oid, bl.length());
int ret = store->apply_transaction(&osr, t);
return 0;
}
-int set_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
+int set_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force,
+ ObjectStore::Sequencer &osr) {
OSDMap osdmap;
osdmap.decode(bl);
if (e == 0) {
}
cout << "Creating a new epoch." << std::endl;
}
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction t;
t.write(coll_t::meta(), full_oid, 0, bl.length(), bl);
t.truncate(coll_t::meta(), full_oid, bl.length());
}
int ObjectStoreTool::get_object(ObjectStore *store, coll_t coll,
- bufferlist &bl, OSDMap &curmap, bool *skipped_objects)
+ bufferlist &bl, OSDMap &curmap,
+ bool *skipped_objects,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
bufferlist::iterator ebliter = bl.begin();
}
int ObjectStoreTool::do_import(ObjectStore *store, OSDSuperblock& sb,
- bool force, std::string pgidstr)
+ bool force, std::string pgidstr,
+ ObjectStore::Sequencer &osr)
{
bufferlist ebl;
pg_info_t info;
}
if (!dry_run) {
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction *t = new ObjectStore::Transaction;
PG::_create(*t, pgid,
pgid.get_split_bits(curmap.get_pg_pool(pgid.pool())->get_pg_num()));
}
switch(type) {
case TYPE_OBJECT_BEGIN:
- ret = get_object(store, coll, ebl, curmap, &skipped_objects);
+ ret = get_object(store, coll, ebl, curmap, &skipped_objects, osr);
if (ret) return ret;
break;
case TYPE_PG_METADATA:
return -EFAULT;
}
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction t;
if (!dry_run) {
pg_log_t newlog, reject;
return 0;
}
-int do_remove_object(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
+int do_remove_object(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj,
+ ObjectStore::Sequencer &osr)
{
spg_t pg;
coll.is_pg_prefix(&pg);
- ObjectStore::Sequencer osr(__func__);
OSDriver driver(
store,
coll_t(),
return 0;
}
-int do_set_bytes(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
+int do_set_bytes(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, int fd,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
return 0;
}
-int do_set_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key, int fd)
+int do_set_attr(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, string key, int fd,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
bufferlist bl;
return 0;
}
-int do_rm_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
+int do_rm_attr(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, string key,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
return 0;
}
-int do_set_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key, int fd)
+int do_set_omap(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, string key, int fd,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
map<string, bufferlist> attrset;
return 0;
}
-int do_rm_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
+int do_rm_omap(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, string key,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
set<string> keys;
return 0;
}
-int do_set_omaphdr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
+int do_set_omaphdr(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, int fd,
+ ObjectStore::Sequencer &osr)
{
- ObjectStore::Sequencer osr(__func__);
ObjectStore::Transaction tran;
ObjectStore::Transaction *t = &tran;
bufferlist hdrbl;
}
struct do_fix_lost : public action_on_object_t {
- virtual int call(ObjectStore *store, coll_t coll, ghobject_t &ghobj, object_info_t &oi) {
+ ObjectStore::Sequencer *osr;
+
+ do_fix_lost(ObjectStore::Sequencer *_osr) : osr(_osr) {}
+
+ virtual int call(ObjectStore *store, coll_t coll,
+ ghobject_t &ghobj, object_info_t &oi) {
if (oi.is_lost()) {
cout << coll << "/" << ghobj << " is lost";
if (!dry_run)
oi.clear_flag(object_info_t::FLAG_LOST);
bufferlist bl;
::encode(oi, bl);
- ObjectStore::Sequencer osr("do_fix_lost");
ObjectStore::Transaction t;
t.setattr(coll, ghobj, OI_ATTR, bl);
- int r = store->apply_transaction(&osr, t);
+ int r = store->apply_transaction(osr, t);
if (r < 0) {
cerr << "Error getting fixing attr on : " << make_pair(coll, ghobj)
<< ", "
myexit(1);
}
+ ObjectStore::Sequencer *osr = new ObjectStore::Sequencer(__func__);
int ret = fs->mount();
if (ret < 0) {
if (ret == -EBUSY) {
bool fs_sharded_objects = fs->get_allow_sharded_objects();
- ObjectStore::Sequencer osr(__func__);
-
vector<coll_t> ls;
vector<coll_t>::iterator it;
CompatSet supported;
bl.clear();
::encode(superblock, bl);
t.write(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
- ret = fs->apply_transaction(&osr, t);
+ ret = fs->apply_transaction(osr, t);
if (ret < 0) {
cerr << "Error writing OSD superblock: " << cpp_strerror(ret) << std::endl;
goto out;
if (op == "import") {
try {
- ret = tool.do_import(fs, superblock, force, pgidstr);
+ ret = tool.do_import(fs, superblock, force, pgidstr, *osr);
}
catch (const buffer::error &e) {
cerr << "do_import threw exception error " << e.what() << std::endl;
if (ret < 0) {
cerr << "Failed to read osdmap " << cpp_strerror(ret) << std::endl;
} else {
- ret = set_osdmap(fs, epoch, bl, force);
+ ret = set_osdmap(fs, epoch, bl, force, *osr);
}
goto out;
} else if (op == "get-inc-osdmap") {
cerr << "Failed to read incremental osdmap " << cpp_strerror(ret) << std::endl;
goto out;
} else {
- ret = set_inc_osdmap(fs, epoch, bl, force);
+ ret = set_inc_osdmap(fs, epoch, bl, force, *osr);
}
goto out;
}
biginfo_oid = OSD::make_pg_biginfo_oid(pgid);
if (op == "remove") {
- ret = initiate_new_remove_pg(fs, pgid);
+ ret = initiate_new_remove_pg(fs, pgid, *osr);
if (ret < 0) {
cerr << "PG '" << pgid << "' not found" << std::endl;
goto out;
if (op == "fix-lost") {
boost::scoped_ptr<action_on_object_t> action;
- action.reset(new do_fix_lost());
+ action.reset(new do_fix_lost(osr));
if (pgidstr.length())
ret = action_on_all_objects_in_exact_pg(fs, coll_t(pgid), *action, debug);
else
if (vm.count("objcmd")) {
ret = 0;
if (objcmd == "remove") {
- ret = do_remove_object(fs, coll, ghobj);
+ ret = do_remove_object(fs, coll, ghobj, *osr);
goto out;
} else if (objcmd == "list-attrs") {
ret = do_list_attrs(fs, coll, ghobj);
goto out;
}
}
- ret = do_set_bytes(fs, coll, ghobj, fd);
+ ret = do_set_bytes(fs, coll, ghobj, fd, *osr);
if (fd != STDIN_FILENO)
close(fd);
}
goto out;
}
}
- ret = do_set_attr(fs, coll, ghobj, arg1, fd);
+ ret = do_set_attr(fs, coll, ghobj, arg1, fd, *osr);
if (fd != STDIN_FILENO)
close(fd);
goto out;
ret = 1;
goto out;
}
- ret = do_rm_attr(fs, coll, ghobj, arg1);
+ ret = do_rm_attr(fs, coll, ghobj, arg1, *osr);
goto out;
} else if (objcmd == "get-omap") {
if (vm.count("arg1") == 0) {
goto out;
}
}
- ret = do_set_omap(fs, coll, ghobj, arg1, fd);
+ ret = do_set_omap(fs, coll, ghobj, arg1, fd, *osr);
if (fd != STDIN_FILENO)
close(fd);
goto out;
ret = 1;
goto out;
}
- ret = do_rm_omap(fs, coll, ghobj, arg1);
+ ret = do_rm_omap(fs, coll, ghobj, arg1, *osr);
goto out;
} else if (objcmd == "get-omaphdr") {
if (vm.count("arg1")) {
goto out;
}
}
- ret = do_set_omaphdr(fs, coll, ghobj, fd);
+ ret = do_set_omaphdr(fs, coll, ghobj, fd, *osr);
if (fd != STDIN_FILENO)
close(fd);
goto out;
ret = write_info(*t, map_epoch, info, past_intervals);
if (ret == 0) {
- fs->apply_transaction(&osr, *t);
+ fs->apply_transaction(osr, *t);
cout << "Removal succeeded" << std::endl;
}
} else if (op == "mark-complete") {
ret = write_info(*t, map_epoch, info, past_intervals);
if (ret == 0) {
- fs->apply_transaction(&osr, *t);
+ fs->apply_transaction(osr, *t);
cout << "Marking complete succeeded" << std::endl;
}
} else {
out:
int r = fs->umount();
+ delete osr;
if (r < 0) {
cerr << "umount failed: " << cpp_strerror(r) << std::endl;
// If no previous error, then use umount() error