]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/rbd/Utils.cc
import ceph quincy 17.2.1
[ceph.git] / ceph / src / tools / rbd / Utils.cc
index 75d9e6c04432d8abd62ea0a7dc05982af16f8c06..161cb91de1701f8a1093d5ec9e7affda2f3a03e0 100644 (file)
@@ -44,7 +44,7 @@ static std::string mgr_command_args_to_str(
 
 int ProgressContext::update_progress(uint64_t offset, uint64_t total) {
   if (progress) {
-    int pc = total ? (offset * 100ull / total) : 0;
+    int pc = get_percentage(offset, total);
     if (pc > last_pc) {
       std::cerr << "\r" << operation << ": "
                << pc << "% complete..." << std::flush;
@@ -67,6 +67,10 @@ void ProgressContext::fail() {
   }
 }
 
+int get_percentage(uint64_t part, uint64_t whole) {
+  return whole ? (100 * part / whole) : 0;
+}
+
 void aio_context_callback(librbd::completion_t completion, void *arg)
 {
   librbd::RBD::AioCompletion *aio_completion =