Skip to content

Commit

Permalink
Merge pull request #25384 from ifed01/wip-ifed-fix2-expand-luminous
Browse files Browse the repository at this point in the history
luminous: core: os/bluestore_tool: fix bluefs expand

Reviewed-by: Josh Durgin <jdurgin@redhat.com>
  • Loading branch information
yuriw committed Jan 16, 2019
2 parents 57da9d4 + 946c3b4 commit bff97ce
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
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

0 comments on commit bff97ce

Please sign in to comment.