From: Matan Breizman Date: Wed, 30 Jul 2025 15:10:48 +0000 (+0000) Subject: crimson/os/seastore: mkfs_managers() into coroutines X-Git-Tag: testing/wip-vshankar-testing-20250813.085004-debug~14^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5cdbea89f2d84ce9be64342748d394fc549bc760;p=ceph-ci.git crimson/os/seastore: mkfs_managers() into coroutines * txn is now created only once and not in each repeated iteration as before, with_repeat_trans_intr will reset the txn if needed. * in order for us to return a seastar::future, we would have to handle each and every errorator. Instead, change the return value to errorator and let the caller handle the error. * The lambda which is passed to with_trans_intr returns mkfs_iertr since this is an extended version of base_iertr. Introduce a mkfs_ertr for the reason above. Future commits would unify the new mkfs_ertr with seastore_mkfs_ertr. Signed-off-by: Matan Breizman --- diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index b0389b241dd..9f4f7582fca 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -401,52 +401,34 @@ seastar::future<> SeaStore::write_fsid(uuid_d new_osd_fsid) }); } -seastar::future<> +TransactionManager::alloc_extent_ertr::future<> SeaStore::Shard::mkfs_managers() { + LOG_PREFIX(SeaStoreS::mkfs_managers); + INFO("..."); init_managers(); - return transaction_manager->mkfs( - ).safe_then([this] { - init_managers(); - return transaction_manager->mount(); - }).safe_then([this] { - - ++(shard_stats.io_num); - ++(shard_stats.pending_io_num); - // For TM::submit_transaction() - ++(shard_stats.processing_inlock_io_num); - - return repeat_eagain([this] { - ++(shard_stats.repeat_io_num); - - return transaction_manager->with_transaction_intr( - Transaction::src_t::MUTATE, - "mkfs_seastore", - CACHE_HINT_TOUCH, - [this](auto& t) - { - LOG_PREFIX(SeaStoreS::mkfs_managers); - DEBUGT("...", t); - return onode_manager->mkfs(t - ).si_then([this, &t] { - return collection_manager->mkfs(t); - }).si_then([this, &t](auto coll_root) { - transaction_manager->write_collection_root( - t, coll_root); - return transaction_manager->submit_transaction(t); - }); - }); - }); - }).handle_error( - crimson::ct_error::assert_all{ - "Invalid error in Shard::mkfs_managers" - } - ).finally([this] { - assert(shard_stats.pending_io_num); - --(shard_stats.pending_io_num); - // XXX: it's wrong to assume no failure - --(shard_stats.processing_postlock_io_num); - }); + co_await transaction_manager->mkfs(); + init_managers(); + co_await transaction_manager->mount(); + ++(shard_stats.io_num); + ++(shard_stats.pending_io_num); + // For TM::submit_transaction() + ++(shard_stats.processing_inlock_io_num); + TransactionRef t = transaction_manager->create_transaction( + Transaction::src_t::MUTATE, "mkfs_seastore", CACHE_HINT_TOUCH); + co_await with_repeat_trans_intr(*t, + seastar::coroutine::lambda([&](auto &tr) -> TransactionManager::alloc_extent_iertr::future<> { + ++(shard_stats.repeat_io_num); + DEBUGT("...", tr); + co_await onode_manager->mkfs(tr); + auto coll_root = co_await collection_manager->mkfs(tr); + transaction_manager->write_collection_root(tr, coll_root); + co_await transaction_manager->submit_transaction(tr); + })); + assert(shard_stats.pending_io_num); + --(shard_stats.pending_io_num); + // XXX: it's wrong to assume no failure + --(shard_stats.processing_postlock_io_num); } seastar::future<> SeaStore::set_secondaries() @@ -472,11 +454,15 @@ SeaStore::mkfs_ertr::future<> SeaStore::test_mkfs(uuid_d new_osd_fsid) return seastar::now(); } return shard_stores.local().mkfs_managers( - ).then([this, new_osd_fsid] { + ).safe_then([this, new_osd_fsid] { return prepare_meta(new_osd_fsid); - }).then([FNAME] { + }).safe_then([FNAME] { INFO("done"); - }); + }).handle_error( + crimson::ct_error::assert_all{ + "Invalid error in SeaStore::mkfs" + } + ); }); } @@ -584,7 +570,8 @@ SeaStore::mkfs_ertr::future<> SeaStore::mkfs(uuid_d new_osd_fsid) return device->mount(); }).safe_then([this] { return shard_stores.invoke_on_all([] (auto &local_store) { - return local_store.mkfs_managers(); + return local_store.mkfs_managers().handle_error( + crimson::ct_error::assert_all{"Invalid error in SeaStoreS::mkfs_managers"}); }); }).safe_then([this, new_osd_fsid] { return prepare_meta(new_osd_fsid); diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index adbd4143a51..f1c80fb1361 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -23,6 +23,7 @@ #include "crimson/os/seastore/device.h" #include "crimson/os/seastore/transaction.h" +#include "crimson/os/seastore/transaction_interruptor.h" #include "crimson/os/seastore/onode_manager.h" #include "crimson/os/seastore/omap_manager.h" #include "crimson/os/seastore/collection_manager.h" @@ -204,7 +205,7 @@ public: uuid_d get_fsid() const; - seastar::future<> mkfs_managers(); + TransactionManager::alloc_extent_ertr::future<> mkfs_managers(); void init_managers(); diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index 32500343c80..26ad8b53e36 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -407,7 +407,9 @@ public: * Allocates a new block of type T with the minimum lba range of size len * greater than laddr_hint. */ - using alloc_extent_iertr = LBAManager::alloc_extent_iertr::extend< + using alloc_extent_ertr = base_ertr::extend< + crimson::ct_error::enospc>; + using alloc_extent_iertr = base_iertr::extend< crimson::ct_error::enospc>; template using alloc_extent_ret = alloc_extent_iertr::future>;