return desc;
}
-using AioCompRef = unique_ptr<AioCompletion>;
+using AioCompRef = std::unique_ptr<AioCompletion>;
class SampleDedupWorkerThread : public Thread
{
public:
struct chunk_t {
- string oid = "";
+ std::string oid = "";
size_t start = 0;
size_t size = 0;
- string fingerprint = "";
+ std::string fingerprint = "";
bufferlist data;
};
}
}
- bool contains(string& fp) {
+ bool contains(std::string& fp) {
std::shared_lock lock(fingerprint_lock);
return fp_map.contains(fp);
}
void try_dedup_and_accumulate_result(ObjectItem &object, snap_t snap = 0);
int do_chunk_dedup(chunk_t &chunk, snap_t snap);
bufferlist read_object(ObjectItem &object);
- std::vector<std::tuple<bufferlist, pair<uint64_t, uint64_t>>> do_cdc(
+ std::vector<std::tuple<bufferlist, std::pair<uint64_t, uint64_t>>> do_cdc(
ObjectItem &object,
bufferlist &data);
std::string generate_fingerprint(bufferlist chunk_data);
- AioCompRef do_async_evict(string oid);
+ AioCompRef do_async_evict(std::string oid);
IoCtx io_ctx;
IoCtx chunk_io_ctx;
op.list_snaps(&snap_set, &snap_ret);
io_ctx.operate(target.oid, &op, NULL);
- for (vector<librados::clone_info_t>::const_iterator r = snap_set.clones.begin();
+ for (std::vector<librados::clone_info_t>::const_iterator r = snap_set.clones.begin();
r != snap_set.clones.end();
++r) {
io_ctx.snap_set_read(r->cloneid);
}
}
- vector<AioCompRef> evict_completions(oid_for_evict.size());
+ std::vector<AioCompRef> evict_completions(oid_for_evict.size());
int i = 0;
for (auto &oid : oid_for_evict) {
if (snap) {
}
}
-AioCompRef SampleDedupWorkerThread::do_async_evict(string oid)
+AioCompRef SampleDedupWorkerThread::do_async_evict(std::string oid)
{
Rados rados;
ObjectReadOperation op_tier;
for (size_t i = 0 ; i < count ; i++) {
indexes[i] = i;
}
- default_random_engine generator;
+ std::default_random_engine generator;
shuffle(indexes.begin(), indexes.end(), generator);
size_t sampling_count = static_cast<double>(count) *
sample_dedup_global.sampling_ratio;
}
size_t duplicated_size = 0;
- list<chunk_t> redundant_chunks;
+ std::list<chunk_t> redundant_chunks;
for (auto &chunk : chunks) {
auto &chunk_data = std::get<0>(chunk);
std::string fingerprint = generate_fingerprint(chunk_data);
return whole_data;
}
-std::vector<std::tuple<bufferlist, pair<uint64_t, uint64_t>>> SampleDedupWorkerThread::do_cdc(
+std::vector<std::tuple<bufferlist, std::pair<uint64_t, uint64_t>>> SampleDedupWorkerThread::do_cdc(
ObjectItem &object,
bufferlist &data)
{
- std::vector<std::tuple<bufferlist, pair<uint64_t, uint64_t>>> ret;
+ std::vector<std::tuple<bufferlist, std::pair<uint64_t, uint64_t>>> ret;
- unique_ptr<CDC> cdc = CDC::create(chunk_algo, cbits(chunk_size) - 1);
- vector<pair<uint64_t, uint64_t>> chunks;
+ std::unique_ptr<CDC> cdc = CDC::create(chunk_algo, cbits(chunk_size) - 1);
+ std::vector<std::pair<uint64_t, uint64_t>> chunks;
cdc->calc_chunks(data, &chunks);
for (auto &p : chunks) {
bufferlist chunk;
std::string SampleDedupWorkerThread::generate_fingerprint(bufferlist chunk_data)
{
- string ret;
+ std::string ret;
switch (fp_type) {
case pg_pool_t::TYPE_FINGERPRINT_SHA1:
int run_crawling_daemon(const po::variables_map &opts)
{
- string base_pool_name = get_opts_pool_name(opts);
- string chunk_pool_name = get_opts_chunk_pool(opts);
+ std::string base_pool_name = get_opts_pool_name(opts);
+ std::string chunk_pool_name = get_opts_chunk_pool(opts);
unsigned max_thread = get_opts_max_thread(opts);
uint32_t report_period = get_opts_report_period(opts);
bool run_once = false; // for debug
if (opts.count("chunk-size")) {
chunk_size = opts["chunk-size"].as<int>();
} else {
- cout << "8192 is set as chunk size by default" << std::endl;
+ std::cout << "8192 is set as chunk size by default" << std::endl;
}
bool snap = false;
if (opts.count("snap")) {
if (opts.count("wakeup-period")) {
wakeup_period = opts["wakeup-period"].as<int>();
} else {
- cout << "100 second is set as wakeup period by default" << std::endl;
+ std::cout << "100 second is set as wakeup period by default" << std::endl;
}
const size_t fp_threshold = opts["fpstore-threshold"].as<size_t>();
std::string fp_algo = get_opts_fp_algo(opts);
- list<string> pool_names;
+ std::list<std::string> pool_names;
IoCtx io_ctx, chunk_io_ctx;
pool_names.push_back(base_pool_name);
ret = rados.ioctx_create(base_pool_name.c_str(), io_ctx);
sleep(wakeup_period);
- map<string, librados::pool_stat_t> stats;
+ std::map<std::string, librados::pool_stat_t> stats;
ret = rados.get_pool_stats(pool_names, stats);
if (ret < 0) {
derr << "error fetching pool stats: " << cpp_strerror(ret) << dendl;
{
auto args = argv_to_vec(argc, argv);
if (args.empty()) {
- cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
exit(1);
}
return 1;
}
if (opts.count("help") || opts.count("h")) {
- cout<< desc << std::endl;
+ std::cout<< desc << std::endl;
exit(0);
}
std::string err;
int r = forker.prefork(err);
if (r < 0) {
- cerr << err << std::endl;
+ std::cerr << err << std::endl;
return r;
}
if (forker.is_parent()) {
ceph::mutex lock = ceph::make_mutex("EstimateResult::lock");
// < key, <count, chunk_size> >
- map< string, pair <uint64_t, uint64_t> > chunk_statistics;
+ std::map< std::string, std::pair <uint64_t, uint64_t> > chunk_statistics;
uint64_t total_bytes = 0;
std::atomic<uint64_t> total_objects = {0};
chunk_size(1ull << chunk_size) {}
void add_chunk(bufferlist& chunk, const std::string& fp_algo) {
- string fp;
+ std::string fp;
if (fp_algo == "sha1") {
sha1_digest_t sha1_val = crypto::digest<crypto::SHA1>(chunk);
fp = sha1_val.to_str();
if (p != chunk_statistics.end()) {
p->second.first++;
if (p->second.second != chunk.length()) {
- cerr << "warning: hash collision on " << fp
+ std::cerr << "warning: hash collision on " << fp
<< ": was " << p->second.second
<< " now " << chunk.length() << std::endl;
}
} else {
- chunk_statistics[fp] = make_pair(1, chunk.length());
+ chunk_statistics[fp] = std::make_pair(1, chunk.length());
}
total_bytes += chunk.length();
}
}
};
-map<uint64_t, EstimateResult> dedup_estimates; // chunk size -> result
+std::map<uint64_t, EstimateResult> dedup_estimates; // chunk size -> result
ceph::mutex glock = ceph::make_mutex("glock");
po::options_description make_usage() {
std::string err;
*val = strict_iecstrtoll(i->second, &err);
if (err != "") {
- cerr << "Invalid value for " << i->first << ": " << err << std::endl;
+ std::cerr << "Invalid value for " << i->first << ": " << err << std::endl;
return -EINVAL;
} else {
return 0;
m_stop = true;
m_cond.notify_all();
}
- virtual void print_status(Formatter *f, ostream &out) {}
+ virtual void print_status(Formatter *f, std::ostream &out) {}
uint64_t get_examined_objects() { return examined_objects; }
uint64_t get_examined_bytes() { return examined_bytes; }
uint64_t get_total_bytes() { return total_bytes; }
class EstimateDedupRatio : public CrawlerThread
{
- string chunk_algo;
- string fp_algo;
+ std::string chunk_algo;
+ std::string fp_algo;
uint64_t chunk_size;
uint64_t max_seconds;
public:
EstimateDedupRatio(
IoCtx& io_ctx, int n, int m, ObjectCursor begin, ObjectCursor end,
- string chunk_algo, string fp_algo, uint64_t chunk_size, int32_t report_period,
+ std::string chunk_algo, std::string fp_algo, uint64_t chunk_size, int32_t report_period,
uint64_t num_objects, uint64_t max_read_size,
uint64_t max_seconds):
CrawlerThread(io_ctx, n, m, begin, end, report_period, num_objects,
}
void chunk_scrub_common();
int get_damaged_objects() { return damaged_objects; }
- void print_status(Formatter *f, ostream &out);
+ void print_status(Formatter *f, std::ostream &out);
};
-vector<std::unique_ptr<CrawlerThread>> estimate_threads;
+std::vector<std::unique_ptr<CrawlerThread>> estimate_threads;
static void print_dedup_estimate(std::ostream& out, std::string chunk_algo)
{
std::vector<ObjectItem> result;
int r = io_ctx.object_list(c, shard_end, 12, {}, &result, &c);
if (r < 0 ){
- cerr << "error object_list : " << cpp_strerror(r) << std::endl;
+ std::cerr << "error object_list : " << cpp_strerror(r) << std::endl;
return;
}
if (n == 0 && // first thread only
next_report != utime_t() && now > next_report) {
- cerr << (int)(now - start) << "s : read "
+ std::cerr << (int)(now - start) << "s : read "
<< dedup_estimates.begin()->second.total_bytes << " bytes so far..."
<< std::endl;
- print_dedup_estimate(cerr, chunk_algo);
+ print_dedup_estimate(std::cerr, chunk_algo);
next_report = now;
next_report += report_period;
}
// do the chunking
for (auto& i : dedup_estimates) {
- vector<pair<uint64_t, uint64_t>> chunks;
+ std::vector<std::pair<uint64_t, uint64_t>> chunks;
i.second.cdc->calc_chunks(bl, &chunks);
for (auto& p : chunks) {
bufferlist chunk;
chunk.substr_of(bl, p.first, p.second);
i.second.add_chunk(chunk, fp_algo);
if (debug) {
- cout << " " << oid << " " << p.first << "~" << p.second << std::endl;
+ std::cout << " " << oid << " " << p.first << "~" << p.second << std::endl;
}
}
++i.second.total_objects;
ret = rados.init_with_context(g_ceph_context);
if (ret < 0) {
- cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
return;
}
ret = rados.connect();
if (ret) {
- cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
return;
}
std::vector<ObjectItem> result;
int r = chunk_io_ctx.object_list(c, shard_end, 12, {}, &result, &c);
if (r < 0 ){
- cerr << "error object_list : " << cpp_strerror(r) << std::endl;
+ std::cerr << "error object_list : " << cpp_strerror(r) << std::endl;
return;
}
std::unique_lock l{m_lock};
if (m_stop) {
Formatter *formatter = Formatter::create("json-pretty");
- print_status(formatter, cout);
+ print_status(formatter, std::cout);
delete formatter;
return;
}
utime_t now = ceph_clock_now();
if (n == 0 && // first thread only
next_report != utime_t() && now > next_report) {
- cerr << (int)(now - start) << "s, interim findings is : "
+ std::cerr << (int)(now - start) << "s, interim findings is : "
<< std::endl;
print_chunk_scrub();
next_report = now;
auto oid = i.oid;
if (debug) {
- cout << oid << std::endl;
+ std::cout << oid << std::endl;
}
chunk_refs_t refs;
{
// check all objects
chunk_refs_by_object_t *byo =
static_cast<chunk_refs_by_object_t*>(refs.r.get());
- set<hobject_t> real_refs;
+ std::set<hobject_t> real_refs;
uint64_t pool_missing = 0;
uint64_t object_missing = 0;
IoCtx target_io_ctx;
ret = rados.ioctx_create2(pp.pool, target_io_ctx);
if (ret < 0) {
- cerr << oid << " ref " << pp
+ std::cerr << oid << " ref " << pp
<< ": referencing pool does not exist" << std::endl;
++pool_missing;
continue;
ret = cls_cas_references_chunk(target_io_ctx, pp.oid.name, oid);
if (ret == -ENOENT) {
- cerr << oid << " ref " << pp
+ std::cerr << oid << " ref " << pp
<< ": referencing object missing" << std::endl;
++object_missing;
} else if (ret == -ENOLINK) {
- cerr << oid << " ref " << pp
+ std::cerr << oid << " ref " << pp
<< ": referencing object does not reference chunk"
<< std::endl;
++does_not_ref;
}
}
}
- cout << "--done--" << std::endl;
+ std::cout << "--done--" << std::endl;
}
-void ChunkScrub::print_status(Formatter *f, ostream &out)
+void ChunkScrub::print_status(Formatter *f, std::ostream &out)
{
if (f) {
f->open_array_section("chunk_scrub");
f->dump_string("damaged objects", stringify(damaged_objects));
f->close_section();
f->flush(out);
- cout << std::endl;
+ std::cout << std::endl;
}
}
Rados rados;
IoCtx io_ctx;
std::string chunk_algo = "fastcdc";
- string fp_algo = "sha1";
- string pool_name;
+ std::string fp_algo = "sha1";
+ std::string pool_name;
uint64_t chunk_size = 8192;
uint64_t min_chunk_size = 8192;
uint64_t max_chunk_size = 4*1024*1024;
ObjectCursor begin;
ObjectCursor end;
librados::pool_stat_t s;
- list<string> pool_names;
- map<string, librados::pool_stat_t> stats;
+ std::list<std::string> pool_names;
+ std::map<std::string, librados::pool_stat_t> stats;
pool_name = get_opts_pool_name(opts);
if (opts.count("chunk-algorithm")) {
- chunk_algo = opts["chunk-algorithm"].as<string>();
+ chunk_algo = opts["chunk-algorithm"].as<std::string>();
if (!CDC::create(chunk_algo, 12)) {
- cerr << "unrecognized chunk-algorithm " << chunk_algo << std::endl;
+ std::cerr << "unrecognized chunk-algorithm " << chunk_algo << std::endl;
exit(1);
}
} else {
- cerr << "must specify chunk-algorithm" << std::endl;
+ std::cerr << "must specify chunk-algorithm" << std::endl;
exit(1);
}
fp_algo = get_opts_fp_algo(opts);
if (opts.count("chunk-size")) {
chunk_size = opts["chunk-size"].as<int>();
} else {
- cout << "8192 is set as chunk size by default" << std::endl;
+ std::cout << "8192 is set as chunk size by default" << std::endl;
}
if (opts.count("min-chunk-size")) {
chunk_size = opts["min-chunk-size"].as<int>();
} else {
- cout << "8192 is set as min chunk size by default" << std::endl;
+ std::cout << "8192 is set as min chunk size by default" << std::endl;
}
if (opts.count("max-chunk-size")) {
chunk_size = opts["max-chunk-size"].as<int>();
} else {
- cout << "4MB is set as max chunk size by default" << std::endl;
+ std::cout << "4MB is set as max chunk size by default" << std::endl;
}
if (opts.count("max-seconds")) {
max_seconds = opts["max-seconds"].as<int>();
} else {
- cout << "max seconds is not set" << std::endl;
+ std::cout << "max seconds is not set" << std::endl;
}
if (opts.count("max-read-size")) {
max_read_size = opts["max-read-size"].as<int>();
} else {
- cout << default_op_size << " is set as max-read-size by default" << std::endl;
+ std::cout << default_op_size << " is set as max-read-size by default" << std::endl;
}
if (opts.count("debug")) {
debug = true;
ret = rados.init_with_context(g_ceph_context);
if (ret < 0) {
- cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
goto out;
}
ret = rados.connect();
if (ret) {
- cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
ret = -1;
goto out;
}
if (pool_name.empty()) {
- cerr << "--create-pool requested but pool_name was not specified!" << std::endl;
+ std::cerr << "--create-pool requested but pool_name was not specified!" << std::endl;
exit(1);
}
ret = rados.ioctx_create(pool_name.c_str(), io_ctx);
if (ret < 0) {
- cerr << "error opening pool "
+ std::cerr << "error opening pool "
<< pool_name << ": "
<< cpp_strerror(ret) << std::endl;
goto out;
pool_names.push_back(pool_name);
ret = rados.get_pool_stats(pool_names, stats);
if (ret < 0) {
- cerr << "error fetching pool stats: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "error fetching pool stats: " << cpp_strerror(ret) << std::endl;
glock.unlock();
return ret;
}
if (stats.find(pool_name) == stats.end()) {
- cerr << "stats can not find pool name: " << pool_name << std::endl;
+ std::cerr << "stats can not find pool name: " << pool_name << std::endl;
glock.unlock();
return ret;
}
p->join();
}
- print_dedup_estimate(cout, chunk_algo);
+ print_dedup_estimate(std::cout, chunk_algo);
out:
return (ret < 0) ? 1 : 0;
damaged_objects += ptr->get_damaged_objects();
}
- cout << " Total object : " << total_objects << std::endl;
- cout << " Examined object : " << examined_objects << std::endl;
- cout << " Damaged object : " << damaged_objects << std::endl;
+ std::cout << " Total object : " << total_objects << std::endl;
+ std::cout << " Examined object : " << examined_objects << std::endl;
+ std::cout << " Damaged object : " << damaged_objects << std::endl;
}
int chunk_scrub_common(const po::variables_map &opts)
Rados rados;
IoCtx io_ctx, chunk_io_ctx;
std::string object_name, target_object_name;
- string chunk_pool_name, op_name;
+ std::string chunk_pool_name, op_name;
int ret;
unsigned max_thread = get_opts_max_thread(opts);
std::map<std::string, std::string>::const_iterator i;
ObjectCursor begin;
ObjectCursor end;
librados::pool_stat_t s;
- list<string> pool_names;
- map<string, librados::pool_stat_t> stats;
+ std::list<std::string> pool_names;
+ std::map<std::string, librados::pool_stat_t> stats;
op_name = get_opts_op_name(opts);
chunk_pool_name = get_opts_chunk_pool(opts);
ret = rados.init_with_context(g_ceph_context);
if (ret < 0) {
- cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
goto out;
}
ret = rados.connect();
if (ret) {
- cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
ret = -1;
goto out;
}
ret = rados.ioctx_create(chunk_pool_name.c_str(), chunk_io_ctx);
if (ret < 0) {
- cerr << "error opening pool "
+ std::cerr << "error opening pool "
<< chunk_pool_name << ": "
<< cpp_strerror(ret) << std::endl;
goto out;
if (op_name == "chunk-get-ref" ||
op_name == "chunk-put-ref" ||
op_name == "chunk-repair") {
- string target_object_name;
+ std::string target_object_name;
uint64_t pool_id;
object_name = get_opts_object_name(opts);
if (opts.count("target-ref")) {
- target_object_name = opts["target-ref"].as<string>();
+ target_object_name = opts["target-ref"].as<std::string>();
} else {
- cerr << "must specify target ref" << std::endl;
+ std::cerr << "must specify target ref" << std::endl;
exit(1);
}
if (opts.count("target-ref-pool-id")) {
pool_id = opts["target-ref-pool-id"].as<uint64_t>();
} else {
- cerr << "must specify target-ref-pool-id" << std::endl;
+ std::cerr << "must specify target-ref-pool-id" << std::endl;
exit(1);
}
hobject_t oid(sobject_t(target_object_name, CEPH_NOSNAP), "", hash, pool_id, "");
auto run_op = [] (ObjectWriteOperation& op, hobject_t& oid,
- string& object_name, IoCtx& chunk_io_ctx) -> int {
+ std::string& object_name, IoCtx& chunk_io_ctx) -> int {
int ret = chunk_io_ctx.operate(object_name, &op);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
}
return ret;
};
} else if (op_name == "chunk-repair") {
ret = rados.ioctx_create2(pool_id, io_ctx);
if (ret < 0) {
- cerr << oid << " ref " << pool_id
+ std::cerr << oid << " ref " << pool_id
<< ": referencing pool does not exist" << std::endl;
return ret;
}
auto p = t.cbegin();
decode(refs, p);
if (refs.get_type() != chunk_refs_t::TYPE_BY_OBJECT) {
- cerr << " does not supported chunk type " << std::endl;
+ std::cerr << " does not supported chunk type " << std::endl;
return -1;
}
chunk_ref =
static_cast<chunk_refs_by_object_t*>(refs.r.get())->by_object.count(oid);
if (chunk_ref < 0) {
- cerr << object_name << " has no reference of " << target_object_name
+ std::cerr << object_name << " has no reference of " << target_object_name
<< std::endl;
return chunk_ref;
}
- cout << object_name << " has " << chunk_ref << " references for "
+ std::cout << object_name << " has " << chunk_ref << " references for "
<< target_object_name << std::endl;
// read object on base pool to know the number of chunk object's references
return base_ref;
}
}
- cout << target_object_name << " has " << base_ref << " references for "
+ std::cout << target_object_name << " has " << base_ref << " references for "
<< object_name << std::endl;
if (chunk_ref != base_ref) {
if (base_ref > chunk_ref) {
- cerr << "error : " << target_object_name << "'s ref. < " << object_name
+ std::cerr << "error : " << target_object_name << "'s ref. < " << object_name
<< "' ref. " << std::endl;
return -EINVAL;
}
- cout << " fix dangling reference from " << chunk_ref << " to " << base_ref
+ std::cout << " fix dangling reference from " << chunk_ref << " to " << base_ref
<< std::endl;
while (base_ref != chunk_ref) {
ObjectWriteOperation op;
decode(refs, p);
auto f = Formatter::create("json-pretty");
f->dump_object("refs", refs);
- f->flush(cout);
+ f->flush(std::cout);
return 0;
}
pool_names.push_back(chunk_pool_name);
ret = rados.get_pool_stats(pool_names, stats);
if (ret < 0) {
- cerr << "error fetching pool stats: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "error fetching pool stats: " << cpp_strerror(ret) << std::endl;
glock.unlock();
return ret;
}
if (stats.find(chunk_pool_name) == stats.end()) {
- cerr << "stats can not find pool name: " << chunk_pool_name << std::endl;
+ std::cerr << "stats can not find pool name: " << chunk_pool_name << std::endl;
glock.unlock();
return ret;
}
glock.unlock();
for (auto &p : estimate_threads) {
- cout << "join " << std::endl;
+ std::cout << "join " << std::endl;
p->join();
- cout << "joined " << std::endl;
+ std::cout << "joined " << std::endl;
}
print_chunk_scrub();
ret = rados.init_with_context(g_ceph_context);
if (ret < 0) {
- cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't initialize rados: " << cpp_strerror(ret) << std::endl;
goto out;
}
ret = rados.connect();
if (ret) {
- cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
+ std::cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl;
ret = -1;
goto out;
}
ret = rados.ioctx_create(pool_name.c_str(), io_ctx);
if (ret < 0) {
- cerr << "error opening pool "
+ std::cerr << "error opening pool "
<< chunk_pool_name << ": "
<< cpp_strerror(ret) << std::endl;
goto out;
}
ret = rados.ioctx_create(chunk_pool_name.c_str(), chunk_io_ctx);
if (ret < 0) {
- cerr << "error opening pool "
+ std::cerr << "error opening pool "
<< chunk_pool_name << ": "
<< cpp_strerror(ret) << std::endl;
goto out;
if (op_name == "chunk-dedup") {
uint64_t offset, length;
- string chunk_object;
+ std::string chunk_object;
if (opts.count("source-off")) {
offset = opts["source-off"].as<uint64_t>();
} else {
- cerr << "must specify --source-off" << std::endl;
+ std::cerr << "must specify --source-off" << std::endl;
exit(1);
}
if (opts.count("source-length")) {
length = opts["source-length"].as<uint64_t>();
} else {
- cerr << "must specify --source-length" << std::endl;
+ std::cerr << "must specify --source-length" << std::endl;
exit(1);
}
// 1. make a copy from manifest object to chunk object
bufferlist bl;
ret = io_ctx.read(object_name, bl, length, offset);
if (ret < 0) {
- cerr << " reading object in base pool fails : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " reading object in base pool fails : " << cpp_strerror(ret) << std::endl;
goto out;
}
- chunk_object = [&fp_algo, &bl]() -> string {
+ chunk_object = [&fp_algo, &bl]() -> std::string {
if (fp_algo == "sha1") {
return ceph::crypto::digest<ceph::crypto::SHA1>(bl).to_str();
} else if (fp_algo == "sha256") {
}();
ret = chunk_io_ctx.write(chunk_object, bl, length, offset);
if (ret < 0) {
- cerr << " writing object in chunk pool fails : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " writing object in chunk pool fails : " << cpp_strerror(ret) << std::endl;
goto out;
}
// 2. call set_chunk
CEPH_OSD_OP_FLAG_WITH_REFERENCE);
ret = io_ctx.operate(object_name, &op, NULL);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
goto out;
}
} else if (op_name == "object-dedup") {
if (opts.count("dedup-cdc-chunk-size")) {
chunk_size = opts["dedup-cdc-chunk-size"].as<unsigned int>();
} else {
- cerr << "must specify --dedup-cdc-chunk-size" << std::endl;
+ std::cerr << "must specify --dedup-cdc-chunk-size" << std::endl;
exit(1);
}
if (opts.count("snap")) {
make_pool_str(pool_name, "fingerprint_algorithm", fp_algo),
inbl, NULL, NULL);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
ret = rados.mon_command(
make_pool_str(pool_name, "dedup_tier", chunk_pool_name),
inbl, NULL, NULL);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
ret = rados.mon_command(
make_pool_str(pool_name, "dedup_chunk_algorithm", "fastcdc"),
inbl, NULL, NULL);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
ret = rados.mon_command(
make_pool_str(pool_name, "dedup_cdc_chunk_size", chunk_size),
inbl, NULL, NULL);
if (ret < 0) {
- cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " operate fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
auto create_new_deduped_object =
- [&io_ctx](string object_name) -> int {
+ [&io_ctx](std::string object_name) -> int {
// tier-flush to perform deduplication
ObjectReadOperation flush_op;
flush_op.tier_flush();
int ret = io_ctx.operate(object_name, &flush_op, NULL);
if (ret < 0) {
- cerr << " tier_flush fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " tier_flush fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
// tier-evict
evict_op.tier_evict();
ret = io_ctx.operate(object_name, &evict_op, NULL);
if (ret < 0) {
- cerr << " tier_evict fail : " << cpp_strerror(ret) << std::endl;
+ std::cerr << " tier_evict fail : " << cpp_strerror(ret) << std::endl;
return ret;
}
return ret;
op.list_snaps(&snap_set, &snap_ret);
io_ctx.operate(object_name, &op, NULL);
- for (vector<librados::clone_info_t>::const_iterator r = snap_set.clones.begin();
+ for (std::vector<librados::clone_info_t>::const_iterator r = snap_set.clones.begin();
r != snap_set.clones.end();
++r) {
io_ctx.snap_set_read(r->cloneid);
{
auto args = argv_to_vec(argc, argv);
if (args.empty()) {
- cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
exit(1);
}
return 1;
}
if (opts.count("help") || opts.count("h")) {
- cout<< desc << std::endl;
+ std::cout<< desc << std::endl;
exit(0);
}
std::string err;
int r = forker.prefork(err);
if (r < 0) {
- cerr << err << std::endl;
+ std::cerr << err << std::endl;
return r;
}
if (forker.is_parent()) {
register_async_signal_handler_oneshot(SIGINT, handle_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_signal);
- string op_name = get_opts_op_name(opts);
+ std::string op_name = get_opts_op_name(opts);
int ret = 0;
if (op_name == "estimate") {
ret = estimate_dedup_ratio(opts);
*/
ret = make_dedup_object(opts);
} else {
- cerr << "unrecognized op " << op_name << std::endl;
+ std::cerr << "unrecognized op " << op_name << std::endl;
exit(1);
}