From bb81de5b554aa727f571fb5f74e42f2ab26cfb96 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 17 Apr 2020 19:26:29 +0300 Subject: [PATCH] os/bluestore: invoke _prepare_ondisk_format_super as the last op Fixes: https://tracker.ceph.com/issues/45133 Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index de18468d474526..6f6273d3a873a3 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -11084,6 +11084,9 @@ int BlueStore::_upgrade_super() t->rmkey(PREFIX_SUPER, "min_min_alloc_size"); } ondisk_format = 2; + + // make sure upgrade is performed within a single transaction + // hence preparing new super record here other than at the end _prepare_ondisk_format_super(t); int r = db->submit_transaction_sync(t); ceph_assert(r == 0); @@ -11096,19 +11099,23 @@ int BlueStore::_upgrade_super() // - super: added per_pool_omap key, which indicates that *all* objects // are using the new prefix and key format ondisk_format = 3; - KeyValueDB::Transaction t = db->get_transaction(); - _prepare_ondisk_format_super(t); - int r = db->submit_transaction_sync(t); - ceph_assert(r == 0); } if (ondisk_format == 3) { // changes: // - FreelistManager keeps meta within bdev label int r = _write_out_fm_meta(0); ceph_assert(r == 0); - ondisk_format = 4; } + // This to be the last operation + // Upgrade to format 2 is completed at this point, + // perform additional upgrade is needed + if (ondisk_format > 2) { + KeyValueDB::Transaction t = db->get_transaction(); + _prepare_ondisk_format_super(t); + int r = db->submit_transaction_sync(t); + ceph_assert(r == 0); + } } // done dout(1) << __func__ << " done" << dendl;