if (!result.empty()) {
print_deprecated_warning(option, description);
}
- } catch (exception& e) {
+ } catch (std::exception& e) {
continue;
}
}
if (progress) {
int pc = total ? (offset * 100ull / total) : 0;
if (pc > last_pc) {
- cerr << "\r" << operation << ": "
- << pc << "% complete...";
- cerr.flush();
+ std::cerr << "\r" << operation << ": "
+ << pc << "% complete..." << std::flush;
last_pc = pc;
}
}
void ProgressContext::finish() {
if (progress) {
- cerr << "\r" << operation << ": 100% complete...done." << std::endl;
+ std::cerr << "\r" << operation << ": 100% complete...done." << std::endl;
}
}
void ProgressContext::fail() {
if (progress) {
- cerr << "\r" << operation << ": " << last_pc << "% complete...failed."
- << std::endl;
+ std::cerr << "\r" << operation << ": " << last_pc << "% complete...failed."
+ << std::endl;
}
}
std::cout << "write error: " << cpp_strerror(ret) << std::endl;
exit(ret < 0 ? -ret : ret);
} else if (b->io_type == IO_TYPE_READ && (unsigned int)ret != b->io_size) {
- cout << "read error: " << cpp_strerror(ret) << std::endl;
+ std::cout << "read error: " << cpp_strerror(ret) << std::endl;
exit(ret < 0 ? -ret : ret);
}
b->lock.lock();
<< " type " << (io_type == IO_TYPE_READ ? "read" :
io_type == IO_TYPE_WRITE ? "write" : "readwrite")
<< (io_type == IO_TYPE_RW ? " read:write=" +
- to_string(read_proportion) + ":" + to_string(100 - read_proportion) : "")
+ std::to_string(read_proportion) + ":" +
+ std::to_string(100 - read_proportion) : "")
<< " io_size " << io_size
<< " io_threads " << io_threads
<< " bytes " << io_bytes
srand(time(NULL) % (unsigned long) -1);
coarse_mono_time start = coarse_mono_clock::now();
- chrono::duration<double> last = chrono::duration<double>::zero();
+ std::chrono::duration<double> last = std::chrono::duration<double>::zero();
unsigned ios = 0;
- vector<uint64_t> thread_offset;
+ std::vector<uint64_t> thread_offset;
uint64_t i;
uint64_t seq_chunk_length = (size / io_size / io_threads) * io_size;;
}
coarse_mono_time now = coarse_mono_clock::now();
- chrono::duration<double> elapsed = now - start;
- if (last == chrono::duration<double>::zero()) {
+ std::chrono::duration<double> elapsed = now - start;
+ if (last == std::chrono::duration<double>::zero()) {
last = elapsed;
} else if ((int)elapsed.count() != (int)last.count()) {
time_acc((elapsed - last).count());
}
coarse_mono_time now = coarse_mono_clock::now();
- chrono::duration<double> elapsed = now - start;
+ std::chrono::duration<double> elapsed = now - start;
std::cout << "elapsed: " << (int)elapsed.count() << " "
<< "ops: " << ios << " "
}
int wait_for(uint64_t max) {
+ using namespace std::chrono_literals;
std::unique_lock l{lock};
int r = io_status.io_error;
#include <boost/program_options.hpp>
#include <boost/scope_exit.hpp>
+using std::cerr;
+using std::string;
+
namespace rbd {
namespace action {
namespace export_full {
break;
}
- uint64_t length = min(period, info.size - offset);
+ uint64_t length = std::min(period, info.size - offset);
C_Export *ctx = new C_Export(throttle, image, file_size + offset, offset,
length, fd);
ctx->send();
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rbd
+using std::cerr;
+using std::string;
+
namespace rbd {
namespace action {
namespace import {
if (fd == STDIN_FILENO) {
// read the appending data out to skip this tag.
char buf[4096];
- uint64_t len = min<uint64_t>(length, sizeof(buf));
+ uint64_t len = std::min<uint64_t>(length, sizeof(buf));
while (len > 0) {
r = safe_read_exact(fd, buf, len);
if (r < 0) {
return r;
}
length -= len;
- len = min<uint64_t>(length, sizeof(buf));
+ len = std::min<uint64_t>(length, sizeof(buf));
}
} else {
// lseek to skip this tag
g_conf().get_val<uint64_t>("rbd_concurrent_management_ops"), false));
}
- reqlen = min<uint64_t>(reqlen, size);
+ reqlen = std::min<uint64_t>(reqlen, size);
// loop body handles 0 return, as we may have a block to flush
while ((readlen = ::read(fd, p + blklen, reqlen)) >= 0) {
if (throttle->pending_error()) {
librbd::Image img;
librbd::RBD::AioCompletion* completion;
WorkerState state;
- string name;
- string id;
+ std::string name;
+ std::string id;
WorkerEntry() {
state = STATE_IDLE;
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rbd
+using std::string;
+
namespace rbd {
namespace action {
namespace merge_diff {
r = do_merge_diff(first_diff.c_str(), second_diff.c_str(), path.c_str(),
vm[at::NO_PROGRESS].as<bool>());
if (r < 0) {
- cerr << "rbd: merge-diff error" << std::endl;
+ std::cerr << "rbd: merge-diff error" << std::endl;
return -r;
}
struct timespec timestamp;
bool snap_protected = false;
image.snap_get_timestamp(s->id, ×tamp);
- string tt_str = "";
+ std::string tt_str = "";
if(timestamp.tv_sec != 0) {
time_t tt = timestamp.tv_sec;
tt_str = ctime(&tt);
t << s->id << s->name << stringify(byte_u_t(s->size)) << protected_str << tt_str;
if (all_snaps) {
- ostringstream oss;
+ std::ostringstream oss;
oss << snap_namespace_name;
if (get_group_res == 0) {
} else if (0 == snaps.size()) {
return 0;
} else {
- list<std::string> protect;
+ std::list<std::string> protect;
snaps.erase(remove_if(snaps.begin(),
snaps.end(),
boost::bind(utils::is_not_user_snap_namespace, &image, _1)),
bool all_snaps = vm[ALL_NAME].as<bool>();
r = do_list_snaps(image, formatter.get(), all_snaps, rados);
if (r < 0) {
- cerr << "rbd: failed to list snapshots: " << cpp_strerror(r)
+ std::cerr << "rbd: failed to list snapshots: " << cpp_strerror(r)
<< std::endl;
return r;
}
r = do_add_snap(image, snap_name.c_str(), flags,
vm[at::NO_PROGRESS].as<bool>());
if (r < 0) {
- cerr << "rbd: failed to create snapshot: " << cpp_strerror(r)
- << std::endl;
+ std::cerr << "rbd: failed to create snapshot: " << cpp_strerror(r)
+ << std::endl;
return r;
}
return 0;