From d04b42570b167c6bcb43acc4c49b171960aa4dba Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 2 Jun 2021 20:47:03 +0800 Subject: [PATCH] crimson/osd: extract OSD::_write_superblock() out prepare for the change to verify existing meta collection and superblock stored in it. Signed-off-by: Kefu Chai --- src/crimson/osd/osd.cc | 30 +++++++++++++++++------------- src/crimson/osd/osd.h | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 28f79d2fd3042..f49446447593f 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -154,19 +154,7 @@ seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid) superblock.osd_fsid = store->get_fsid(); superblock.whoami = whoami; superblock.compat_features = get_osd_initial_compat_set(); - - logger().info( - "{} writing superblock cluster_fsid {} osd_fsid {}", - __func__, - cluster_fsid, - superblock.osd_fsid); - return store->create_new_collection(coll_t::meta()); - }).then([this] (auto ch) { - meta_coll = make_unique(ch , store.get()); - ceph::os::Transaction t; - meta_coll->create(t); - meta_coll->store_superblock(t, superblock); - return store->do_transaction(meta_coll->collection(), std::move(t)); + return _write_superblock(); }).then([cluster_fsid, this] { return when_all_succeed( store->write_meta("ceph_fsid", cluster_fsid.to_string()), @@ -179,6 +167,22 @@ seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid) }); } +seastar::future<> OSD::_write_superblock() +{ + logger().info( + "{} writing superblock cluster_fsid {} osd_fsid {}", + __func__, + superblock.cluster_fsid, + superblock.osd_fsid); + return store->create_new_collection(coll_t::meta()).then([this] (auto ch) { + meta_coll = make_unique(ch , store.get()); + ceph::os::Transaction t; + meta_coll->create(t); + meta_coll->store_superblock(t, superblock); + return store->do_transaction(meta_coll->collection(), std::move(t)); + }); +} + namespace { entity_addrvec_t pick_addresses(int what) { entity_addrvec_t addrs; diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 889960ced8d96..ebce16bf8ccf6 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -143,6 +143,7 @@ public: uint64_t send_pg_stats(); private: + seastar::future<> _write_superblock(); seastar::future<> start_boot(); seastar::future<> _preboot(version_t oldest_osdmap, version_t newest_osdmap); seastar::future<> _send_boot(); -- 2.39.5