]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: kill block_total
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 26 Sep 2017 08:52:08 +0000 (16:52 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 26 Sep 2017 13:45:54 +0000 (21:45 +0800)
As block_all will suffice for the same purpose.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index e3ffff2600fda6a50cd02af695ca79de6a4422bd..fdbb493abb93fe2ee16c84ddd9c3931b3908efeb 100644 (file)
@@ -29,8 +29,7 @@ BlueFS::BlueFS(CephContext* cct)
   : cct(cct),
     bdev(MAX_BDEV),
     ioc(MAX_BDEV),
-    block_all(MAX_BDEV),
-    block_total(MAX_BDEV, 0)
+    block_all(MAX_BDEV)
 {
 }
 
@@ -113,19 +112,19 @@ void BlueFS::_update_logger_stats()
   logger->set(l_bluefs_log_bytes, log_writer->file->fnode.size);
 
   if (alloc[BDEV_WAL]) {
-    logger->set(l_bluefs_wal_total_bytes, block_total[BDEV_WAL]);
+    logger->set(l_bluefs_wal_total_bytes, block_all[BDEV_WAL].size());
     logger->set(l_bluefs_wal_used_bytes,
-               block_total[BDEV_WAL] - alloc[BDEV_WAL]->get_free());
+               block_all[BDEV_WAL].size() - alloc[BDEV_WAL]->get_free());
   }
   if (alloc[BDEV_DB]) {
-    logger->set(l_bluefs_db_total_bytes, block_total[BDEV_DB]);
+    logger->set(l_bluefs_db_total_bytes, block_all[BDEV_DB].size());
     logger->set(l_bluefs_db_used_bytes,
-               block_total[BDEV_DB] - alloc[BDEV_DB]->get_free());
+               block_all[BDEV_DB].size() - alloc[BDEV_DB]->get_free());
   }
   if (alloc[BDEV_SLOW]) {
-    logger->set(l_bluefs_slow_total_bytes, block_total[BDEV_SLOW]);
+    logger->set(l_bluefs_slow_total_bytes, block_all[BDEV_SLOW].size());
     logger->set(l_bluefs_slow_used_bytes,
-               block_total[BDEV_SLOW] - alloc[BDEV_SLOW]->get_free());
+               block_all[BDEV_SLOW].size() - alloc[BDEV_SLOW]->get_free());
   }
 }
 
@@ -171,7 +170,6 @@ void BlueFS::add_block_extent(unsigned id, uint64_t offset, uint64_t length)
   assert(bdev[id]);
   assert(bdev[id]->get_size() >= offset + length);
   block_all[id].insert(offset, length);
-  block_total[id] += length;
 
   if (id < alloc.size() && alloc[id]) {
     log_t.op_alloc_add(id, offset, length);
@@ -209,7 +207,6 @@ int BlueFS::reclaim_blocks(unsigned id, uint64_t want,
 
   for (auto& p : *extents) {
     block_all[id].erase(p.offset, p.length);
-    block_total[id] -= p.length;
     log_t.op_alloc_rm(id, p.offset, p.length);
   }
 
@@ -238,7 +235,7 @@ uint64_t BlueFS::get_total(unsigned id)
 {
   std::lock_guard<std::mutex> l(lock);
   assert(id < block_all.size());
-  return block_total[id];
+  return block_all[id].size();
 }
 
 uint64_t BlueFS::get_free(unsigned id)
@@ -276,9 +273,9 @@ void BlueFS::get_usage(vector<pair<uint64_t,uint64_t>> *usage)
       continue;
     }
     (*usage)[id].first = alloc[id]->get_free();
-    (*usage)[id].second = block_total[id];
+    (*usage)[id].second = block_all[id].size();
     uint64_t used =
-      (block_total[id] - (*usage)[id].first) * 100 / block_total[id];
+      (block_all[id].size() - (*usage)[id].first) * 100 / block_all[id].size();
     dout(10) << __func__ << " bdev " << id
             << " free " << (*usage)[id].first
             << " (" << pretty_si_t((*usage)[id].first) << "B)"
@@ -352,7 +349,6 @@ int BlueFS::mkfs(uuid_d osd_uuid)
   _close_writer(log_writer);
   log_writer = NULL;
   block_all.clear();
-  block_total.clear();
   _stop_alloc();
   _shutdown_logger();
 
@@ -404,8 +400,6 @@ int BlueFS::mount()
 
   block_all.clear();
   block_all.resize(MAX_BDEV);
-  block_total.clear();
-  block_total.resize(MAX_BDEV, 0);
   _init_alloc();
 
   r = _replay(false);
@@ -679,7 +673,6 @@ int BlueFS::_replay(bool noop)
                    << dendl;
          if (!noop) {
            block_all[id].insert(offset, length);
-           block_total[id] += length;
            alloc[id]->init_add_free(offset, length);
          }
        }
@@ -698,7 +691,6 @@ int BlueFS::_replay(bool noop)
                    << dendl;
          if (!noop) {
            block_all[id].erase(offset, length);
-           block_total[id] -= length;
            alloc[id]->init_rm_free(offset, length);
          }
        }
index 36b41b451bbe5a66168e35794ee0033dd5c498f4..72a12eac0fe0e112f6a7e112b1bc1d797000e331 100644 (file)
@@ -251,7 +251,6 @@ private:
   vector<BlockDevice*> bdev;                  ///< block devices we can use
   vector<IOContext*> ioc;                     ///< IOContexts for bdevs
   vector<interval_set<uint64_t> > block_all;  ///< extents in bdev we own
-  vector<uint64_t> block_total;               ///< sum of block_all
   vector<Allocator*> alloc;                   ///< allocators for bdevs
   vector<interval_set<uint64_t>> pending_release; ///< extents to release