Skip to content

Commit

Permalink
os/bluestore/BlueFS: kill block_total
Browse files Browse the repository at this point in the history
block_all will suffice for the same purpose.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed Sep 26, 2017
1 parent c7d45c4 commit 2b5c5c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
28 changes: 10 additions & 18 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/os/bluestore/BlueFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class BlueFS {
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

Expand Down

0 comments on commit 2b5c5c4

Please sign in to comment.