summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Durgin <josh.durgin@inktank.com>2013-04-17 15:37:11 -0700
committerJosh Durgin <josh.durgin@inktank.com>2013-04-17 15:37:11 -0700
commit90a3bb7ae3f7b224d89cb75144fd365fdbd0971d (patch)
tree01fea959559d14194788ff995c3061f4ea0ce719
parent8f21beb23cf0ca1834f5cc42737530b3cbcb72ec (diff)
parentdb37bd8e7383fe59e1e93169acf4bc7997cacbcb (diff)
downloadceph-90a3bb7ae3f7b224d89cb75144fd365fdbd0971d.tar.gz
Merge pull request #219 from ceph/wip-rbd-progress
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--src/rbd.cc32
-rw-r--r--src/test/cli/rbd/help.t1
2 files changed, 22 insertions, 11 deletions
diff --git a/src/rbd.cc b/src/rbd.cc
index 6449ef1f4cd..03735a20cb1 100644
--- a/src/rbd.cc
+++ b/src/rbd.cc
@@ -71,6 +71,7 @@ static string dir_oid = RBD_DIRECTORY;
static string dir_info_oid = RBD_INFO;
bool udevadm_settle = true;
+bool progress = true;
#define dout_subsys ceph_subsys_rbd
@@ -152,7 +153,8 @@ void usage()
" --shared <tag> take a shared (rather than exclusive) lock\n"
" --format <output-format> output format (default: plain, json, xml)\n"
" --pretty-format make json or xml output more readable\n"
-" --no-settle do not wait for udevadm to settle on map/unmap\n";
+" --no-settle do not wait for udevadm to settle on map/unmap\n"
+" --no-progress do not show progress for long-running commands\n";
}
static string feature_str(uint64_t feature)
@@ -198,22 +200,28 @@ struct MyProgressContext : public librbd::ProgressContext {
}
int update_progress(uint64_t offset, uint64_t total) {
- int pc = total ? (offset * 100ull / total) : 0;
- if (pc != last_pc) {
- cerr << "\r" << operation << ": "
- // << offset << " / " << total << " "
- << pc << "% complete...";
- cerr.flush();
- last_pc = pc;
+ if (progress) {
+ int pc = total ? (offset * 100ull / total) : 0;
+ if (pc != last_pc) {
+ cerr << "\r" << operation << ": "
+ // << offset << " / " << total << " "
+ << pc << "% complete...";
+ cerr.flush();
+ last_pc = pc;
+ }
}
return 0;
}
void finish() {
- cerr << "\r" << operation << ": 100% complete...done." << std::endl;
+ if (progress) {
+ cerr << "\r" << operation << ": 100% complete...done." << std::endl;
+ }
}
void fail() {
- cerr << "\r" << operation << ": " << last_pc << "% complete...failed."
- << std::endl;
+ if (progress) {
+ cerr << "\r" << operation << ": " << last_pc << "% complete...failed."
+ << std::endl;
+ }
}
};
@@ -2188,6 +2196,8 @@ int main(int argc, const char **argv)
lock_tag = strdup(val.c_str());
} else if (ceph_argparse_flag(args, i, "--no-settle", (char *)NULL)) {
udevadm_settle = false;
+ } else if (ceph_argparse_flag(args, i, "--no-progress", (char *)NULL)) {
+ progress = false;
} else if (ceph_argparse_witharg(args, i, &val, "--format", (char *) NULL)) {
std::string err;
long long ret = strict_strtoll(val.c_str(), 10, &err);
diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t
index 3fc81a2f31f..b88b42bdb30 100644
--- a/src/test/cli/rbd/help.t
+++ b/src/test/cli/rbd/help.t
@@ -75,3 +75,4 @@
--format <output-format> output format (default: plain, json, xml)
--pretty-format make json or xml output more readable
--no-settle do not wait for udevadm to settle on map/unmap
+ --no-progress do not show progress for long-running commands