diff --git a/src/tools/ceph_dedup_tool.cc b/src/tools/ceph_dedup_tool.cc index f0c2713a02ad6d..e9ee933261d4c5 100644 --- a/src/tools/ceph_dedup_tool.cc +++ b/src/tools/ceph_dedup_tool.cc @@ -160,6 +160,8 @@ void usage() cout << " --chunk-dedup-threshold " << std::endl; cout << " --sampling-ratio " << std::endl; cout << " --shallow-crawling" << std::endl; + cout << " --daemon" << std::endl; + cout << " --iterative" << std::endl; cout << "explanations: " << std::endl; cout << " chunk-dedup performs deduplication using a chunk generated by given source" << std::endl; cout << " offset and length. object-dedup deduplicates the entire object, not a chunk" << std::endl; @@ -1758,6 +1760,28 @@ int make_dedup_object(const std::map < std::string, std::string > &opts, int make_crawling_daemon(const map &opts, vector &nargs) { + + map::const_iterator i = opts.find("daemon"); + if (i != opts.end()) { + pid_t pid = fork(); + if (pid < 0) { + cerr << "daemon process creation failed\n"; + return -EINVAL; + } + + if (pid != 0) { + return 0; + } + signal(SIGHUP, SIG_IGN); + close(STDIN_FILENO); + close(STDOUT_FILENO); + } + + i = opts.find("iterative"); + bool iterative = false; + if (i != opts.end()) { + iterative = true; + } string base_pool_name; auto i = opts.find("pool"); if (i != opts.end()) { @@ -1840,6 +1864,13 @@ int make_crawling_daemon(const map &opts, cerr << "couldn't connect to cluster: " << cpp_strerror(ret) << std::endl; return -EINVAL; } + uint32_t wakeup_period = 100; + i = opts.find("wakeup-period"); + if (i != opts.end()) { + if (rados_sistrtoll(i, &wakeup_period)) { + return -EINVAL; + } + } std::string fp_algo; i = opts.find("fingerprint-algorithm"); @@ -1950,7 +1981,12 @@ int make_crawling_daemon(const map &opts, for (auto &p : estimate_threads) { p->join(); } - break; + + if (iterative) { + sleep(wakeup_period); + } else { + break; + } } return 0; @@ -2028,6 +2064,12 @@ int main(int argc, const char **argv) opts["object-dedup-threshold"] = val; } else if (ceph_argparse_witharg(args, i, &val, "--chunk-dedup-threshold", (char*)NULL)) { opts["chunk-dedup-threshold"] = val; + } else if (ceph_argparse_witharg(args, i, &val, "--wakeup-period", (char*)NULL)) { + opts["wakeup-period"] = val; + } else if (ceph_argparse_flag(args, i, "--daemon", (char*)NULL)) { + opts["daemon"] = "true"; + } else if (ceph_argparse_flag(args, i, "--iterative", (char*)NULL)) { + opts["iterative"] = "true"; } else if (ceph_argparse_flag(args, i, "--shallow-crawling", (char*)NULL)) { opts["shallow-crawling"] = true; } else if (ceph_argparse_flag(args, i, "--debug", (char*)NULL)) {