]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_dedup_tool: SampleDedupWorkerThread can simply inherit from Thread
authorSamuel Just <sjust@redhat.com>
Sat, 17 Sep 2022 02:42:49 +0000 (02:42 +0000)
committermyoungwon oh <ohmyoungwon@gmail.com>
Mon, 19 Sep 2022 04:21:12 +0000 (13:21 +0900)
SampleDedupWorkerThread didn't actually use any of the facilities on
CrawlerThread and indeed left several of them uninitialized.

Also allows us to remove the CrawlerThread constructor which left
several members uninitialized.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/tools/ceph_dedup_tool.cc

index 4075d562b44975c60cde091efe47215d3d2ab550..c97b46e88139f67b7c2a727b636d636bef702636 100644 (file)
@@ -232,7 +232,6 @@ public:
     io_ctx(io_ctx), n(n), m(m), begin(begin), end(end), 
     report_period(report_period), total_objects(num_objects), max_read_size(max_read_size)
   {}
-  CrawlerThread() { }
 
   void signal(int signum) {
     std::lock_guard l{m_lock};
@@ -537,7 +536,7 @@ void ChunkScrub::chunk_scrub_common()
 
 using AioCompRef = unique_ptr<AioCompletion>;
 
-class SampleDedupWorkerThread : public CrawlerThread
+class SampleDedupWorkerThread : public Thread
 {
 public:
   struct chunk_t {
@@ -1670,15 +1669,10 @@ int make_crawling_daemon(const po::variables_map &opts)
       return -EINVAL;
     }
 
-    bool debug = false;
-    if (opts.count("debug")) {
-      debug = true;
-    }
-
-    estimate_threads.clear();
     SampleDedupWorkerThread::SampleDedupGlobal sample_dedup_global(
       chunk_dedup_threshold, sampling_ratio);
 
+    std::list<SampleDedupWorkerThread> threads;
     for (unsigned i = 0; i < max_thread; i++) {
       cout << " add thread.. " << std::endl;
       ObjectCursor shard_start;
@@ -1691,23 +1685,20 @@ int make_crawling_daemon(const po::variables_map &opts)
         &shard_start,
         &shard_end);
 
-      unique_ptr<CrawlerThread> ptr (
-          new SampleDedupWorkerThread(
-            io_ctx,
-            chunk_io_ctx,
-            shard_start,
-            shard_end,
-            chunk_size,
-            fp_algo,
-            chunk_algo,
-            sample_dedup_global));
-      ptr->set_debug(debug);
-      ptr->create("sample_dedup");
-      estimate_threads.push_back(move(ptr));
+      threads.emplace_back(
+       io_ctx,
+       chunk_io_ctx,
+       shard_start,
+       shard_end,
+       chunk_size,
+       fp_algo,
+       chunk_algo,
+       sample_dedup_global);
+      threads.back().create("sample_dedup");
     }
 
-    for (auto &p : estimate_threads) {
-      p->join();
+    for (auto &p : threads) {
+      p.join();
     }
     if (loop) {
       sleep(wakeup_period);