Skip to content

Commit

Permalink
os/ceph-bluestore-tool: more strict control if bluefs device is expan…
Browse files Browse the repository at this point in the history
…dable

Fixes: https://tracker.ceph.com/issues/37494
This commit is specific for pre-Nautilius releases (mimic & luminous)
as we don't backport main device expansion feature. Which
makes this mimic/luminous commit completely different from nautilus one.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
  • Loading branch information
ifed01 committed Dec 3, 2018
1 parent 1867622 commit 69a730d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,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 @@ -356,6 +356,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
11 changes: 10 additions & 1 deletion src/os/bluestore/bluestore_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,18 @@ int main(int argc, char **argv)
cout << "start:" << std::endl;
fs->dump_block_extents(cout);
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."
<< std::endl;
continue;
}
interval_set<uint64_t> before;
fs->get_block_extents(devid, &before);
if (before.empty()) continue;
ceph_assert(!before.empty());
uint64_t end = before.range_end();
uint64_t size = fs->get_block_device_size(devid);
if (end < size) {
Expand Down

0 comments on commit 69a730d

Please sign in to comment.