From: Kefu Chai Date: Sun, 30 Jun 2019 15:34:53 +0000 (+0800) Subject: crimson: use given osd_fsid when mkfs X-Git-Tag: v15.1.0~2337^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28800%2Fhead;p=ceph.git crimson: use given osd_fsid when mkfs 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 --monmap 2. read the osd_fsid of osd. 3. ceph osd new 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 --- diff --git a/src/crimson/os/cyan_store.cc b/src/crimson/os/cyan_store.cc index 4473d7ac166d..796f23544fda 100644 --- a/src/crimson/os/cyan_store.cc +++ b/src/crimson/os/cyan_store.cc @@ -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"); } } diff --git a/src/crimson/os/cyan_store.h b/src/crimson/os/cyan_store.h index 028e733fad93..8eacaa29b8d8 100644 --- a/src/crimson/os/cyan_store.h +++ b/src/crimson/os/cyan_store.h @@ -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 read(CollectionRef c, diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index ab4adfd35275..81f584cf4e0e 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -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; diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index c29ab84667c2..c76da4e3c49c 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -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();