]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-bluestore-tool: update size label on bluefs expand 22085/head
authorIgor Fedotov <ifedotov@suse.com>
Thu, 24 May 2018 16:05:48 +0000 (19:05 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Thu, 24 May 2018 16:05:48 +0000 (19:05 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/bluestore_tool.cc

index fc21750542ecaccdbf657531c063c99526eb6753..50834d369cf43905c6dc0da24dabffee41ac3325 100644 (file)
@@ -66,6 +66,28 @@ void validate_path(CephContext *cct, const string& path, bool bluefs)
   }
 }
 
+const char* find_device_path(
+  int id,
+  CephContext *cct,
+  const vector<string>& devs)
+{
+  for (auto& i : devs) {
+    bluestore_bdev_label_t label;
+    int r = BlueStore::_read_bdev_label(cct, i, &label);
+    if (r < 0) {
+      cerr << "unable to read label for " << i << ": "
+          << cpp_strerror(r) << std::endl;
+      exit(EXIT_FAILURE);
+    }
+    if ((id == BlueFS::BDEV_SLOW && label.description == "main") ||
+        (id == BlueFS::BDEV_DB && label.description == "bluefs db") ||
+        (id == BlueFS::BDEV_WAL && label.description == "bluefs wal")) {
+      return i.c_str();
+    }
+  }
+  return nullptr;
+}
+
 void add_devices(
   BlueFS *fs,
   CephContext *cct,
@@ -483,6 +505,27 @@ int main(int argc, char **argv)
        cout << "expanding dev " << devid << " 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;
+         continue;
+       }
+       bluestore_bdev_label_t label;
+       int r = BlueStore::_read_bdev_label(cct.get(), path, &label);
+       if (r < 0) {
+         cerr << "unable to read label for " << path << ": "
+               << cpp_strerror(r) << std::endl;
+         continue;
+       }
+        label.size = size;
+       r = BlueStore::_write_bdev_label(cct.get(), path, label);
+       if (r < 0) {
+         cerr << "unable to write label for " << path << ": "
+               << cpp_strerror(r) << std::endl;
+         continue;
+       }
+       cout << "dev " << devid << " size label updated to "
+             << size << std::endl;
       }
     }
     delete fs;