Merge pull request #41520 from tchaikov/wip-osd-unique-ptr

os: let ObjectStore::create() return unique_ptr<>

Reviewed-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
Kefu Chai 2021-05-29 10:37:31 +08:00 committed by GitHub
commit 2a35c562a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 151 additions and 146 deletions

View File

@ -323,11 +323,11 @@ int main(int argc, const char **argv)
std::string journal_path = g_conf().get_val<std::string>("osd_journal");
uint32_t flags = g_conf().get_val<uint64_t>("osd_os_flags");
ObjectStore *store = ObjectStore::create(g_ceph_context,
store_type,
data_path,
journal_path,
flags);
std::unique_ptr<ObjectStore> store = ObjectStore::create(g_ceph_context,
store_type,
data_path,
journal_path,
flags);
if (!store) {
derr << "unable to create object store" << dendl;
forker.exit(-ENODEV);
@ -369,7 +369,7 @@ int main(int argc, const char **argv)
forker.exit(-EINVAL);
}
int err = OSD::mkfs(g_ceph_context, store, g_conf().get_val<uuid_d>("fsid"),
int err = OSD::mkfs(g_ceph_context, std::move(store), g_conf().get_val<uuid_d>("fsid"),
whoami, osdspec_affinity);
if (err < 0) {
derr << TEXT_RED << " ** ERROR: error creating empty object store in "
@ -438,7 +438,7 @@ int main(int argc, const char **argv)
<< " for object store " << data_path
<< dendl;
flushjournal_out:
delete store;
store.reset();
forker.exit(err < 0 ? 1 : 0);
}
if (dump_journal) {
@ -477,7 +477,7 @@ flushjournal_out:
uuid_d cluster_fsid, osd_fsid;
ceph_release_t require_osd_release = ceph_release_t::unknown;
int w;
int r = OSD::peek_meta(store, &magic, &cluster_fsid, &osd_fsid, &w,
int r = OSD::peek_meta(store.get(), &magic, &cluster_fsid, &osd_fsid, &w,
&require_osd_release);
if (r < 0) {
derr << TEXT_RED << " ** ERROR: unable to open OSD superblock on "
@ -678,7 +678,7 @@ flushjournal_out:
}
osdptr = new OSD(g_ceph_context,
store,
std::move(store),
whoami,
ms_cluster,
ms_public,

View File

@ -30,44 +30,45 @@
using std::string;
ObjectStore *ObjectStore::create(CephContext *cct,
const string& type,
const string& data,
const string& journal,
osflagbits_t flags)
std::unique_ptr<ObjectStore> ObjectStore::create(
CephContext *cct,
const string& type,
const string& data,
const string& journal,
osflagbits_t flags)
{
#ifndef WITH_SEASTAR
if (type == "filestore") {
return new FileStore(cct, data, journal, flags);
return std::make_unique<FileStore>(cct, data, journal, flags);
}
if (type == "memstore") {
return new MemStore(cct, data);
return std::make_unique<MemStore>(cct, data);
}
#endif
#if defined(WITH_BLUESTORE)
if (type == "bluestore") {
return new BlueStore(cct, data);
return std::make_unique<BlueStore>(cct, data);
}
#ifndef WITH_SEASTAR
if (type == "random") {
if (rand() % 2) {
return new FileStore(cct, data, journal, flags);
return std::make_unique<FileStore>(cct, data, journal, flags);
} else {
return new BlueStore(cct, data);
return std::make_unique<BlueStore>(cct, data);
}
}
#endif
#else
#ifndef WITH_SEASTAR
if (type == "random") {
return new FileStore(cct, data, journal, flags);
return std::make_unique<FileStore>(cct, data, journal, flags);
}
#endif
#endif
#ifndef WITH_SEASTAR
if (type == "kstore" &&
cct->check_experimental_feature_enabled("kstore")) {
return new KStore(cct, data);
return std::make_unique<KStore>(cct, data);
}
#endif
return NULL;

View File

@ -29,8 +29,9 @@
#include <errno.h>
#include <sys/stat.h>
#include <vector>
#include <map>
#include <memory>
#include <vector>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) || defined(_WIN32)
#include <sys/statvfs.h>
@ -77,11 +78,12 @@ public:
* @param journal path (or other descriptor) for journal (optional)
* @param flags which filestores should check if applicable
*/
static ObjectStore *create(CephContext *cct,
const std::string& type,
const std::string& data,
const std::string& journal,
osflagbits_t flags = 0);
static std::unique_ptr<ObjectStore> create(
CephContext *cct,
const std::string& type,
const std::string& data,
const std::string& journal,
osflagbits_t flags = 0);
/**
* probe a block device to learn the uuid of the owning OSD

View File

@ -24,7 +24,6 @@
#include <sys/stat.h>
#include <signal.h>
#include <time.h>
#include <boost/scoped_ptr.hpp>
#include <boost/range/adaptor/reversed.hpp>
#ifdef HAVE_SYS_PARAM_H
@ -42,6 +41,7 @@
#include "include/types.h"
#include "include/compat.h"
#include "include/random.h"
#include "include/scope_guard.h"
#include "OSD.h"
#include "OSDMap.h"
@ -254,7 +254,7 @@ CompatSet OSD::get_osd_compat_set() {
OSDService::OSDService(OSD *osd, ceph::async::io_context_pool& poolctx) :
osd(osd),
cct(osd->cct),
whoami(osd->whoami), store(osd->store),
whoami(osd->whoami), store(osd->store.get()),
log_client(osd->log_client), clog(osd->clog),
pg_recovery_stats(osd->pg_recovery_stats),
cluster_messenger(osd->cluster_messenger),
@ -2030,14 +2030,16 @@ int heap(CephContext& cct, const cmdmap_t& cmdmap, Formatter& f, std::ostream& o
} // namespace ceph::osd_cmds
int OSD::mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, string osdspec_affinity)
int OSD::mkfs(CephContext *cct,
std::unique_ptr<ObjectStore> store,
uuid_d fsid,
int whoami,
string osdspec_affinity)
{
int ret;
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);
@ -2045,7 +2047,7 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, str
if (ret) {
derr << "OSD::mkfs: ObjectStore::mkfs failed with error "
<< cpp_strerror(ret) << dendl;
goto free_store;
return ret;
}
store->set_cache_shards(1); // doesn't matter for mkfs!
@ -2054,15 +2056,20 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, str
if (ret) {
derr << "OSD::mkfs: couldn't mount ObjectStore: error "
<< cpp_strerror(ret) << dendl;
goto free_store;
return ret;
}
ch = store->open_collection(coll_t::meta());
auto umount_store = make_scope_guard([&] {
store->umount();
});
ObjectStore::CollectionHandle 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;
return ret;
}
/* if we already have superblock, check content of superblock */
dout(0) << " have superblock" << dendl;
@ -2071,14 +2078,12 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, str
if (whoami != sb.whoami) {
derr << "provided osd id " << whoami << " != superblock's " << sb.whoami
<< dendl;
ret = -EINVAL;
goto umount_store;
return -EINVAL;
}
if (fsid != sb.cluster_fsid) {
derr << "provided cluster fsid " << fsid
<< " != superblock's " << sb.cluster_fsid << dendl;
ret = -EINVAL;
goto umount_store;
return -EINVAL;
}
} else {
// create superblock
@ -2099,24 +2104,15 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, str
if (ret) {
derr << "OSD::mkfs: error while writing OSD_SUPERBLOCK_GOBJECT: "
<< "queue_transaction returned " << cpp_strerror(ret) << dendl;
goto umount_store;
return ret;
}
}
ret = write_meta(cct, store, sb.cluster_fsid, sb.osd_fsid, whoami, osdspec_affinity);
ret = write_meta(cct, store.get(), sb.cluster_fsid, sb.osd_fsid, whoami, osdspec_affinity);
if (ret) {
derr << "OSD::mkfs: failed to write fsid file: error "
<< cpp_strerror(ret) << dendl;
goto umount_store;
}
umount_store:
if (ch) {
ch.reset();
}
store->umount();
free_store:
delete store;
return ret;
}
@ -2223,7 +2219,8 @@ int OSD::peek_meta(ObjectStore *store,
// cons/des
OSD::OSD(CephContext *cct_, ObjectStore *store_,
OSD::OSD(CephContext *cct_,
std::unique_ptr<ObjectStore> store_,
int id,
Messenger *internal_messenger,
Messenger *external_messenger,
@ -2246,7 +2243,7 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
mgrc(cct_, client_messenger, &mc->monmap),
logger(create_logger()),
recoverystate_perf(create_recoverystate_perf()),
store(store_),
store(std::move(store_)),
log_client(cct, client_messenger, &mc->monmap, LogClient::NO_FLAGS),
clog(log_client.create_channel()),
whoami(id),
@ -2338,7 +2335,6 @@ OSD::~OSD()
cct->get_perfcounters_collection()->remove(logger);
delete recoverystate_perf;
delete logger;
delete store;
}
double OSD::get_tick_interval() const
@ -3310,7 +3306,7 @@ int OSD::enable_disable_fuse(bool stop)
<< cpp_strerror(r) << dendl;
return r;
}
fuse_store = new FuseStore(store, mntpath);
fuse_store = new FuseStore(store.get(), mntpath);
r = fuse_store->start();
if (r < 0) {
derr << __func__ << " unable to start fuse: " << cpp_strerror(r) << dendl;
@ -3555,7 +3551,7 @@ int OSD::init()
auto ch = service.meta_ch;
auto hoid = make_snapmapper_oid();
unsigned max = cct->_conf->osd_target_transaction_size;
r = SnapMapper::convert_legacy(cct, store, ch, hoid, max);
r = SnapMapper::convert_legacy(cct, store.get(), ch, hoid, max);
if (r < 0)
goto out;
}
@ -3792,8 +3788,7 @@ int OSD::init()
out:
enable_disable_fuse(true);
store->umount();
delete store;
store = NULL;
store.reset();
return r;
}
@ -3937,7 +3932,7 @@ void OSD::final_init()
"Dump store's statistics for the given pool");
ceph_assert(r == 0);
test_ops_hook = new TestOpsSocketHook(&(this->service), this->store);
test_ops_hook = new TestOpsSocketHook(&(this->service), this->store.get());
// Note: pools are CephString instead of CephPoolname because
// these commands traditionally support both pool names and numbers
r = admin_socket->register_command(
@ -4356,8 +4351,7 @@ int OSD::shutdown()
std::lock_guard lock(osd_lock);
store->umount();
delete store;
store = nullptr;
store.reset();
dout(10) << "Store synced" << dendl;
op_tracker.on_shutdown();
@ -4797,10 +4791,10 @@ void OSD::load_pgs()
++it) {
spg_t pgid;
if (it->is_temp(&pgid) ||
(it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
(it->is_pg(&pgid) && PG::_has_removal_flag(store.get(), pgid))) {
dout(10) << "load_pgs " << *it
<< " removing, legacy or flagged for removal pg" << dendl;
recursive_remove_collection(cct, store, pgid, *it);
recursive_remove_collection(cct, store.get(), pgid, *it);
continue;
}
@ -4811,7 +4805,7 @@ void OSD::load_pgs()
dout(10) << "pgid " << pgid << " coll " << coll_t(pgid) << dendl;
epoch_t map_epoch = 0;
int r = PG::peek_map_epoch(store, pgid, &map_epoch);
int r = PG::peek_map_epoch(store.get(), pgid, &map_epoch);
if (r < 0) {
derr << __func__ << " unable to peek at " << pgid << " metadata, skipping"
<< dendl;
@ -4841,7 +4835,7 @@ void OSD::load_pgs()
pg = _make_pg(get_osdmap(), pgid);
}
if (!pg) {
recursive_remove_collection(cct, store, pgid, *it);
recursive_remove_collection(cct, store.get(), pgid, *it);
continue;
}
@ -4851,13 +4845,13 @@ void OSD::load_pgs()
pg->ch = store->open_collection(pg->coll);
// read pg state, log
pg->read_state(store);
pg->read_state(store.get());
if (pg->dne()) {
dout(10) << "load_pgs " << *it << " deleting dne" << dendl;
pg->ch = nullptr;
pg->unlock();
recursive_remove_collection(cct, store, pgid, *it);
recursive_remove_collection(cct, store.get(), pgid, *it);
continue;
}
{
@ -6487,7 +6481,7 @@ void OSD::handle_get_purged_snaps_reply(MMonGetPurgedSnapsReply *m)
m->last < superblock.purged_snaps_last) {
goto out;
}
SnapMapper::record_purged_snaps(cct, store, service.meta_ch,
SnapMapper::record_purged_snaps(cct, store.get(), service.meta_ch,
make_purged_snaps_oid(), &t,
m->purged_snaps);
superblock.purged_snaps_last = m->last;
@ -6919,7 +6913,7 @@ void OSD::scrub_purged_snaps()
{
dout(10) << __func__ << dendl;
ceph_assert(ceph_mutex_is_locked(osd_lock));
SnapMapper::Scrubber s(cct, store, service.meta_ch,
SnapMapper::Scrubber s(cct, store.get(), service.meta_ch,
make_snapmapper_oid(),
make_purged_snaps_oid());
clog->debug() << "purged_snaps scrub starts";
@ -8216,7 +8210,7 @@ void OSD::handle_osd_map(MOSDMap *m)
// record new purged_snaps
if (superblock.purged_snaps_last == start - 1) {
SnapMapper::record_purged_snaps(cct, store, service.meta_ch,
SnapMapper::record_purged_snaps(cct, store.get(), service.meta_ch,
make_purged_snaps_oid(), &t,
purged_snaps);
superblock.purged_snaps_last = last;

View File

@ -100,7 +100,7 @@ public:
CephContext *cct;
ObjectStore::CollectionHandle meta_ch;
const int whoami;
ObjectStore *&store;
ObjectStore * const store;
LogClient &log_client;
LogChannelRef clog;
PGRecoveryStats &pg_recovery_stats;
@ -1119,7 +1119,7 @@ protected:
MgrClient mgrc;
PerfCounters *logger;
PerfCounters *recoverystate_perf;
ObjectStore *store;
std::unique_ptr<ObjectStore> store;
#ifdef HAVE_LIBFUSE
FuseStore *fuse_store = nullptr;
#endif
@ -2010,7 +2010,7 @@ private:
/* internal and external can point to the same messenger, they will still
* be cleaned up properly*/
OSD(CephContext *cct_,
ObjectStore *store_,
std::unique_ptr<ObjectStore> store_,
int id,
Messenger *internal,
Messenger *external,
@ -2024,7 +2024,11 @@ private:
~OSD() override;
// static bits
static int mkfs(CephContext *cct, ObjectStore *store, uuid_d fsid, int whoami, std::string osdspec_affinity);
static int mkfs(CephContext *cct,
std::unique_ptr<ObjectStore> store,
uuid_d fsid,
int whoami,
std::string osdspec_affinity);
/* remove any non-user xattrs from a std::map of them */
void filter_xattrs(std::map<std::string, ceph::buffer::ptr>& attrs) {

View File

@ -408,10 +408,10 @@ Engine::Engine(thread_data* td)
TracepointProvider::initialize<bluestore_tracepoint_traits>(g_ceph_context);
// create the ObjectStore
os.reset(ObjectStore::create(g_ceph_context,
g_conf().get_val<std::string>("osd objectstore"),
g_conf().get_val<std::string>("osd data"),
g_conf().get_val<std::string>("osd journal")));
os = ObjectStore::create(g_ceph_context,
g_conf().get_val<std::string>("osd objectstore"),
g_conf().get_val<std::string>("osd data"),
g_conf().get_val<std::string>("osd journal"));
if (!os)
throw std::runtime_error("bad objectstore type " + g_conf()->osd_objectstore);

View File

@ -16,9 +16,9 @@
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <memory>
#include <time.h>
#include <sys/mount.h>
#include <boost/scoped_ptr.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/binomial_distribution.hpp>
@ -6622,7 +6622,7 @@ INSTANTIATE_TEST_SUITE_P(
#endif
"kstore"));
void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store,
void doMany4KWritesTest(ObjectStore* store,
unsigned max_objects,
unsigned max_ops,
unsigned max_object_size,
@ -6634,7 +6634,7 @@ void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store,
coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
store_statfs_t res_stat;
SyntheticWorkloadState test_obj(store.get(),
SyntheticWorkloadState test_obj(store,
&gen,
&rng,
cid,
@ -6675,7 +6675,7 @@ TEST_P(StoreTestSpecificAUSize, Many4KWritesTest) {
StartDeferred(0x10000);
const unsigned max_object = 4*1024*1024;
doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0);
doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0);
}
TEST_P(StoreTestSpecificAUSize, Many4KWritesNoCSumTest) {
@ -6686,7 +6686,7 @@ TEST_P(StoreTestSpecificAUSize, Many4KWritesNoCSumTest) {
g_ceph_context->_conf.apply_changes(nullptr);
const unsigned max_object = 4*1024*1024;
doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0 );
doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0 );
}
TEST_P(StoreTestSpecificAUSize, TooManyBlobsTest) {
@ -6694,7 +6694,7 @@ TEST_P(StoreTestSpecificAUSize, TooManyBlobsTest) {
return;
StartDeferred(0x10000);
const unsigned max_object = 4*1024*1024;
doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0);
doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0);
}
#if defined(WITH_BLUESTORE)

View File

@ -40,10 +40,10 @@ void StoreTestFixture::SetUp()
}
ASSERT_EQ(0, r);
store.reset(ObjectStore::create(g_ceph_context,
type,
data_dir,
string("store_test_temp_journal")));
store = ObjectStore::create(g_ceph_context,
type,
data_dir,
"store_test_temp_journal");
if (!store) {
cerr << __func__ << ": objectstore type " << type << " doesn't exist yet!" << std::endl;
}
@ -113,10 +113,10 @@ void StoreTestFixture::CloseAndReopen() {
EXPECT_EQ(0, r);
ch.reset(nullptr);
store.reset(nullptr);
store.reset(ObjectStore::create(g_ceph_context,
type,
data_dir,
string("store_test_temp_journal")));
store = ObjectStore::create(g_ceph_context,
type,
data_dir,
"store_test_temp_journal");
if (!store) {
cerr << __func__ << ": objectstore type " << type << " failed to reopen!" << std::endl;
}

View File

@ -1,6 +1,6 @@
#include <string>
#include <stack>
#include <boost/scoped_ptr.hpp>
#include <memory>
#include <gtest/gtest.h>
#include "common/config_fwd.h"
@ -16,7 +16,7 @@ class StoreTestFixture : virtual public ::testing::Test {
std::string orig_death_test_style;
public:
boost::scoped_ptr<ObjectStore> store;
std::unique_ptr<ObjectStore> store;
ObjectStore::CollectionHandle ch;
explicit StoreTestFixture(const std::string& type)

View File

@ -207,11 +207,11 @@ int main(int argc, const char *argv[])
dout(0) << "repeats " << cfg.repeats << dendl;
dout(0) << "threads " << cfg.threads << dendl;
auto os = std::unique_ptr<ObjectStore>(
auto os =
ObjectStore::create(g_ceph_context,
g_conf()->osd_objectstore,
g_conf()->osd_data,
g_conf()->osd_journal));
g_conf()->osd_journal);
//Checking data folder: create if needed or error if it's not empty
DIR *dir = ::opendir(g_conf()->osd_data.c_str());

View File

@ -33,7 +33,7 @@ class TestOSDScrub: public OSD {
public:
TestOSDScrub(CephContext *cct_,
ObjectStore *store_,
std::unique_ptr<ObjectStore> store_,
int id,
Messenger *internal,
Messenger *external,
@ -44,7 +44,10 @@ public:
Messenger *osdc_messenger,
MonClient *mc, const std::string &dev, const std::string &jdev,
ceph::async::io_context_pool& ictx) :
OSD(cct_, store_, id, internal, external, hb_front_client, hb_back_client, hb_front_server, hb_back_server, osdc_messenger, mc, dev, jdev, ictx)
OSD(cct_, std::move(store_), id, internal, external,
hb_front_client, hb_back_client,
hb_front_server, hb_back_server,
osdc_messenger, mc, dev, jdev, ictx)
{
}
@ -55,7 +58,7 @@ public:
TEST(TestOSDScrub, scrub_time_permit) {
ceph::async::io_context_pool icp(1);
ObjectStore *store = ObjectStore::create(g_ceph_context,
std::unique_ptr<ObjectStore> store = ObjectStore::create(g_ceph_context,
g_conf()->osd_objectstore,
g_conf()->osd_data,
g_conf()->osd_journal);
@ -68,7 +71,7 @@ TEST(TestOSDScrub, scrub_time_permit) {
ms->bind(g_conf()->public_addr);
MonClient mc(g_ceph_context, icp);
mc.build_initial_monmap();
TestOSDScrub* osd = new TestOSDScrub(g_ceph_context, store, 0, ms, ms, ms, ms, ms, ms, ms, &mc, "", "", icp);
TestOSDScrub* osd = new TestOSDScrub(g_ceph_context, std::move(store), 0, ms, ms, ms, ms, ms, ms, ms, &mc, "", "", icp);
// These are now invalid
int err = g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "24");

View File

@ -3513,8 +3513,8 @@ int main(int argc, char **argv)
}
}
ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
if (fs == NULL) {
std::unique_ptr<ObjectStore> fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
if (!fs) {
cerr << "Unable to create store of type " << type << std::endl;
return 1;
}
@ -3577,14 +3577,14 @@ int main(int argc, char **argv)
target_type = string(bl.c_str(), bl.length() - 1); // drop \n
}
::close(fd);
ObjectStore *targetfs = ObjectStore::create(
unique_ptr<ObjectStore> targetfs = ObjectStore::create(
g_ceph_context, target_type,
target_data_path, "", 0);
if (targetfs == NULL) {
if (!targetfs) {
cerr << "Unable to open store of type " << target_type << std::endl;
return 1;
}
int r = dup(dpath, fs, target_data_path, targetfs);
int r = dup(dpath, fs.get(), target_data_path, targetfs.get());
if (r < 0) {
cerr << "dup failed: " << cpp_strerror(r) << std::endl;
return 1;
@ -3604,9 +3604,10 @@ int main(int argc, char **argv)
if (op == "fuse") {
#ifdef HAVE_LIBFUSE
FuseStore fuse(fs, mountpoint);
FuseStore fuse(fs.get(), mountpoint);
cout << "mounting fuse at " << mountpoint << " ..." << std::endl;
int r = fuse.main();
fs->umount();
if (r < 0) {
cerr << "failed to mount fuse: " << cpp_strerror(r) << std::endl;
return 1;
@ -3672,7 +3673,7 @@ int main(int argc, char **argv)
target_level = atoi(arg1.c_str());
}
ceph_assert(superblock != nullptr);
ret = apply_layout_settings(fs, *superblock, pool, pgid, dry_run, target_level);
ret = apply_layout_settings(fs.get(), *superblock, pool, pgid, dry_run, target_level);
goto out;
}
@ -3691,11 +3692,11 @@ int main(int argc, char **argv)
head = true;
lookup_ghobject lookup(object, nspace, head);
if (pgidstr == "meta")
ret = action_on_all_objects_in_exact_pg(fs, coll_t::meta(), lookup, debug);
ret = action_on_all_objects_in_exact_pg(fs.get(), coll_t::meta(), lookup, debug);
else if (pgidstr.length())
ret = action_on_all_objects_in_exact_pg(fs, coll_t(pgid), lookup, debug);
ret = action_on_all_objects_in_exact_pg(fs.get(), coll_t(pgid), lookup, debug);
else
ret = action_on_all_objects(fs, lookup, debug);
ret = action_on_all_objects(fs.get(), lookup, debug);
if (ret) {
throw std::runtime_error("Internal error");
} else {
@ -3799,7 +3800,7 @@ int main(int argc, char **argv)
if (op == "import") {
ceph_assert(superblock != nullptr);
try {
ret = tool.do_import(fs, *superblock, force, pgidstr);
ret = tool.do_import(fs.get(), *superblock, force, pgidstr);
}
catch (const buffer::error &e) {
cerr << "do_import threw exception error " << e.what() << std::endl;
@ -3831,7 +3832,7 @@ int main(int argc, char **argv)
ceph_assert(superblock != nullptr);
epoch = superblock->current_epoch;
}
ret = get_osdmap(fs, epoch, osdmap, bl);
ret = get_osdmap(fs.get(), epoch, osdmap, bl);
if (ret) {
cerr << "Failed to get osdmap#" << epoch << ": "
<< cpp_strerror(ret) << std::endl;
@ -3850,7 +3851,7 @@ int main(int argc, char **argv)
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.get(), epoch, bl, force);
}
goto out;
} else if (op == "get-inc-osdmap") {
@ -3859,7 +3860,7 @@ int main(int argc, char **argv)
ceph_assert(superblock != nullptr);
epoch = superblock->current_epoch;
}
ret = get_inc_osdmap(fs, epoch, bl);
ret = get_inc_osdmap(fs.get(), epoch, bl);
if (ret < 0) {
cerr << "Failed to get incremental osdmap# " << epoch << ": "
<< cpp_strerror(ret) << std::endl;
@ -3879,7 +3880,7 @@ int main(int argc, char **argv)
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.get(), epoch, bl, force);
}
goto out;
} else if (op == "update-mon-db") {
@ -3899,7 +3900,7 @@ int main(int argc, char **argv)
ret = -EINVAL;
goto out;
}
ret = initiate_new_remove_pg(fs, pgid);
ret = initiate_new_remove_pg(fs.get(), pgid);
if (ret < 0) {
cerr << "PG '" << pgid << "' not found" << std::endl;
goto out;
@ -3912,14 +3913,14 @@ int main(int argc, char **argv)
boost::scoped_ptr<action_on_object_t> action;
action.reset(new do_fix_lost());
if (pgidstr.length())
ret = action_on_all_objects_in_exact_pg(fs, coll_t(pgid), *action, debug);
ret = action_on_all_objects_in_exact_pg(fs.get(), coll_t(pgid), *action, debug);
else
ret = action_on_all_objects(fs, *action, debug);
ret = action_on_all_objects(fs.get(), *action, debug);
goto out;
}
if (op == "list") {
ret = do_list(fs, pgidstr, object, nspace, formatter, debug,
ret = do_list(fs.get(), pgidstr, object, nspace, formatter, debug,
human_readable, head);
if (ret < 0) {
cerr << "do_list failed: " << cpp_strerror(ret) << std::endl;
@ -3927,7 +3928,7 @@ int main(int argc, char **argv)
goto out;
}
if (op == "list-slow-omap") {
ret = do_list_slow(fs, pgidstr, object, slow_threshold, formatter, debug,
ret = do_list_slow(fs.get(), pgidstr, object, slow_threshold, formatter, debug,
human_readable);
if (ret < 0) {
cerr << "do_list failed: " << cpp_strerror(ret) << std::endl;
@ -3961,7 +3962,7 @@ int main(int argc, char **argv)
}
if (op == "meta-list") {
ret = do_meta(fs, object, formatter, debug, human_readable);
ret = do_meta(fs.get(), object, formatter, debug, human_readable);
if (ret < 0) {
cerr << "do_meta failed: " << cpp_strerror(ret) << std::endl;
}
@ -4038,13 +4039,13 @@ int main(int argc, char **argv)
type = NOSNAPMAP;
else if (rmtypestr == "snapmap")
type = SNAPMAP;
ret = do_remove_object(fs, coll, ghobj, all, force, type);
ret = do_remove_object(fs.get(), coll, ghobj, all, force, type);
goto out;
} else if (objcmd == "list-attrs") {
ret = do_list_attrs(fs, coll, ghobj);
ret = do_list_attrs(fs.get(), coll, ghobj);
goto out;
} else if (objcmd == "list-omap") {
ret = do_list_omap(fs, coll, ghobj);
ret = do_list_omap(fs.get(), coll, ghobj);
goto out;
} else if (objcmd == "get-bytes" || objcmd == "set-bytes") {
if (objcmd == "get-bytes") {
@ -4059,7 +4060,7 @@ int main(int argc, char **argv)
goto out;
}
}
ret = do_get_bytes(fs, coll, ghobj, fd);
ret = do_get_bytes(fs.get(), coll, ghobj, fd);
if (fd != STDOUT_FILENO)
close(fd);
} else {
@ -4080,7 +4081,7 @@ int main(int argc, char **argv)
goto out;
}
}
ret = do_set_bytes(fs, coll, ghobj, fd);
ret = do_set_bytes(fs.get(), coll, ghobj, fd);
if (fd != STDIN_FILENO)
close(fd);
}
@ -4091,7 +4092,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = do_get_attr(fs, coll, ghobj, arg1);
ret = do_get_attr(fs.get(), coll, ghobj, arg1);
goto out;
} else if (objcmd == "set-attr") {
if (vm.count("arg1") == 0) {
@ -4116,7 +4117,7 @@ int main(int argc, char **argv)
goto out;
}
}
ret = do_set_attr(fs, coll, ghobj, arg1, fd);
ret = do_set_attr(fs.get(), coll, ghobj, arg1, fd);
if (fd != STDIN_FILENO)
close(fd);
goto out;
@ -4126,7 +4127,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = do_rm_attr(fs, coll, ghobj, arg1);
ret = do_rm_attr(fs.get(), coll, ghobj, arg1);
goto out;
} else if (objcmd == "get-omap") {
if (vm.count("arg1") == 0) {
@ -4134,7 +4135,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = do_get_omap(fs, coll, ghobj, arg1);
ret = do_get_omap(fs.get(), coll, ghobj, arg1);
goto out;
} else if (objcmd == "set-omap") {
if (vm.count("arg1") == 0) {
@ -4159,7 +4160,7 @@ int main(int argc, char **argv)
goto out;
}
}
ret = do_set_omap(fs, coll, ghobj, arg1, fd);
ret = do_set_omap(fs.get(), coll, ghobj, arg1, fd);
if (fd != STDIN_FILENO)
close(fd);
goto out;
@ -4169,7 +4170,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = do_rm_omap(fs, coll, ghobj, arg1);
ret = do_rm_omap(fs.get(), coll, ghobj, arg1);
goto out;
} else if (objcmd == "get-omaphdr") {
if (vm.count("arg1")) {
@ -4177,7 +4178,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = do_get_omaphdr(fs, coll, ghobj);
ret = do_get_omaphdr(fs.get(), coll, ghobj);
goto out;
} else if (objcmd == "set-omaphdr") {
// Extra arg
@ -4203,7 +4204,7 @@ int main(int argc, char **argv)
goto out;
}
}
ret = do_set_omaphdr(fs, coll, ghobj, fd);
ret = do_set_omaphdr(fs.get(), coll, ghobj, fd);
if (fd != STDIN_FILENO)
close(fd);
goto out;
@ -4214,7 +4215,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = print_obj_info(fs, coll, ghobj, formatter);
ret = print_obj_info(fs.get(), coll, ghobj, formatter);
goto out;
} else if (objcmd == "corrupt-info") { // Undocumented testing feature
// There should not be any other arguments
@ -4223,7 +4224,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = corrupt_info(fs, coll, ghobj, formatter);
ret = corrupt_info(fs.get(), coll, ghobj, formatter);
goto out;
} else if (objcmd == "set-size" || objcmd == "corrupt-size") {
// Undocumented testing feature
@ -4240,10 +4241,10 @@ int main(int argc, char **argv)
goto out;
}
uint64_t size = atoll(arg1.c_str());
ret = set_size(fs, coll, ghobj, size, formatter, corrupt);
ret = set_size(fs.get(), coll, ghobj, size, formatter, corrupt);
goto out;
} else if (objcmd == "clear-data-digest") {
ret = clear_data_digest(fs, coll, ghobj);
ret = clear_data_digest(fs.get(), coll, ghobj);
goto out;
} else if (objcmd == "clear-snapset") {
// UNDOCUMENTED: For testing zap SnapSet
@ -4253,7 +4254,7 @@ int main(int argc, char **argv)
ret = 1;
goto out;
}
ret = clear_snapset(fs, coll, ghobj, arg1);
ret = clear_snapset(fs.get(), coll, ghobj, arg1);
goto out;
} else if (objcmd == "remove-clone-metadata") {
// Extra arg
@ -4273,7 +4274,7 @@ int main(int argc, char **argv)
goto out;
}
snapid_t cloneid = atoi(arg1.c_str());
ret = remove_clone(fs, coll, ghobj, cloneid, force);
ret = remove_clone(fs.get(), coll, ghobj, cloneid, force);
goto out;
}
cerr << "Unknown object command '" << objcmd << "'" << std::endl;
@ -4283,7 +4284,7 @@ int main(int argc, char **argv)
}
map_epoch = 0;
ret = PG::peek_map_epoch(fs, pgid, &map_epoch);
ret = PG::peek_map_epoch(fs.get(), pgid, &map_epoch);
if (ret < 0)
cerr << "peek_map_epoch reports error" << std::endl;
if (debug)
@ -4292,7 +4293,7 @@ int main(int argc, char **argv)
pg_info_t info(pgid);
PastIntervals past_intervals;
__u8 struct_ver;
ret = PG::read_info(fs, pgid, coll, info, past_intervals, struct_ver);
ret = PG::read_info(fs.get(), pgid, coll, info, past_intervals, struct_ver);
if (ret < 0) {
cerr << "read_info error " << cpp_strerror(ret) << std::endl;
goto out;
@ -4307,11 +4308,11 @@ int main(int argc, char **argv)
if (op == "export" || op == "export-remove") {
ceph_assert(superblock != nullptr);
ret = tool.do_export(fs, coll, pgid, info, map_epoch, struct_ver, *superblock, past_intervals);
ret = tool.do_export(fs.get(), coll, pgid, info, map_epoch, struct_ver, *superblock, past_intervals);
if (ret == 0) {
cerr << "Export successful" << std::endl;
if (op == "export-remove") {
ret = initiate_new_remove_pg(fs, pgid);
ret = initiate_new_remove_pg(fs.get(), pgid);
// Export succeeded, so pgid is there
ceph_assert(ret == 0);
cerr << "Remove successful" << std::endl;
@ -4326,7 +4327,7 @@ int main(int argc, char **argv)
} else if (op == "log") {
PGLog::IndexedLog log;
pg_missing_t missing;
ret = get_log(fs, struct_ver, pgid, info, log, missing);
ret = get_log(fs.get(), struct_ver, pgid, info, log, missing);
if (ret < 0)
goto out;
@ -4362,7 +4363,7 @@ int main(int argc, char **argv)
}
cout << "Marking complete succeeded" << std::endl;
} else if (op == "trim-pg-log") {
ret = do_trim_pg_log(fs, coll, info, pgid,
ret = do_trim_pg_log(fs.get(), coll, info, pgid,
map_epoch, past_intervals);
if (ret < 0) {
cerr << "Error trimming pg log: " << cpp_strerror(ret) << std::endl;