void *ptr;
struct iovec iov[NR_IOVECS];
+ uint64_t bytes_read = 0;
+ uint64_t bytes_written = 0;
+ sec_duration read_time{0};
+ sec_duration write_time{0};
int r = ceph_openat(m_local_mount, fh.c_fd, epath.c_str(), O_RDONLY | O_NOFOLLOW, 0);
if (r < 0) {
derr << ": failed to open local file path=" << epath << ": "
}
}
+ auto rs = clock::now();
r = ceph_preadv(m_local_mount, l_fd, iov, num_buffers, offset);
+ auto re = clock::now();
+ read_time += sec_duration(re - rs);
if (r < 0) {
derr << ": failed to read local file path=" << epath << ": "
<< cpp_strerror(r) << dendl;
break;
}
+ bytes_read += r;
dout(10) << ": read: " << r << " bytes" << dendl;
if (r == 0) {
break;
}
dout(10) << ": writing to offset: " << offset << dendl;
+ auto ws = clock::now();
r = ceph_pwritev(m_remote_mount, r_fd, iov, iovs, offset);
+ auto we = clock::now();
+ write_time += sec_duration(we - ws);
if (r < 0) {
derr << ": failed to write remote file path=" << epath << ": "
<< cpp_strerror(r) << dendl;
break;
}
+ bytes_written += r;
offset += r;
}
++b;
}
+ //io accounting for metrics
+ add_io(dir_root, bytes_read, bytes_written, read_time.count(), write_time.count());
+
if (num_blocks == 0 && r >= 0) { // handle blocklist case
dout(20) << ": truncating epath=" << epath << " to " << stx.stx_size << " bytes"
<< dendl;
f->dump_string("sync-mode", "delta");
else
f->dump_string("sync-mode", "full");
+
+ //avg read/write throughput
+ double read_bps = sync_stat.read_time_sec > 0 ?
+ sync_stat.bytes_read / sync_stat.read_time_sec : 0;
+ double write_bps = sync_stat.write_time_sec > 0 ?
+ sync_stat.bytes_written / sync_stat.write_time_sec : 0;
+ f->dump_string("avg_read_throughput_bytes", format_bytes(read_bps) + "/s");
+ f->dump_string("avg_write_throughput_bytes", format_bytes(write_bps) + "/s");
+
f->open_object_section("crawl");
if (sync_stat.crawl_finished) {
f->dump_string("state", "completed");
bool crawl_finished = false; // crawl_state - in-progress/completed
clock::time_point crawl_start_time; // to show current crawl duration if crawl is in progress
double crawl_duration = 0.0; // time taken to complete the crawl, includes a few entry operation like mkdir as well
+ // actual io accounting
+ uint64_t bytes_read = 0; //actual bytes read counter, independently for each directory sync.
+ uint64_t bytes_written = 0; //actual bytes written counter, independently for each directory sync.
+ double read_time_sec = 0.0; //actual read time in seconds counter, independently for each directroy sync.
+ double write_time_sec = 0.0; //actual write time in seconds counter, independently for each directroy sync.
};
void _inc_failed_count(const std::string &dir_root) {
sync_stat.crawl_finished = false;
sync_stat.crawl_start_time = clock::now();
sync_stat.crawl_duration = 0.0;
+ sync_stat.bytes_read = 0;
+ sync_stat.bytes_written = 0;
+ sync_stat.read_time_sec = 0.0;
+ sync_stat.write_time_sec = 0.0;
}
void _set_last_synced_snap(const std::string &dir_root, uint64_t snap_id,
const std::string &snap_name) {
sync_stat.crawl_finished = state;
sync_stat.crawl_duration = seconds;
}
+ void add_io(const std::string &dir_root, const uint64_t& br, const uint64_t bw,
+ const double rt, const double wt) {
+ std::scoped_lock locker(m_lock);
+ auto &sync_stat = m_snap_sync_stats.at(dir_root);
+ sync_stat.bytes_read += br;
+ sync_stat.bytes_written += bw;
+ sync_stat.read_time_sec += rt;
+ sync_stat.write_time_sec += wt;
+ }
void inc_sync_bytes(const std::string &dir_root, const uint64_t& b) {
std::scoped_lock locker(m_lock);
auto &sync_stat = m_snap_sync_stats.at(dir_root);