]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: use given osd_fsid when mkfs 28800/head
authorKefu Chai <kchai@redhat.com>
Sun, 30 Jun 2019 15:34:53 +0000 (23:34 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 30 Jun 2019 15:42:55 +0000 (23:42 +0800)
MemStore does not have this feature, but CyanStore needs it. because
`qa/tasks/ceph.py` uses following steps when creating/starting an OSD

1. ceph-osd --mkfs --mkkey -i <osd_id> --monmap <monmap>
2. read the osd_fsid of osd.<osd_id>
3. ceph osd new <osd_fsid> <osd_id>

when we mkfs for the OSD, the osd_fsid is still unknown. so we cannot
use the configured one, as it is always empty. in that case, we need to
use a random uuid, and persist it to both ${osd_data}/fsid and
superblock.osd_fsid

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/os/cyan_store.cc
src/crimson/os/cyan_store.h
src/crimson/os/futurized_store.h
src/crimson/osd/osd.cc

index 4473d7ac166d164c712a35bdf1c400c0f4bedc19..796f23544fda654ae7ce26bd8f2c7f9f44006528 100644 (file)
@@ -80,12 +80,16 @@ seastar::future<> CyanStore::umount()
   });
 }
 
-seastar::future<> CyanStore::mkfs()
+seastar::future<> CyanStore::mkfs(uuid_d new_osd_fsid)
 {
   std::string fsid_str;
   int r = read_meta("fsid", &fsid_str);
   if (r == -ENOENT) {
-    osd_fsid.generate_random();
+    if (new_osd_fsid.is_zero()) {
+      osd_fsid.generate_random();
+    } else {
+      osd_fsid = new_osd_fsid;
+    }
     write_meta("fsid", fmt::format("{}", osd_fsid));
   } else if (r < 0) {
     throw std::runtime_error("read_meta");
@@ -93,6 +97,9 @@ seastar::future<> CyanStore::mkfs()
     logger().info("{} already has fsid {}", __func__, fsid_str);
     if (!osd_fsid.parse(fsid_str.c_str())) {
       throw std::runtime_error("failed to parse fsid");
+    } else if (osd_fsid != new_osd_fsid) {
+      logger().error("on-disk fsid {} != provided {}", osd_fsid, new_osd_fsid);
+      throw std::runtime_error("unmatched osd_fsid");
     }
   }
 
index 028e733fad93f477b3d0c78c8ff4e268b29fa253..8eacaa29b8d8e2d4ecebac133f76799875e08674 100644 (file)
@@ -41,7 +41,7 @@ public:
   seastar::future<> mount() final;
   seastar::future<> umount() final;
 
-  seastar::future<> mkfs() final;
+  seastar::future<> mkfs(uuid_d new_osd_fsid) final;
   store_statfs_t stat() const final;
 
   seastar::future<ceph::bufferlist> read(CollectionRef c,
index ab4adfd35275bc2dc095493c25298b6885ece35b..81f584cf4e0e3d381152b3f2b70813de20cfdc5b 100644 (file)
@@ -61,7 +61,7 @@ public:
   virtual seastar::future<> mount() = 0;
   virtual seastar::future<> umount() = 0;
 
-  virtual seastar::future<> mkfs() = 0;
+  virtual seastar::future<> mkfs(uuid_d new_osd_fsid) = 0;
   virtual store_statfs_t stat() const = 0;
 
   using CollectionRef = boost::intrusive_ptr<Collection>;
index c29ab84667c20538fb9f77aacb9b761d9d456b0b..c76da4e3c49c6a3ca64381a70d73b90eca751fd5 100644 (file)
@@ -110,11 +110,11 @@ CompatSet get_osd_initial_compat_set()
 
 seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
 {
-  return store->mkfs().then([this] {
+  return store->mkfs(osd_uuid).then([this] {
     return store->mount();
-  }).then([cluster_fsid, osd_uuid, this] {
+  }).then([cluster_fsid, this] {
     superblock.cluster_fsid = cluster_fsid;
-    superblock.osd_fsid = osd_uuid;
+    superblock.osd_fsid = store->get_fsid();
     superblock.whoami = whoami;
     superblock.compat_features = get_osd_initial_compat_set();