From 6228d5ee220bf969f1061880f592a526436c406c Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 26 Sep 2017 16:52:08 +0800 Subject: [PATCH] os/bluestore/BlueFS: kill block_total As block_all will suffice for the same purpose. Signed-off-by: xie xingguo --- src/os/bluestore/BlueFS.cc | 28 ++++++++++------------------ src/os/bluestore/BlueFS.h | 1 - 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index e3ffff2600fda..fdbb493abb93f 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -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 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> *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); } } diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 36b41b451bbe5..72a12eac0fe0e 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -251,7 +251,6 @@ private: vector bdev; ///< block devices we can use vector ioc; ///< IOContexts for bdevs vector > block_all; ///< extents in bdev we own - vector block_total; ///< sum of block_all vector alloc; ///< allocators for bdevs vector> pending_release; ///< extents to release -- 2.39.5