From: Samuel Just Date: Sat, 13 Jul 2024 03:30:00 +0000 (+0000) Subject: mon/NVMeofGwSerialize.h: tabbing, bracing, line length fixes X-Git-Tag: v20.0.0~1291^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5e013f5928c959a0eeffd9c9eecd2166bcba2ce;p=ceph.git mon/NVMeofGwSerialize.h: tabbing, bracing, line length fixes Signed-off-by: Samuel Just --- diff --git a/src/mon/NVMeofGwSerialize.h b/src/mon/NVMeofGwSerialize.h index cd7055413727..ca4b970ef44a 100755 --- a/src/mon/NVMeofGwSerialize.h +++ b/src/mon/NVMeofGwSerialize.h @@ -18,591 +18,660 @@ #define MODULE_PREFFIX "nvmeofgw " #define dout_prefix *_dout << MODULE_PREFFIX << __PRETTY_FUNCTION__ << " " -inline std::ostream& operator<<(std::ostream& os, const gw_exported_states_per_group_t value) { - switch (value) { - case gw_exported_states_per_group_t::GW_EXPORTED_OPTIMIZED_STATE: os << "OPTIMIZED "; break; - case gw_exported_states_per_group_t::GW_EXPORTED_INACCESSIBLE_STATE: os << "INACCESSIBLE "; break; - default: os << "Invalid " << (int)value << " "; - } - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const gw_states_per_group_t value) { - switch (value) { - case gw_states_per_group_t::GW_IDLE_STATE: os << "IDLE "; break; - case gw_states_per_group_t::GW_STANDBY_STATE: os << "STANDBY "; break; - case gw_states_per_group_t::GW_ACTIVE_STATE: os << "ACTIVE "; break; - case gw_states_per_group_t::GW_OWNER_WAIT_FAILBACK_PREPARED: os << "OWNER_FAILBACK_PREPARED "; break; - case gw_states_per_group_t::GW_WAIT_FAILBACK_PREPARED: os << "WAIT_FAILBACK_PREPARED "; break; - case gw_states_per_group_t::GW_WAIT_BLOCKLIST_CMPL: os << "WAIT_BLOCKLIST_CMPL "; break; - default: os << "Invalid " << (int)value << " "; - } - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const gw_availability_t value) { - switch (value) { - - case gw_availability_t::GW_CREATED: os << "CREATED"; break; - case gw_availability_t::GW_AVAILABLE: os << "AVAILABLE"; break; - case gw_availability_t::GW_UNAVAILABLE: os << "UNAVAILABLE"; break; - - default: os << "Invalid " << (int)value << " "; - } - return os; +inline std::ostream& operator<<( + std::ostream& os, const gw_exported_states_per_group_t value) { + switch (value) { + case gw_exported_states_per_group_t::GW_EXPORTED_OPTIMIZED_STATE: + os << "OPTIMIZED "; + break; + case gw_exported_states_per_group_t::GW_EXPORTED_INACCESSIBLE_STATE: + os << "INACCESSIBLE "; + break; + default: + os << "Invalid " << (int)value << " "; + } + return os; +} + +inline std::ostream& operator<<( + std::ostream& os, const gw_states_per_group_t value) { + switch (value) { + case gw_states_per_group_t::GW_IDLE_STATE: + os << "IDLE "; + break; + case gw_states_per_group_t::GW_STANDBY_STATE: + os << "STANDBY "; + break; + case gw_states_per_group_t::GW_ACTIVE_STATE: + os << "ACTIVE "; + break; + case gw_states_per_group_t::GW_OWNER_WAIT_FAILBACK_PREPARED: + os << "OWNER_FAILBACK_PREPARED "; + break; + case gw_states_per_group_t::GW_WAIT_FAILBACK_PREPARED: + os << "WAIT_FAILBACK_PREPARED "; + break; + case gw_states_per_group_t::GW_WAIT_BLOCKLIST_CMPL: + os << "WAIT_BLOCKLIST_CMPL "; + break; + default: + os << "Invalid " << (int)value << " "; + } + return os; +} + +inline std::ostream& operator<<( + std::ostream& os, const gw_availability_t value) { + switch (value) { + + case gw_availability_t::GW_CREATED: + os << "CREATED"; + break; + case gw_availability_t::GW_AVAILABLE: + os << "AVAILABLE"; + break; + case gw_availability_t::GW_UNAVAILABLE: + os << "UNAVAILABLE"; + break; + default: + os << "Invalid " << (int)value << " "; + } + return os; } inline std::ostream& operator<<(std::ostream& os, const SmState value) { - os << "SM_STATE [ "; - for (auto& state_itr: value ) - os << value.at(state_itr.first); - os << "]"; - return os; + os << "SM_STATE [ "; + for (auto& state_itr: value ) { + os << value.at(state_itr.first); + } + os << "]"; + return os; } inline std::ostream& operator<<(std::ostream& os, const BeaconNamespace value) { - os << "BeaconNamespace( anagrpid:" << value.anagrpid << ", nonce:" << value.nonce <<" )"; - return os; + os << "BeaconNamespace( anagrpid:" << value.anagrpid + << ", nonce:" << value.nonce <<" )"; + return os; } inline std::ostream& operator<<(std::ostream& os, const BeaconListener value) { - os << "BeaconListener( addrfam:" << value.address_family - << ", addr:" << value.address - << ", svcid:" << value.svcid << " )"; - return os; + os << "BeaconListener( addrfam:" << value.address_family + << ", addr:" << value.address + << ", svcid:" << value.svcid << " )"; + return os; } inline std::ostream& operator<<(std::ostream& os, const BeaconSubsystem value) { - os << "BeaconSubsystem( nqn:" << value.nqn << ", listeners [ "; - for (const auto& list: value.listeners) os << list << " "; - os << "] namespaces [ "; - for (const auto& ns: value.namespaces) os << ns << " "; - os << "] )"; - return os; + os << "BeaconSubsystem( nqn:" << value.nqn << ", listeners [ "; + for (const auto& list: value.listeners) os << list << " "; + os << "] namespaces [ "; + for (const auto& ns: value.namespaces) os << ns << " "; + os << "] )"; + return os; } inline std::ostream& operator<<(std::ostream& os, const NqnState value) { - os << "NqnState( nqn: " << value.nqn << ", " << value.ana_state << " )"; - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const NvmeGwClientState value) { - os << "NvmeGwState { group id: " << value.group_id << " gw_map_epoch " << value.gw_map_epoch << " availablilty "<< value.availability - << " GwSubsystems: [ "; - for (const auto& sub: value.subsystems) os << sub.second << " "; - os << " ] }"; + os << "NqnState( nqn: " << value.nqn << ", " << value.ana_state << " )"; + return os; +} + +inline std::ostream& operator<<( + std::ostream& os, const NvmeGwClientState value) { + os << "NvmeGwState { group id: " << value.group_id + << " gw_map_epoch " << value.gw_map_epoch + << " availablilty "<< value.availability + << " GwSubsystems: [ "; + for (const auto& sub: value.subsystems) { + os << sub.second << " "; + } + os << " ] }"; - return os; + return os; }; inline std::ostream& operator<<(std::ostream& os, const NvmeGroupKey value) { - os << "NvmeGroupKey {" << value.first << "," << value.second << "}"; - return os; + os << "NvmeGroupKey {" << value.first << "," << value.second << "}"; + return os; }; -inline std::ostream& operator<<(std::ostream& os, const NvmeGwMonClientStates value) { - os << "NvmeGwMap "; - for (auto& gw_state: value) { - os << "\n" << MODULE_PREFFIX <<" { == gw_id: " << gw_state.first << " -> " << gw_state.second << "}"; - } - os << "}"; +inline std::ostream& operator<<( + std::ostream& os, const NvmeGwMonClientStates value) { + os << "NvmeGwMap "; + for (auto& gw_state: value) { + os << "\n" << MODULE_PREFFIX <<" { == gw_id: " << gw_state.first + << " -> " << gw_state.second << "}"; + } + os << "}"; - return os; + return os; }; inline std::ostream& operator<<(std::ostream& os, const NvmeNonceVector value) { - for (auto & nonces : value) { - os << nonces << " "; - } - return os; + for (auto & nonces : value) { + os << nonces << " "; + } + return os; } inline std::ostream& operator<<(std::ostream& os, const NvmeAnaNonceMap value) { - if(value.size()) os << "\n" << MODULE_PREFFIX; - for (auto &nonce_map : value) { - os << " ana_grp: " << nonce_map.first << " [ " << nonce_map.second << "]\n"<< MODULE_PREFFIX ; - } - return os; + if (value.size()) { + os << "\n" << MODULE_PREFFIX; + } + for (auto &nonce_map : value) { + os << " ana_grp: " << nonce_map.first + << " [ " << nonce_map.second << "]\n"<< MODULE_PREFFIX; + } + return os; } -inline std::ostream& print_gw_created_t(std::ostream& os, const NvmeGwMonState value, size_t num_ana_groups) { - os << "==Internal map ==NvmeGwCreated { ana_group_id " << value.ana_grp_id << " osd_epochs: "; - for (auto& blklst_itr: value.blocklist_data) - { - os << " " << blklst_itr.first <<": " << blklst_itr.second.osd_epoch << ":" < { " << group_gws.second << " }"; - } - os << "]"; - return os; + os << "NVMeofGwMap [ Created_gws: "; + for (auto& group_gws: value.created_gws) { + os << "\n" << MODULE_PREFFIX << "{ " << group_gws.first + << " } -> { " << group_gws.second << " }"; + } + os << "]"; + return os; } inline void encode(const ana_state_t& st, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode((uint32_t)st.size(), bl); - for (const auto& gr: st) { - encode((uint32_t)gr.first, bl); - encode((uint32_t)gr.second, bl); - } - ENCODE_FINISH(bl); + ENCODE_START(1, 1, bl); + encode((uint32_t)st.size(), bl); + for (const auto& gr: st) { + encode((uint32_t)gr.first, bl); + encode((uint32_t)gr.second, bl); + } + ENCODE_FINISH(bl); } inline void decode(ana_state_t& st, ceph::buffer::list::const_iterator &bl) { - uint32_t n; - DECODE_START(1, bl); - decode(n, bl); - st.resize(n); - for (uint32_t i = 0; i < n; i++) { - uint32_t a, b; - decode(a, bl); - decode(b, bl); - st[i].first = (gw_exported_states_per_group_t)a; - st[i].second = (epoch_t)b; - } - DECODE_FINISH(bl); + uint32_t n; + DECODE_START(1, bl); + decode(n, bl); + st.resize(n); + for (uint32_t i = 0; i < n; i++) { + uint32_t a, b; + decode(a, bl); + decode(b, bl); + st[i].first = (gw_exported_states_per_group_t)a; + st[i].second = (epoch_t)b; + } + DECODE_FINISH(bl); } inline void encode(const GwSubsystems& subsystems, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode((uint32_t)subsystems.size(), bl); - for (const auto& sub: subsystems) { - encode(sub.second.nqn, bl); - encode(sub.second.ana_state, bl); - } - ENCODE_FINISH(bl); + ENCODE_START(1, 1, bl); + encode((uint32_t)subsystems.size(), bl); + for (const auto& sub: subsystems) { + encode(sub.second.nqn, bl); + encode(sub.second.ana_state, bl); + } + ENCODE_FINISH(bl); } -inline void decode(GwSubsystems& subsystems, ceph::bufferlist::const_iterator& bl) { +inline void decode( + GwSubsystems& subsystems, ceph::bufferlist::const_iterator& bl) { uint32_t num_subsystems; DECODE_START(1, bl); decode(num_subsystems, bl); subsystems.clear(); for (uint32_t i=0; i(endtime.time_since_epoch()).count(); - encode(millisecondsSinceEpoch , bl); - } - ENCODE_FINISH(bl); + ENCODE_START(1, 1, bl); + encode((uint32_t)state.data.size(), bl); + for (auto &tm_itr:state.data) { + encode((uint32_t)tm_itr.first, bl);// encode key + uint32_t tick = tm_itr.second.timer_started; + uint8_t val = tm_itr.second.timer_value; + encode(tick, bl); + encode(val, bl); + auto endtime = tm_itr.second.end_time; + // Convert the time point to milliseconds since the epoch + uint64_t millisecondsSinceEpoch = + std::chrono::duration_cast( + endtime.time_since_epoch()).count(); + encode(millisecondsSinceEpoch , bl); + } + ENCODE_FINISH(bl); } -inline void decode(NvmeGwTimerState& state, ceph::bufferlist::const_iterator& bl) { - uint32_t size; - DECODE_START(1, bl); - decode(size, bl); - for (uint32_t i = 0; i (duration); - state.data[tm_key] = tm; - } - DECODE_FINISH(bl); +inline void decode( + NvmeGwTimerState& state, ceph::bufferlist::const_iterator& bl) { + uint32_t size; + DECODE_START(1, bl); + decode(size, bl); + for (uint32_t i = 0; i (duration); + state.data[tm_key] = tm; + } + DECODE_FINISH(bl); } inline void encode(const NvmeAnaNonceMap& nonce_map, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode((uint32_t)nonce_map.size(), bl); - for (auto& ana_group_nonces : nonce_map) { - encode(ana_group_nonces.first, bl); // ana group id - encode ((uint32_t)ana_group_nonces.second.size(), bl); // encode the vector size - for (auto& nonce: ana_group_nonces.second) encode(nonce, bl); - } - ENCODE_FINISH(bl); + ENCODE_START(1, 1, bl); + encode((uint32_t)nonce_map.size(), bl); + for (auto& ana_group_nonces : nonce_map) { + // ana group id + encode(ana_group_nonces.first, bl); + // encode the vector size + encode ((uint32_t)ana_group_nonces.second.size(), bl); + for (auto& nonce: ana_group_nonces.second) encode(nonce, bl); + } + ENCODE_FINISH(bl); } -inline void decode(NvmeAnaNonceMap& nonce_map, ceph::buffer::list::const_iterator &bl) { - uint32_t map_size; - NvmeAnaGrpId ana_grp_id; - uint32_t vector_size; - std::string nonce; - DECODE_START(1, bl); - decode(map_size, bl); - for (uint32_t i = 0; i& created_gws, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode ((uint32_t)created_gws.size(), bl); // number of groups - for (auto& group_gws: created_gws) { - auto& group_key = group_gws.first; - encode(group_key.first, bl); // pool - encode(group_key.second, bl); // group +inline void decode( + NvmeGwMonStates& gws, ceph::buffer::list::const_iterator &bl) { + gws.clear(); + uint32_t num_created_gws; + DECODE_START(1, bl); + decode(num_created_gws, bl); - auto& gws = group_gws.second; - encode (gws, bl); // encode group gws - } - ENCODE_FINISH(bl); -} - -inline void decode(std::map& created_gws, ceph::buffer::list::const_iterator &bl) { - created_gws.clear(); - uint32_t ngroups; - DECODE_START(1, bl); - decode(ngroups, bl); - for (uint32_t i = 0; i& created_gws, + ceph::bufferlist &bl) { + ENCODE_START(1, 1, bl); + encode ((uint32_t)created_gws.size(), bl); // number of groups + for (auto& group_gws: created_gws) { + auto& group_key = group_gws.first; + encode(group_key.first, bl); // pool + encode(group_key.second, bl); // group + + auto& gws = group_gws.second; + encode (gws, bl); // encode group gws + } + ENCODE_FINISH(bl); } -inline void decode(NvmeGwMonClientStates& subsyst_gwmap, ceph::buffer::list::const_iterator &bl) { - subsyst_gwmap.clear(); - uint32_t num_gws; - DECODE_START(1, bl); - decode(num_gws, bl); +inline void decode( + std::map& created_gws, + ceph::buffer::list::const_iterator &bl) { + created_gws.clear(); + uint32_t ngroups; + DECODE_START(1, bl); + decode(ngroups, bl); + for (uint32_t i = 0; i& gmap, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode ((uint32_t)gmap.size(), bl); // number of groups - for (auto& group_state: gmap) { - auto& group_key = group_state.first; - encode(group_key.first, bl); // pool - encode(group_key.second, bl); // group - encode(group_state.second, bl); - } - ENCODE_FINISH(bl); +inline void encode( + const std::map& gmap, + ceph::bufferlist &bl) { + ENCODE_START(1, 1, bl); + encode ((uint32_t)gmap.size(), bl); // number of groups + for (auto& group_state: gmap) { + auto& group_key = group_state.first; + encode(group_key.first, bl); // pool + encode(group_key.second, bl); // group + encode(group_state.second, bl); + } + ENCODE_FINISH(bl); } + // Start decode NvmeGroupKey, NvmeGwMap -inline void decode(std::map& gmap, ceph::buffer::list::const_iterator &bl) { - gmap.clear(); - uint32_t ngroups; - DECODE_START(1, bl); - decode(ngroups, bl); - for (uint32_t i = 0; i& gmap, + ceph::buffer::list::const_iterator &bl) { + gmap.clear(); + uint32_t ngroups; + DECODE_START(1, bl); + decode(ngroups, bl); + for (uint32_t i = 0; i& gmetadata, ceph::bufferlist &bl) { - ENCODE_START(1, 1, bl); - encode ((uint32_t)gmetadata.size(), bl); // number of groups - for (auto& group_md: gmetadata) { - auto& group_key = group_md.first; - encode(group_key.first, bl); // pool - encode(group_key.second, bl); // group +inline void encode( + const std::map& gmetadata, + ceph::bufferlist &bl) { + ENCODE_START(1, 1, bl); + encode ((uint32_t)gmetadata.size(), bl); // number of groups + for (auto& group_md: gmetadata) { + auto& group_key = group_md.first; + encode(group_key.first, bl); // pool + encode(group_key.second, bl); // group - encode(group_md.second, bl); - } - ENCODE_FINISH(bl); -} - -inline void decode(std::map& gmetadata, ceph::buffer::list::const_iterator &bl) { - gmetadata.clear(); - uint32_t ngroups; - DECODE_START(1, bl); - decode(ngroups, bl); - for (uint32_t i = 0; i& gmetadata, + ceph::buffer::list::const_iterator &bl) { + gmetadata.clear(); + uint32_t ngroups; + DECODE_START(1, bl); + decode(ngroups, bl); + for (uint32_t i = 0; i