Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore/BlueFS: several cleanups #17966

Merged
merged 3 commits into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 12 additions & 27 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 Expand Up @@ -1836,7 +1828,7 @@ int BlueFS::_allocate(uint8_t id, uint64_t len,
}

uint64_t hint = 0;
if (!ev->empty()) {
if (!ev->empty() && ev->back().bdev == id) {
hint = ev->back().end();
}

Expand All @@ -1854,14 +1846,7 @@ int BlueFS::_allocate(uint8_t id, uint64_t len,
}

for (auto& p : extents) {
bluefs_extent_t e = bluefs_extent_t(id, p.offset, p.length);
if (!ev->empty() &&
ev->back().bdev == e.bdev &&
ev->back().end() == (uint64_t) e.offset) {
ev->back().length += e.length;
} else {
ev->push_back(e);
}
ev->push_back(bluefs_extent_t(id, p.offset, p.length));
}

return 0;
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