]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ceph-bluestore-tool: more strict control if bluefs device is expandable
authorIgor Fedotov <ifedotov@suse.com>
Fri, 23 Nov 2018 11:39:20 +0000 (14:39 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 3 Dec 2018 11:09:14 +0000 (14:09 +0300)
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>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/bluestore_tool.cc

index e13675cd5e36224a668ce025a4f3064d74393517..53fa35db8243a103ff1d1bd2fc905d611da09693 100644 (file)
@@ -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);
index 84c37128e23d377bb5fae952f95290f32d6c5a8d..6830901c5e8cb1745e14d61ebd027dbf4c9aa1b8 100644 (file)
@@ -356,6 +356,13 @@ public:
   /// 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,
index 50834d369cf43905c6dc0da24dabffee41ac3325..a8ad208ab1dc2137efb5c6a567ffa430c6c64f94 100644 (file)
@@ -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) {