bool mgr=false) const
{
if (mgr) {
- auto m = make_message<MMgrCommand>(fsid);
+ auto m = ceph::make_message<MMgrCommand>(fsid);
m->cmd = cmd;
m->set_data(inbl);
m->set_tid(tid);
return m;
} else {
- auto m = make_message<MCommand>(fsid);
+ auto m = ceph::make_message<MCommand>(fsid);
m->cmd = cmd;
m->set_data(inbl);
m->set_tid(tid);
#include "include/encoding.h"
-void DecayCounter::encode(bufferlist& bl) const
+void DecayCounter::encode(ceph::buffer::list& bl) const
{
decay();
ENCODE_START(5, 4, bl);
ENCODE_FINISH(bl);
}
-void DecayCounter::decode(bufferlist::const_iterator &p)
+void DecayCounter::decode(ceph::buffer::list::const_iterator &p)
{
DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, p);
if (struct_v < 2) {
DECODE_FINISH(p);
}
-void DecayCounter::dump(Formatter *f) const
+void DecayCounter::dump(ceph::Formatter *f) const
{
decay();
f->dump_float("value", val);
DecayCounter() : DecayCounter(DecayRate()) {}
explicit DecayCounter(const DecayRate &rate) : last_decay(clock::now()), rate(rate) {}
- void encode(bufferlist& bl) const;
- void decode(bufferlist::const_iterator& p);
- void dump(Formatter *f) const;
+ void encode(ceph::buffer::list& bl) const;
+ void decode(ceph::buffer::list::const_iterator& p);
+ void dump(ceph::Formatter *f) const;
static void generate_test_instances(std::list<DecayCounter*>& ls);
/**
DecayRate rate;
};
-inline void encode(const DecayCounter &c, bufferlist &bl) {
+inline void encode(const DecayCounter &c, ceph::buffer::list &bl) {
c.encode(bl);
}
-inline void decode(DecayCounter &c, bufferlist::const_iterator &p) {
+inline void decode(DecayCounter &c, ceph::buffer::list::const_iterator &p) {
c.decode(p);
}
#include "log/Entry.h"
#include "log/SubsystemMap.h"
-namespace ceph {
-namespace logging {
+using std::cerr;
+
+namespace ceph::logging {
Graylog::Graylog(const SubsystemMap * const s, const std::string &logger)
: m_subs(s),
}
}
-} // ceph::logging::
-} // ceph::
+} // name ceph::logging
#undef dout_prefix
#define dout_prefix *_dout << "heartbeat_map "
+using std::chrono::duration_cast;
+using std::chrono::seconds;
+using std::string;
+
namespace ceph {
HeartbeatMap::HeartbeatMap(CephContext *cct)
{
ldout(m_cct, 20) << "reset_timeout '" << h->name << "' grace " << grace
<< " suicide " << suicide_grace << dendl;
- auto now = chrono::duration_cast<chrono::seconds>(
- ceph::coarse_mono_clock::now().time_since_epoch()).count();
+ auto now = duration_cast<seconds>(coarse_mono_clock::now()
+ .time_since_epoch()).count();
_check(h, "reset_timeout", now);
h->timeout = now + grace;
void HeartbeatMap::clear_timeout(heartbeat_handle_d *h)
{
ldout(m_cct, 20) << "clear_timeout '" << h->name << "'" << dendl;
- auto now = chrono::duration_cast<std::chrono::seconds>(
- ceph::coarse_mono_clock::now().time_since_epoch()).count();
+ auto now = duration_cast<seconds>(coarse_mono_clock::now()
+ .time_since_epoch()).count();
_check(h, "clear_timeout", now);
h->timeout = 0;
h->suicide_timeout = 0;
healthy = false;
}
- for (list<heartbeat_handle_d*>::iterator p = m_workers.begin();
+ for (auto p = m_workers.begin();
p != m_workers.end();
++p) {
heartbeat_handle_d *h = *p;
- auto epoch = chrono::duration_cast<chrono::seconds>(now.time_since_epoch()).count();
+ auto epoch = duration_cast<seconds>(now.time_since_epoch()).count();
if (!_check(h, "is_healthy", epoch)) {
healthy = false;
unhealthy++;
#define dout_subsys ceph_subsys_monc
+using std::map;
+using std::ostream;
+using std::ostringstream;
+using std::string;
+
int parse_log_client_options(CephContext *cct,
map<string,string> &log_to_monitors,
map<string,string> &log_to_syslog,
version_t last = m->last;
- deque<LogEntry>::iterator q = log_queue.begin();
+ auto q = log_queue.begin();
while (q != log_queue.end()) {
const LogEntry &entry(*q);
if (entry.seq > last)
}
return true;
}
-
#include "Formatter.h"
#include "include/stringify.h"
+using std::list;
+using std::map;
+using std::make_pair;
+using std::pair;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::decode;
+using ceph::encode;
+using ceph::Formatter;
+
// ----
// LogEntryKey
o.push_back(new LogSummary);
// more!
}
-
void OutputDataSocket::handle_connection(int fd)
{
- bufferlist bl;
+ ceph::buffer::list bl;
m_lock.lock();
init_connection(bl);
int OutputDataSocket::dump_data(int fd)
{
m_lock.lock();
- vector<buffer::list> l = std::move(data);
+ auto l = std::move(data);
data.clear();
data_size = 0;
m_lock.unlock();
for (auto iter = l.begin(); iter != l.end(); ++iter) {
- bufferlist& bl = *iter;
+ ceph::buffer::list& bl = *iter;
int ret = safe_write(fd, bl.c_str(), bl.length());
if (ret >= 0) {
ret = safe_write(fd, delim.c_str(), delim.length());
if (ret < 0) {
std::scoped_lock lock(m_lock);
for (; iter != l.end(); ++iter) {
- bufferlist& bl = *iter;
+ ceph::buffer::list& bl = *iter;
data.push_back(bl);
data_size += bl.length();
}
m_path.clear();
}
-void OutputDataSocket::append_output(bufferlist& bl)
+void OutputDataSocket::append_output(ceph::buffer::list& bl)
{
std::lock_guard l(m_lock);
bool init(const std::string &path);
- void append_output(bufferlist& bl);
+ void append_output(ceph::buffer::list& bl);
protected:
- virtual void init_connection(bufferlist& bl) {}
+ virtual void init_connection(ceph::buffer::list& bl) {}
void shutdown();
std::string create_shutdown_pipe(int *pipe_rd, int *pipe_wr);
uint64_t data_size;
uint32_t skipped;
- std::vector<buffer::list> data;
+ std::vector<ceph::buffer::list> data;
ceph::mutex m_lock = ceph::make_mutex("OutputDataSocket::m_lock");
ceph::condition_variable cond;
- buffer::list delim;
+ ceph::buffer::list delim;
};
#endif
#define dout_subsys ceph_subsys_context
+using std::map;
+using std::string;
+
+namespace ceph {
+
PluginRegistry::PluginRegistry(CephContext *cct) :
cct(cct),
loading(false),
<< " loaded and registered" << dendl;
return 0;
}
+}
/*
int ErasureCodePluginRegistry::preload(const std::string &plugins,
#include "common/Readahead.h"
#include "common/Cond.h"
+using std::vector;
+
Readahead::Readahead()
: m_trigger_requests(10),
m_readahead_min_bytes(0),
m_lock.unlock();
return extent_t(0, 0);
}
- pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
+ std::pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
m_lock.unlock();
return extent;
}
#include "common/Formatter.h"
using namespace std;
+using ceph::bufferlist;
void SloppyCRCMap::write(uint64_t offset, uint64_t len, const bufferlist& bl,
std::ostream *out)
block_size = b;
//zero_crc = ceph_crc32c(0xffffffff, NULL, block_size);
if (b) {
- bufferlist bl;
+ ceph::buffer::list bl;
bl.append_zero(block_size);
zero_crc = bl.crc32c(crc_iv);
} else {
}
/// update based on a write
- void write(uint64_t offset, uint64_t len, const bufferlist& bl,
+ void write(uint64_t offset, uint64_t len, const ceph::buffer::list& bl,
std::ostream *out = NULL);
/// update based on a truncate
* @param err option ostream to describe errors in detail
* @returns error count, 0 for success
*/
- int read(uint64_t offset, uint64_t len, const bufferlist& bl, std::ostream *err);
+ int read(uint64_t offset, uint64_t len, const ceph::buffer::list& bl, std::ostream *err);
- void encode(bufferlist& bl) const;
- void decode(bufferlist::const_iterator& bl);
+ void encode(ceph::buffer::list& bl) const;
+ void decode(ceph::buffer::list::const_iterator& bl);
void dump(ceph::Formatter *f) const;
static void generate_test_instances(std::list<SloppyCRCMap*>& ls);
};
#undef dout_prefix
#define dout_prefix *_dout << "throttle(" << name << " " << (void*)this << ") "
+using std::list;
+using std::ostream;
+using std::string;
+
using ceph::mono_clock;
using ceph::mono_time;
+using ceph::timespan;
enum {
l_throttle_first = 532430,
#undef dout_prefix
#define dout_prefix *_dout << "timer(" << this << ")."
+using std::pair;
+using ceph::operator <<;
class SafeTimerThread : public Thread {
SafeTimer *parent;
#undef dout_prefix
#define dout_prefix _prefix(_dout)
+using std::list;
+using std::make_pair;
+using std::ostream;
+using std::pair;
+using std::set;
+using std::string;
+using std::stringstream;
+
+using ceph::Formatter;
+
static ostream& _prefix(std::ostream* _dout)
{
return *_dout << "-- op tracker -- ";
#undef dout_prefix
#define dout_prefix *_dout << name << " "
-
-ThreadPool::ThreadPool(CephContext *cct_, string nm, string tn, int n, const char *option)
+ThreadPool::ThreadPool(CephContext *cct_, std::string nm, std::string tn, int n, const char *option)
: cct(cct_), name(std::move(nm)), thread_name(std::move(tn)),
lockname(name + "::lock"),
_lock(ceph::make_mutex(lockname)), // this should be safe due to declaration order
{
std::unique_lock ul(_lock);
ldout(cct,10) << "worker start" << dendl;
-
+
std::stringstream ss;
ss << name << " thread " << (void *)pthread_self();
- heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
+ auto hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
while (!_stop) {
_cond.notify_all();
join_old_threads();
_lock.unlock();
- for (set<WorkThread*>::iterator p = _threads.begin();
- p != _threads.end();
- ++p) {
+ for (auto p = _threads.begin(); p != _threads.end(); ++p) {
(*p)->join();
delete *p;
}
_draining--;
}
-ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn,
- uint32_t pnum_threads):
+ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, std::string nm, std::string tn,
+ uint32_t pnum_threads):
cct(pcct_),
name(std::move(nm)),
thread_name(std::move(tn)),
std::stringstream ss;
ss << name << " thread " << (void *)pthread_self();
- heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
+ auto hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
while (!stop_threads) {
if (pause_threads) {
stop_threads = true;
ceph_assert(wq != NULL);
wq->return_waiting_threads();
- for (vector<WorkThreadSharded*>::iterator p = threads_shardedpool.begin();
+ for (auto p = threads_shardedpool.begin();
p != threads_shardedpool.end();
++p) {
(*p)->join();
std::cmatch m;
if (std::regex_match(url, m, expr)) {
- string host(m[2].first, m[2].second);
- string port(m[3].first, m[3].second);
+ std::string host(m[2].first, m[2].second);
+ std::string port(m[3].first, m[3].second);
addrinfo hints;
// FIPS zeroization audit 20191115: this memset is fine.
memset(&hints, 0, sizeof(hints));
return 1;
}
-
#undef dout_prefix
#define dout_prefix *_dout << "asok(" << (void*)m_cct << ") "
+using namespace std::literals;
using std::ostringstream;
+using std::string;
+using std::stringstream;
+
using namespace TOPNSPC::common;
+using ceph::bufferlist;
+using ceph::cref_t;
+using ceph::Formatter;
+
+
/*
* UNIX domain sockets created by an application persist even after that
* application closes, unless they're explicitly unlinked. This is because the
empty);
}
- Formatter *f = Formatter::create(format, "json-pretty", "json-pretty");
+ auto f = Formatter::create(format, "json-pretty", "json-pretty");
std::unique_lock l(lock);
decltype(hooks)::iterator p;
// do what you'd expect. GCC 7 does not.
(void)command;
ostringstream secname;
- secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
+ secname << "cmd" << std::setfill('0') << std::setw(3) << cmdnum;
dump_cmd_and_help_to_json(f,
CEPH_FEATURES_ALL,
secname.str().c_str(),
#include "common/ref.h"
#include "common/cmdparse.h"
-class AdminSocket;
class MCommand;
class MMonCommand;
-using namespace std::literals;
-
-inline constexpr auto CEPH_ADMIN_SOCK_VERSION = "2"sv;
+inline constexpr auto CEPH_ADMIN_SOCK_VERSION = std::string_view("2");
class AdminSocketHook {
public:
virtual int call(
std::string_view command,
const cmdmap_t& cmdmap,
- Formatter *f,
+ ceph::Formatter *f,
std::ostream& errss,
ceph::buffer::list& out) = 0;
virtual void call_async(
std::string_view command,
const cmdmap_t& cmdmap,
- Formatter *f,
- const bufferlist& inbl,
- std::function<void(int,const std::string&,bufferlist&)> on_finish) {
+ ceph::Formatter *f,
+ const ceph::buffer::list& inbl,
+ std::function<void(int,const std::string&,ceph::buffer::list&)> on_finish) {
// by default, call the synchronous handler and then finish
- bufferlist out;
+ ceph::buffer::list out;
std::ostringstream errss;
int r = call(command, cmdmap, f, errss, out);
on_finish(r, errss.str(), out);
/// execute (async)
void execute_command(
const std::vector<std::string>& cmd,
- const bufferlist& inbl,
- std::function<void(int,const std::string&,bufferlist&)> on_fin);
+ const ceph::buffer::list& inbl,
+ std::function<void(int,const std::string&,ceph::buffer::list&)> on_fin);
/// execute (blocking)
int execute_command(
const std::vector<std::string>& cmd,
- const bufferlist& inbl,
+ const ceph::buffer::list& inbl,
std::ostream& errss,
- bufferlist *outbl);
+ ceph::buffer::list *outbl);
- void queue_tell_command(cref_t<MCommand> m);
- void queue_tell_command(cref_t<MMonCommand> m); // for compat
+ void queue_tell_command(ceph::cref_t<MCommand> m);
+ void queue_tell_command(ceph::cref_t<MMonCommand> m); // for compat
private:
std::unique_ptr<AdminSocketHook> getdescs_hook;
std::mutex tell_lock;
- std::list<cref_t<MCommand>> tell_queue;
- std::list<cref_t<MMonCommand>> tell_legacy_queue;
+ std::list<ceph::cref_t<MCommand>> tell_queue;
+ std::list<ceph::cref_t<MMonCommand>> tell_legacy_queue;
struct hook_info {
AdminSocketHook* hook;
#include "include/compat.h"
#include "common/debug.h"
+using std::ostringstream;
+
namespace ceph {
static CephContext *g_assert_context = NULL;
}
[[gnu::cold]] void __ceph_abort(const char *file, int line,
- const char *func, const string& msg)
+ const char *func, const std::string& msg)
{
ostringstream tss;
tss << ceph_clock_now();
#include "json_spirit/json_spirit_reader.h"
+
int get_device_by_path(const char *path, char* partition, char* device,
size_t max)
{
#endif
+using namespace std::literals;
+
+using std::string;
+
+using ceph::bufferlist;
+
BlkDev::BlkDev(int f)
: fd(f)
MEMPOOL_DEFINE_FACTORY(unsigned char, byte, bloom_filter);
+using ceph::bufferlist;
+using ceph::bufferptr;
+using ceph::Formatter;
+
void bloom_filter::encode(bufferlist& bl) const
{
ENCODE_START(2, 2, bl);
#include "include/spinlock.h"
#include "include/scope_guard.h"
+using std::cerr;
+using std::make_pair;
+using std::pair;
+using std::string;
+
using namespace ceph;
#define CEPH_BUFFER_ALLOC_UNIT 4096u
void string_to_vec(std::vector<std::string>& args, std::string argstr)
{
- istringstream iss(argstr);
+ std::istringstream iss(argstr);
while(iss) {
- string sub;
+ std::string sub;
iss >> sub;
if (sub == "") break;
args.push_back(sub);
}
static std::mutex g_str_vec_lock;
-static vector<string> g_str_vec;
+static std::vector<std::string> g_str_vec;
void clear_g_str_vec()
{
{
*argv = (const char**)malloc(sizeof(char*) * (args.size() + 1));
if (!*argv)
- throw bad_alloc();
+ throw std::bad_alloc();
*argc = 1;
(*argv)[0] = argv0;
}
-bool parse_ip_port_vec(const char *s, vector<entity_addrvec_t>& vec, int type)
+bool parse_ip_port_vec(const char *s, std::vector<entity_addrvec_t>& vec, int type)
{
// first split by [ ;], which are not valid for an addrvec
- list<string> items;
+ std::list<std::string> items;
get_str_list(s, " ;", items);
for (auto& i : items) {
int r;
va_list ap;
va_start(ap, ret);
- r = va_ceph_argparse_witharg(args, i, ret, cerr, ap);
+ r = va_ceph_argparse_witharg(args, i, ret, std::cerr, ap);
va_end(ap);
if (r < 0)
_exit(1);
CephInitParameters iparams(module_type);
std::string val;
- vector<const char *> orig_args = args;
+ auto orig_args = args;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (strcmp(*i, "--") == 0) {
break;
}
else if (ceph_argparse_flag(args, i, "--version", "-v", (char*)NULL)) {
- cout << pretty_version_to_str() << std::endl;
+ std::cout << pretty_version_to_str() << std::endl;
_exit(0);
}
else if (ceph_argparse_witharg(args, i, &val, "--conf", "-c", (char*)NULL)) {
}
else if (ceph_argparse_witharg(args, i, &val, "--name", "-n", (char*)NULL)) {
if (!iparams.name.from_str(val)) {
- cerr << "error parsing '" << val << "': expected string of the form TYPE.ID, "
- << "valid types are: " << EntityName::get_valid_types_as_str()
- << std::endl;
+ std::cerr << "error parsing '" << val << "': expected string of the form TYPE.ID, "
+ << "valid types are: " << EntityName::get_valid_types_as_str()
+ << std::endl;
_exit(1);
}
}
else if (ceph_argparse_flag(args, i, "--show_args", (char*)NULL)) {
- cout << "args: ";
+ std::cout << "args: ";
for (std::vector<const char *>::iterator ci = orig_args.begin(); ci != orig_args.end(); ++ci) {
- if (ci != orig_args.begin())
- cout << " ";
- cout << *ci;
+ if (ci != orig_args.begin())
+ std::cout << " ";
+ std::cout << *ci;
}
- cout << std::endl;
+ std::cout << std::endl;
}
else {
// ignore
static void generic_usage(bool is_server)
{
- cout <<
+ std::cout <<
" --conf/-c FILE read configuration from the given configuration file" << std::endl <<
(is_server ?
" --id/-i ID set ID portion of my name" :
<< std::endl;
if (is_server) {
- cout <<
+ std::cout <<
" -d run in foreground, log to stderr" << std::endl <<
" -f run in foreground, log to usual location" << std::endl <<
std::endl <<
" --debug_ms N set message debug level (e.g. 1)" << std::endl;
}
- cout.flush();
+ std::cout.flush();
}
bool ceph_argparse_need_usage(const std::vector<const char*>& args)
#include "common/valgrind.h"
#include "include/spinlock.h"
-using ceph::bufferlist;
-using ceph::HeartbeatMap;
-
// for CINIT_FLAGS
#include "common/common_init.h"
#include <iostream>
#include <pthread.h>
+using namespace std::literals;
+
+using ceph::bufferlist;
+using ceph::HeartbeatMap;
+
+
#if defined(WITH_SEASTAR) && !defined(WITH_ALIEN)
namespace crimson::common {
CephContext::CephContext()
// AdminSocketHook
int call(std::string_view command, const cmdmap_t& cmdmap,
- Formatter *f,
+ ceph::Formatter *f,
std::ostream& errss,
bufferlist& out) override {
if (command == "dump_mempools") {
}
if (changed.count("log_stderr_prefix")) {
- log->set_log_stderr_prefix(conf.get_val<string>("log_stderr_prefix"));
+ log->set_log_stderr_prefix(conf.get_val<std::string>("log_stderr_prefix"));
}
if (changed.count("log_max_new")) {
bool CephContext::check_experimental_feature_enabled(const std::string& feat)
{
- stringstream message;
+ std::stringstream message;
bool enabled = check_experimental_feature_enabled(feat, &message);
lderr(this) << message.str() << dendl;
return enabled;
r = -EINVAL;
} else {
// val may be multiple words
- string valstr = str_join(val, " ");
+ auto valstr = str_join(val, " ");
r = _conf.set_val(var.c_str(), valstr.c_str());
if (r < 0) {
ss << "error setting '" << var << "' to '" << valstr << "': "
<< cpp_strerror(r);
} else {
- stringstream ss;
+ std::stringstream ss;
_conf.apply_changes(&ss);
f->dump_string("success", ss.str());
}
f->close_section(); // unknown
}
else if (command == "injectargs") {
- vector<string> argsvec;
+ std::vector<std::string> argsvec;
cmd_getval(cmdmap, "injected_args", argsvec);
if (!argsvec.empty()) {
- string args = joinify<std::string>(argsvec.begin(),
- argsvec.end(),
- " ");
+ auto args = joinify<std::string>(argsvec.begin(), argsvec.end(), " ");
r = _conf.injectargs(args, &ss);
}
}
_mempool_perf_names.reserve(mempool::num_pools * 2);
_mempool_perf_descriptions.reserve(mempool::num_pools * 2);
for (unsigned i = 0; i < mempool::num_pools; ++i) {
- string n = mempool::get_pool_name(mempool::pool_index_t(i));
- _mempool_perf_names.push_back(n + "_bytes");
+ std::string n = mempool::get_pool_name(mempool::pool_index_t(i));
+ _mempool_perf_names.push_back(n + "_bytes"s);
_mempool_perf_descriptions.push_back(
- string("mempool ") + n + " total bytes");
- _mempool_perf_names.push_back(n + "_items");
+ "mempool "s + n + " total bytes");
+ _mempool_perf_names.push_back(n + "_items"s);
_mempool_perf_descriptions.push_back(
- string("mempool ") + n + " total items");
+ "mempool "s + n + " total items"s);
}
PerfCountersBuilder plb2(this, "mempool", l_mempool_first,
using namespace json_spirit;
-#define dout_subsys ceph_subsys_rgw
+using std::ifstream;
+using std::pair;
+using std::ostream;
+using std::string;
+using std::vector;
+using ceph::bufferlist;
+using ceph::Formatter;
-static JSONFormattable default_formattable;
+#define dout_subsys ceph_subsys_rgw
+static JSONFormattable default_formattable;
void encode_json(const char *name, const JSONObj::data_val& v, Formatter *f)
{
JSONObj::~JSONObj()
{
- multimap<string, JSONObj *>::iterator iter;
- for (iter = children.begin(); iter != children.end(); ++iter) {
+ for (auto iter = children.begin(); iter != children.end(); ++iter) {
JSONObj *obj = iter->second;
delete obj;
}
JSONObjIter JSONObj::find(const string& name)
{
JSONObjIter iter;
- map<string, JSONObj *>::iterator first;
- map<string, JSONObj *>::iterator last;
- first = children.find(name);
+ auto first = children.find(name);
if (first != children.end()) {
- last = children.upper_bound(name);
+ auto last = children.upper_bound(name);
iter.set(first, last);
}
return iter;
JSONObjIter JSONObj::find_first(const string& name)
{
JSONObjIter iter;
- map<string, JSONObj *>::iterator first;
- first = children.find(name);
+ auto first = children.find(name);
iter.set(first, children.end());
return iter;
}
bl.append(s.c_str(), s.size());
try {
val.decode_base64(bl);
- } catch (buffer::error& err) {
+ } catch (ceph::buffer::error& err) {
throw JSONDecoder::err("failed to decode base64");
}
}
}
#endif
+using namespace std::literals;
+
namespace ceph {
namespace time_detail {
void real_clock::to_ceph_timespec(const time_point& t,
// FIXME: somebody pretty please make a version of this function
// that isn't as lame as this one!
uint64_t nsec = std::chrono::nanoseconds(t).count();
- ostringstream ss;
+ std::ostringstream ss;
if (nsec < 2000000000) {
ss << ((float)nsec / 1000000000) << "s";
return ss.str();
uint64_t sec = nsec / 1000000000;
nsec %= 1000000000;
uint64_t yr = sec / (60 * 60 * 24 * 365);
- ostringstream ss;
+ std::ostringstream ss;
if (yr) {
ss << yr << "y";
sec -= yr * (60 * 60 * 24 * 365);
std::chrono::seconds parse_timespan(const std::string& s)
{
- static std::map<string,int> units = {
+ static std::map<std::string,int> units = {
{ "s", 1 },
{ "sec", 1 },
{ "second", 1 },
++pos;
}
if (val_start == pos) {
- throw invalid_argument("expected digit");
+ throw std::invalid_argument("expected digit");
}
- string n = s.substr(val_start, pos - val_start);
- string err;
+ auto n = s.substr(val_start, pos - val_start);
+ std::string err;
auto val = strict_strtoll(n.c_str(), 10, &err);
if (err.size()) {
- throw invalid_argument(err);
+ throw std::invalid_argument(err);
}
// skip whitespace
++pos;
}
if (unit_start != pos) {
- string unit = s.substr(unit_start, pos - unit_start);
+ auto unit = s.substr(unit_start, pos - unit_start);
auto p = units.find(unit);
if (p == units.end()) {
- throw invalid_argument("unrecogized unit '"s + unit + "'");
+ throw std::invalid_argument("unrecogized unit '"s + unit + "'");
}
val *= p->second;
} else if (pos < s.size()) {
- throw invalid_argument("unexpected trailing '"s + s.substr(pos) + "'");
+ throw std::invalid_argument("unexpected trailing '"s + s.substr(pos) + "'");
}
- r += chrono::seconds(val);
+ r += std::chrono::seconds(val);
}
return r;
}
#include "common/strtol.h"
#include "json_spirit/json_spirit.h"
+using std::is_same_v;
+using std::ostringstream;
+using std::string;
+using std::stringstream;
+using std::string_view;
+using std::vector;
+
/**
* Given a cmddesc like "foo baz name=bar,type=CephString",
* return the prefix "foo baz".
try {
if (!json_spirit::read(fullcmd, v))
- throw runtime_error("unparseable JSON " + fullcmd);
+ throw std::runtime_error("unparseable JSON " + fullcmd);
if (v.type() != json_spirit::obj_type)
- throw(runtime_error("not JSON object " + fullcmd));
+ throw std::runtime_error("not JSON object " + fullcmd);
// allocate new mObject (map) to return
// make sure all contents are simple types (not arrays or objects)
json_spirit::mObject o = v.get_obj();
- for (map<string, json_spirit::mValue>::iterator it = o.begin();
- it != o.end(); ++it) {
+ for (auto it = o.begin(); it != o.end(); ++it) {
// ok, marshal it into our string->cmd_vartype map, or throw an
// exception if it's not a simple datatype. This is kind of
case json_spirit::obj_type:
default:
- throw(runtime_error("JSON array/object not allowed " + fullcmd));
+ throw std::runtime_error("JSON array/object not allowed " + fullcmd);
break;
case json_spirit::array_type:
vector<string> outv;
for (const auto& sv : spvals) {
if (sv.type() != json_spirit::str_type) {
- throw(runtime_error("Can't handle arrays of multiple types"));
+ throw std::runtime_error("Can't handle arrays of multiple types");
}
outv.push_back(sv.get_str());
}
vector<int64_t> outv;
for (const auto& sv : spvals) {
if (spvals.front().type() != json_spirit::int_type) {
- throw(runtime_error("Can't handle arrays of multiple types"));
+ throw std::runtime_error("Can't handle arrays of multiple types");
}
outv.push_back(sv.get_int64());
}
vector<double> outv;
for (const auto& sv : spvals) {
if (spvals.front().type() != json_spirit::real_type) {
- throw(runtime_error("Can't handle arrays of multiple types"));
+ throw std::runtime_error("Can't handle arrays of multiple types");
}
outv.push_back(sv.get_real());
}
(*mapp)[it->first] = std::move(outv);
} else {
- throw(runtime_error("Can't handle arrays of types other than "
- "int, string, or double"));
+ throw std::runtime_error("Can't handle arrays of types other than "
+ "int, string, or double");
}
}
break;
}
}
return true;
- } catch (runtime_error &e) {
+ } catch (const std::runtime_error &e) {
ss << e.what();
return false;
}
}
auto min_max = get_str_list(string(range->second), "|");
auto min = str_to_num<T>(min_max.front());
- auto max = numeric_limits<T>::max();
+ auto max = std::numeric_limits<T>::max();
if (min_max.size() > 1) {
max = str_to_num<T>(min_max.back());
}
template<bool is_vector,
typename T,
- typename Value = conditional_t<is_vector,
- vector<T>,
- T>>
+ typename Value = std::conditional_t<is_vector,
+ vector<T>,
+ T>>
bool validate_arg(CephContext* cct,
const cmdmap_t& cmdmap,
const arg_desc_t& desc,
#endif // #ifndef WITH_SEASTAR
void complain_about_parse_error(CephContext *cct,
- const string& parse_error)
+ const std::string& parse_error)
{
if (parse_error.empty())
return;
// set set_mon_vals()
#define dout_subsys ceph_subsys_monc
+using std::cerr;
+using std::cout;
using std::map;
+using std::less;
using std::list;
+using std::ostream;
using std::ostringstream;
using std::pair;
using std::string;
+using std::string_view;
+using std::vector;
+
+using ceph::bufferlist;
+using ceph::decode;
+using ceph::encode;
+using ceph::Formatter;
static const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config, /etc/ceph/$cluster.conf, $home/.ceph/$cluster.conf, $cluster.conf"
#if defined(__FreeBSD__)
#define dout_subsys ceph_subsys_
+using std::map;
+using std::string;
namespace ceph {
DNSResolver::~DNSResolver()
{
#ifdef HAVE_RES_NQUERY
- list<res_state>::iterator iter;
- for (iter = states.begin(); iter != states.end(); ++iter) {
+ for (auto iter = states.begin(); iter != states.end(); ++iter) {
struct __res_state *s = *iter;
delete s;
}
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
#include "include/fs_types.h"
#include "common/Formatter.h"
#include "include/ceph_features.h"
-void dump(const ceph_file_layout& l, Formatter *f)
+void dump(const ceph_file_layout& l, ceph::Formatter *f)
{
f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
f->dump_unsigned("stripe_count", l.fl_stripe_count);
f->dump_unsigned("pg_pool", l.fl_pg_pool);
}
-void dump(const ceph_dir_layout& l, Formatter *f)
+void dump(const ceph_dir_layout& l, ceph::Formatter *f)
{
f->dump_unsigned("dir_hash", l.dl_dir_hash);
f->dump_unsigned("unused1", l.dl_unused1);
fl->fl_pg_pool = 0;
}
-void file_layout_t::encode(bufferlist& bl, uint64_t features) const
+void file_layout_t::encode(ceph::buffer::list& bl, uint64_t features) const
{
using ceph::encode;
if ((features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) == 0) {
ENCODE_FINISH(bl);
}
-void file_layout_t::decode(bufferlist::const_iterator& p)
+void file_layout_t::decode(ceph::buffer::list::const_iterator& p)
{
using ceph::decode;
if (*p == 0) {
DECODE_FINISH(p);
}
-void file_layout_t::dump(Formatter *f) const
+void file_layout_t::dump(ceph::Formatter *f) const
{
f->dump_unsigned("stripe_unit", stripe_unit);
f->dump_unsigned("stripe_count", stripe_count);
f->dump_string("pool_ns", pool_ns);
}
-void file_layout_t::generate_test_instances(list<file_layout_t*>& o)
+void file_layout_t::generate_test_instances(std::list<file_layout_t*>& o)
{
o.push_back(new file_layout_t);
o.push_back(new file_layout_t);
o.back()->pool_ns = "myns";
}
-ostream& operator<<(ostream& out, const file_layout_t &layout)
+std::ostream& operator<<(std::ostream& out, const file_layout_t &layout)
{
- JSONFormatter f;
+ ceph::JSONFormatter f;
layout.dump(&f);
f.flush(out);
return out;
}
-
#include "common/Formatter.h"
// -- pow2_hist_t --
-void pow2_hist_t::dump(Formatter *f) const
+void pow2_hist_t::dump(ceph::Formatter *f) const
{
f->open_array_section("histogram");
for (std::vector<int32_t>::const_iterator p = h.begin(); p != h.end(); ++p)
f->dump_int("upper_bound", upper_bound());
}
-void pow2_hist_t::encode(bufferlist& bl) const
+void pow2_hist_t::encode(ceph::buffer::list& bl) const
{
ENCODE_START(1, 1, bl);
encode(h, bl);
ENCODE_FINISH(bl);
}
-void pow2_hist_t::decode(bufferlist::const_iterator& p)
+void pow2_hist_t::decode(ceph::buffer::list::const_iterator& p)
{
DECODE_START(1, p);
decode(h, p);
#include "hobject.h"
#include "common/Formatter.h"
+using std::list;
+using std::ostream;
+using std::set;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::Formatter;
+
static void append_escaped(const string &in, string *out)
{
for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
#include <arpa/inet.h>
#include <ifaddrs.h>
#include "msg/msg_types.h"
#include "common/pick_address.h"
+using std::string;
+
void netmask_ipv4(const struct in_addr *addr,
unsigned int prefix_len,
struct in_addr *out) {
g_lockdep = 0;
}
};
+
+
static pthread_mutex_t lockdep_mutex = PTHREAD_MUTEX_INITIALIZER;
static CephContext *g_lockdep_ceph_ctx = NULL;
static lockdep_stopper_t lockdep_stopper;
static ceph::unordered_map<std::string, int> lock_ids;
-static map<int, std::string> lock_names;
-static map<int, int> lock_refs;
+static std::map<int, std::string> lock_names;
+static std::map<int, int> lock_refs;
static char free_ids[MAX_LOCKS/8]; // bit set = free
-static ceph::unordered_map<pthread_t, map<int,BackTrace*> > held;
+static ceph::unordered_map<pthread_t, std::map<int,ceph::BackTrace*> > held;
static char follows[MAX_LOCKS][MAX_LOCKS/8]; // follows[a][b] means b taken after a
-static BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS];
+static ceph::BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS];
unsigned current_maxid;
int last_freed_id = -1;
static bool free_ids_inited;
lock_ids.clear();
// FIPS zeroization audit 20191115: these memsets are not security related.
memset((void*)&follows[0][0], 0, current_maxid * MAX_LOCKS/8);
- memset((void*)&follows_bt[0][0], 0, sizeof(BackTrace*) * current_maxid * MAX_LOCKS);
+ memset((void*)&follows_bt[0][0], 0, sizeof(ceph::BackTrace*) * current_maxid * MAX_LOCKS);
}
pthread_mutex_unlock(&lockdep_mutex);
}
if (!g_lockdep)
goto out;
- for (ceph::unordered_map<pthread_t, map<int,BackTrace*> >::iterator p = held.begin();
- p != held.end();
- ++p) {
+ for (auto p = held.begin(); p != held.end(); ++p) {
lockdep_dout(0) << "--- thread " << p->first << " ---" << dendl;
- for (map<int,BackTrace*>::iterator q = p->second.begin();
+ for (auto q = p->second.begin();
q != p->second.end();
++q) {
lockdep_dout(0) << " * " << lock_names[q->first] << "\n";
pthread_mutex_lock(&lockdep_mutex);
std::string name;
- map<int, std::string>::iterator p = lock_names.find(id);
+ auto p = lock_names.find(id);
if (p == lock_names.end())
name = "unknown" ;
else
lockdep_dout(20) << "_will_lock " << name << " (" << id << ")" << dendl;
// check dependency graph
- map<int, BackTrace *> &m = held[p];
- for (map<int, BackTrace *>::iterator p = m.begin();
- p != m.end();
- ++p) {
+ auto& m = held[p];
+ for (auto p = m.begin(); p != m.end(); ++p) {
if (p->first == id) {
if (!recursive) {
lockdep_dout(0) << "\n";
*_dout << "recursive lock of " << name << " (" << id << ")\n";
- BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+ auto bt = new ceph::BackTrace(BACKTRACE_SKIP);
bt->print(*_dout);
if (p->second) {
*_dout << "\npreviously locked at\n";
// did we just create a cycle?
if (does_follow(id, p->first)) {
- BackTrace *bt = new BackTrace(BACKTRACE_SKIP);
+ auto bt = new ceph::BackTrace(BACKTRACE_SKIP);
lockdep_dout(0) << "new dependency " << lock_names[p->first]
<< " (" << p->first << ") -> " << name << " (" << id << ")"
<< " creates a cycle at\n";
*_dout << dendl;
lockdep_dout(0) << "btw, i am holding these locks:" << dendl;
- for (map<int, BackTrace *>::iterator q = m.begin();
- q != m.end();
- ++q) {
+ for (auto q = m.begin(); q != m.end(); ++q) {
lockdep_dout(0) << " " << lock_names[q->first] << " (" << q->first << ")" << dendl;
if (q->second) {
lockdep_dout(0) << " ";
ceph_abort(); // actually, we should just die here.
} else {
- BackTrace *bt = NULL;
+ ceph::BackTrace* bt = NULL;
if (force_backtrace || lockdep_force_backtrace()) {
- bt = new BackTrace(BACKTRACE_SKIP);
+ bt = new ceph::BackTrace(BACKTRACE_SKIP);
}
follows[p->first][id/8] |= 1 << (id % 8);
follows_bt[p->first][id] = bt;
lockdep_dout(20) << "_locked " << name << dendl;
if (force_backtrace || lockdep_force_backtrace())
- held[p][id] = new BackTrace(BACKTRACE_SKIP);
+ held[p][id] = new ceph::BackTrace(BACKTRACE_SKIP);
else
held[p][id] = 0;
out:
#include "include/stringify.h"
#include "common/safe_io.h"
+using namespace std::literals;
+
+using std::set;
+
// list
#if defined(__linux__)
// rbd feature validation
#include "librbd/Features.h"
+using std::ostream;
+using std::ostringstream;
+
+using ceph::Formatter;
+using ceph::parse_timespan;
+
namespace {
class printer : public boost::static_visitor<> {
ostream& out;
} else if (type == Option::TYPE_SECS) {
try {
*out = parse_timespan(val);
- } catch (const invalid_argument& e) {
+ } catch (const std::invalid_argument& e) {
*error_message = e.what();
return -EINVAL;
}
#include "include/common_fwd.h"
using std::ostringstream;
+using std::make_pair;
+using std::pair;
namespace TOPNSPC::common {
PerfCountersCollectionImpl::PerfCountersCollectionImpl()
{
add_impl(idx, name, description, nick, prio,
PERFCOUNTER_U64 | PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER, unit,
- unique_ptr<PerfHistogram<>>{new PerfHistogram<>{x_axis_config, y_axis_config}});
+ std::unique_ptr<PerfHistogram<>>{new PerfHistogram<>{x_axis_config, y_axis_config}});
}
void PerfCountersBuilder::add_impl(
int idx, const char *name,
const char *description, const char *nick, int prio, int ty, int unit,
- unique_ptr<PerfHistogram<>> histogram)
+ std::unique_ptr<PerfHistogram<>> histogram)
{
ceph_assert(idx > m_perf_counters->m_lower_bound);
ceph_assert(idx < m_perf_counters->m_upper_bound);
#define dout_subsys ceph_subsys_
+using std::string;
+using std::vector;
+
const struct sockaddr *find_ip_in_subnet_list(
CephContext *cct,
const struct ifaddrs *ifa,
return {};
}
- const unsigned int prefix_len = max(sizeof(in_addr::s_addr), sizeof(in6_addr::s6_addr)) * CHAR_BIT;
+ const unsigned int prefix_len = std::max(sizeof(in_addr::s_addr), sizeof(in6_addr::s6_addr)) * CHAR_BIT;
const struct ifaddrs *found = find_ip_in_subnet(
ifa,
(const struct sockaddr *) &network, prefix_len);
}
-bool have_local_addr(CephContext *cct, const list<entity_addr_t>& ls, entity_addr_t *match)
+bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match)
{
struct ifaddrs *ifa;
int r = getifaddrs(&ifa);
PHY_PORT,
BOND_PORT
} ifatype = iface_t::PHY_PORT;
- string_view ifa{iface};
+ std::string_view ifa{iface};
if (auto pos = ifa.find(":"); pos != ifa.npos) {
ifa.remove_suffix(ifa.size() - pos);
}
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+#include <cstring>
+
#include "include/types.h"
#include "rabin.h"
-#include <string.h>
uint64_t RabinChunk::gen_rabin_hash(char* chunk_data, uint64_t off, uint64_t len) {
* output_chunks split by Rabin
*/
-int RabinChunk::do_rabin_chunks(bufferlist & inputdata,
- vector<pair<uint64_t, uint64_t>> & chunks,
+int RabinChunk::do_rabin_chunks(ceph::buffer::list& inputdata,
+ std::vector<std::pair<uint64_t, uint64_t>>& chunks,
uint64_t min_val = 0, uint64_t max_val = 0)
{
char *ptr = inputdata.c_str();
}
if (data_size < min) {
- chunks.push_back(make_pair(0, data_size));
+ chunks.push_back(std::make_pair(0, data_size));
return 0;
}
}
if (store_chunk) {
- chunks.push_back(make_pair(c_start, c_size));
+ chunks.push_back(std::make_pair(c_start, c_size));
c_start += c_size;
c_offset = c_start;
start_new_chunk = true;
if (c_start < data_size) {
c_size = data_size - c_start;
- chunks.push_back(make_pair(c_start, c_size));
+ chunks.push_back(std::make_pair(c_start, c_size));
}
return 0;
#ifndef CEPH_COMMON_RABIN_H_
#define CEPH_COMMON_RABIN_H_
+#include <cstdint>
+#include <utility>
+#include <vector>
+
+#include "include/buffer_fwd.h"
+
class RabinChunk {
public:
- RabinChunk(uint32_t window_size, uint32_t rabin_prime,
- uint64_t mod_prime, uint64_t pow, vector<uint64_t> rabin_mask, uint64_t min,
- uint64_t max, uint32_t num_bits):
- window_size(window_size), rabin_prime(rabin_prime), mod_prime(mod_prime),
- pow(pow), rabin_mask(rabin_mask), min(min), max(max), num_bits(num_bits) {}
+ RabinChunk(uint32_t window_size, uint32_t rabin_prime,
+ uint64_t mod_prime, uint64_t pow, std::vector<uint64_t> rabin_mask,
+ uint64_t min, uint64_t max, uint32_t num_bits):
+ window_size(window_size), rabin_prime(rabin_prime),
+ mod_prime(mod_prime), pow(pow), rabin_mask(rabin_mask), min(min),
+ max(max), num_bits(num_bits) {}
RabinChunk() {
default_init_rabin_options();
}
void default_init_rabin_options() {
- vector<uint64_t> _rabin_mask = {0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
+ std::vector<uint64_t> _rabin_mask = {0,1,3,7,15,31,63,127,255,511,1023,2047,
+ 4095,8191,16383,32767,65535};
window_size = 48;
rabin_prime = 3;
mod_prime = 6148914691236517051;
rabin_mask = _rabin_mask;
}
- int do_rabin_chunks(bufferlist & inputdata,
- vector<pair<uint64_t, uint64_t>> & chunks,
+ int do_rabin_chunks(ceph::buffer::list& inputdata,
+ std::vector<std::pair<uint64_t, uint64_t>>& chunks,
uint64_t min, uint64_t max);
uint64_t gen_rabin_hash(char* chunk_data, uint64_t off, uint64_t len = 0);
bool end_of_chunk(const uint64_t fp , int numbits);
void set_rabin_prime(uint32_t r_prime) { rabin_prime = r_prime; }
void set_mod_prime(uint64_t m_prime) { mod_prime = m_prime; }
void set_pow(uint64_t p) { pow = p; }
- void set_rabin_mask(vector<uint64_t> & mask) { rabin_mask = mask; }
+ void set_rabin_mask(std::vector<uint64_t> & mask) { rabin_mask = mask; }
void set_min_chunk(uint32_t c_min) { min = c_min; }
void set_max_chunk(uint32_t c_max) { max = c_max; }
- int add_rabin_mask(uint64_t mask) {
+ int add_rabin_mask(uint64_t mask) {
rabin_mask.push_back(mask);
for (int i = 0; rabin_mask.size(); i++) {
if (rabin_mask[i] == mask) {
uint32_t window_size;
uint32_t rabin_prime;
uint64_t mod_prime;
- uint64_t pow;
- vector<uint64_t> rabin_mask;
+ uint64_t pow;
+ std::vector<uint64_t> rabin_mask;
uint64_t min;
uint64_t max;
uint32_t num_bits;
#include "scrub_types.h"
+using std::map;
+
using namespace librados;
void object_id_wrapper::encode(bufferlist& bl) const
*
*/
+#include <cstdlib>
+#include <sstream>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <signal.h>
+
#include "common/BackTrace.h"
-#include "common/perf_counters.h"
-#include "global/pidfile.h"
+#include "common/config.h"
#include "common/debug.h"
#include "common/signal.h"
-#include "common/config.h"
+#include "common/perf_counters.h"
-#include <signal.h>
-#include <sstream>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include "global/pidfile.h"
+
+using namespace std::literals;
std::string signal_mask_to_str()
{
return "(pthread_signmask failed)";
}
- ostringstream oss;
+ std::ostringstream oss;
oss << "show_signal_mask: { ";
- string sep("");
+ auto sep = ""s;
for (int signum = 0; signum < NSIG; ++signum) {
if (sigismember(&old_sigset, signum) == 1) {
oss << sep << signum;
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
#include "snap_types.h"
#include "common/Formatter.h"
-void SnapRealmInfo::encode(bufferlist& bl) const
+void SnapRealmInfo::encode(ceph::buffer::list& bl) const
{
h.num_snaps = my_snaps.size();
h.num_prior_parent_snaps = prior_parent_snaps.size();
using ceph::encode;
encode(h, bl);
- encode_nohead(my_snaps, bl);
- encode_nohead(prior_parent_snaps, bl);
+ ceph::encode_nohead(my_snaps, bl);
+ ceph::encode_nohead(prior_parent_snaps, bl);
}
-void SnapRealmInfo::decode(bufferlist::const_iterator& bl)
+void SnapRealmInfo::decode(ceph::buffer::list::const_iterator& bl)
{
using ceph::decode;
decode(h, bl);
- decode_nohead(h.num_snaps, my_snaps, bl);
- decode_nohead(h.num_prior_parent_snaps, prior_parent_snaps, bl);
+ ceph::decode_nohead(h.num_snaps, my_snaps, bl);
+ ceph::decode_nohead(h.num_prior_parent_snaps, prior_parent_snaps, bl);
}
-void SnapRealmInfo::dump(Formatter *f) const
+void SnapRealmInfo::dump(ceph::Formatter *f) const
{
f->dump_unsigned("ino", ino());
f->dump_unsigned("parent", parent());
f->dump_unsigned("created", created());
f->open_array_section("snaps");
- for (vector<snapid_t>::const_iterator p = my_snaps.begin(); p != my_snaps.end(); ++p)
+ for (auto p = my_snaps.begin(); p != my_snaps.end(); ++p)
f->dump_unsigned("snap", *p);
f->close_section();
f->open_array_section("prior_parent_snaps");
- for (vector<snapid_t>::const_iterator p = prior_parent_snaps.begin(); p != prior_parent_snaps.end(); ++p)
+ for (auto p = prior_parent_snaps.begin(); p != prior_parent_snaps.end(); ++p)
f->dump_unsigned("snap", *p);
- f->close_section();
+ f->close_section();
}
-void SnapRealmInfo::generate_test_instances(list<SnapRealmInfo*>& o)
+void SnapRealmInfo::generate_test_instances(std::list<SnapRealmInfo*>& o)
{
o.push_back(new SnapRealmInfo);
o.push_back(new SnapRealmInfo(1, 10, 10, 0));
return true;
}
-void SnapContext::dump(Formatter *f) const
+void SnapContext::dump(ceph::Formatter *f) const
{
f->dump_unsigned("seq", seq);
f->open_array_section("snaps");
- for (vector<snapid_t>::const_iterator p = snaps.begin(); p != snaps.end(); ++p)
+ for (auto p = snaps.cbegin(); p != snaps.cend(); ++p)
f->dump_unsigned("snap", *p);
f->close_section();
}
-void SnapContext::generate_test_instances(list<SnapContext*>& o)
+void SnapContext::generate_test_instances(std::list<SnapContext*>& o)
{
o.push_back(new SnapContext);
- vector<snapid_t> v;
+ std::vector<snapid_t> v;
o.push_back(new SnapContext(10, v));
v.push_back(18);
v.push_back(3);
const shard_id_t shard_id_t::NO_SHARD(-1);
-ostream &operator<<(ostream &lhs, const shard_id_t &rhs)
+std::ostream& operator<<(std::ostream& lhs, const shard_id_t& rhs)
{
return lhs << (unsigned)(uint8_t)rhs.id;
}
#include <stdio.h>
+using std::list;
+using std::map;
+using std::string;
+
+using ceph::bufferlist;
+using ceph::Formatter;
+
int get_fs_stats(ceph_data_stats_t &stats, const char *path)
{
if (!path)
}
static bool value_set(char *buf, const char *prefix,
- map<string, string> *pm, const char *key)
+ map<string, string> *pm, const char *key)
{
if (strncmp(buf, prefix, strlen(prefix))) {
return false;
ceph_assert(f);
f->open_object_section(type);
- for (map<string, list<int> >::const_iterator host = services.begin();
+ for (auto host = services.begin();
host != services.end(); ++host) {
f->open_array_section(host->first.c_str());
const list<int>& hosted = host->second;
- for (list<int>::const_iterator s = hosted.begin();
- s != hosted.end(); ++s) {
+ for (auto s = hosted.cbegin();
+ s != hosted.cend(); ++s) {
f->dump_int(type, *s);
}
f->close_section();