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

luminous: core: os/bluestore_tool: fix bluefs expand #25384

Merged
merged 5 commits into from
Jan 16, 2019
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
24 changes: 24 additions & 0 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ int BlueFS::get_block_extents(unsigned id, interval_set<uint64_t> *extents)
return 0;
}

// returns true if specified device is attached
bool BlueFS::is_device(unsigned id)
{
return !(id >= MAX_BDEV || bdev[id] == nullptr);
}

// returns true if specified device is under full bluefs control
// and hence can be expanded
bool BlueFS::is_device_expandable(unsigned id)
{
if (id >= MAX_BDEV || bdev[id] == nullptr) {
return false;
}
switch(id) {
case BDEV_WAL:
return true;

case BDEV_DB:
// true if DB volume is non-shared
return bdev[BDEV_SLOW] != nullptr;
}
return false;
}

int BlueFS::mkfs(uuid_d osd_uuid)
{
std::unique_lock<std::mutex> l(lock);
Expand Down
7 changes: 7 additions & 0 deletions src/os/bluestore/BlueFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ class BlueFS {
/// get current extents that we own for given block device
int get_block_extents(unsigned id, interval_set<uint64_t> *extents);

// returns true if specified device is attached
bool is_device(unsigned id);

// returns true if specified device is under full bluefs control
// and hence can be expanded
bool is_device_expandable(unsigned id);

int open_for_write(
const string& dir,
const string& file,
Expand Down
23 changes: 18 additions & 5 deletions src/os/bluestore/bluestore_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,32 @@ int main(int argc, char **argv)
}
else if (action == "bluefs-bdev-expand") {
BlueFS *fs = open_bluefs(cct.get(), path, devs);
cout << "start:" << std::endl;
fs->dump_block_extents(cout);
cout << "Expanding..." << std::endl;
for (int devid : { BlueFS::BDEV_WAL, BlueFS::BDEV_DB }) {
if (!fs->is_device(devid)) {
continue;
}
if (!fs->is_device_expandable(devid)) {
cout << devid
<< " : can't be expanded. Bypassing..."
<< std::endl;
continue;
}
interval_set<uint64_t> before;
fs->get_block_extents(devid, &before);
assert(!before.empty());
uint64_t end = before.range_end();
uint64_t size = fs->get_block_device_size(devid);
if (end < size) {
cout << "expanding dev " << devid << " from 0x" << std::hex
cout << devid
<<" : expanding " << " from 0x" << std::hex
<< end << " to 0x" << size << std::dec << std::endl;
fs->add_block_extent(devid, end, size-end);
const char* path = find_device_path(devid, cct.get(), devs);
if (path == nullptr) {
cerr << "Can't find device path for dev " << devid << std::endl;
cerr << devid
<<": can't find device path " << std::endl;
continue;
}
bluestore_bdev_label_t label;
Expand All @@ -507,8 +519,9 @@ int main(int argc, char **argv)
<< cpp_strerror(r) << std::endl;
continue;
}
cout << "dev " << devid << " size label updated to "
<< size << std::endl;
cout << devid
<<" : size label updated to " << size
<< std::endl;
}
}
delete fs;
Expand Down