diff --git a/backport-DRBDmon-Add-CLOSE-command.patch b/backport-DRBDmon-Add-CLOSE-command.patch new file mode 100644 index 0000000000000000000000000000000000000000..3ac64afa5d7207385f73e60dd502e6fc053ffe6c --- /dev/null +++ b/backport-DRBDmon-Add-CLOSE-command.patch @@ -0,0 +1,95 @@ +From 60e1c2157d5386209ec5bfaa14109f9489f6089f Mon Sep 17 00:00:00 2001 +From: Robert Altnoeder +Date: Tue, 20 Feb 2024 15:49:24 +0100 +Subject: [PATCH 070/100] DRBDmon: Add /CLOSE command + +--- + user/drbdmon/terminal/GlobalCommandConsts.cpp | 1 + + user/drbdmon/terminal/GlobalCommandConsts.h | 1 + + user/drbdmon/terminal/GlobalCommandsImpl.cpp | 13 ++++++++++++- + user/drbdmon/terminal/GlobalCommandsImpl.h | 2 ++ + 4 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/user/drbdmon/terminal/GlobalCommandConsts.cpp b/user/drbdmon/terminal/GlobalCommandConsts.cpp +index 8c692878..70a8fe36 100644 +--- a/user/drbdmon/terminal/GlobalCommandConsts.cpp ++++ b/user/drbdmon/terminal/GlobalCommandConsts.cpp +@@ -16,4 +16,5 @@ namespace cmd_names + const std::string KEY_CMD_RESOURCE("RESOURCE"); + const std::string KEY_CMD_CONNECTION("CONNECTION"); + const std::string KEY_CMD_VOLUME("VOLUME"); ++ const std::string KEY_CMD_CLOSE("CLOSE"); + } +diff --git a/user/drbdmon/terminal/GlobalCommandConsts.h b/user/drbdmon/terminal/GlobalCommandConsts.h +index a55974a7..ccf1fd36 100644 +--- a/user/drbdmon/terminal/GlobalCommandConsts.h ++++ b/user/drbdmon/terminal/GlobalCommandConsts.h +@@ -19,6 +19,7 @@ namespace cmd_names + extern const std::string KEY_CMD_RESOURCE; + extern const std::string KEY_CMD_CONNECTION; + extern const std::string KEY_CMD_VOLUME; ++ extern const std::string KEY_CMD_CLOSE; + } + + #endif /* GLOBALCOMMANDCONSTS_H */ +diff --git a/user/drbdmon/terminal/GlobalCommandsImpl.cpp b/user/drbdmon/terminal/GlobalCommandsImpl.cpp +index ab549e1d..6d772b07 100644 +--- a/user/drbdmon/terminal/GlobalCommandsImpl.cpp ++++ b/user/drbdmon/terminal/GlobalCommandsImpl.cpp +@@ -25,7 +25,8 @@ GlobalCommandsImpl::GlobalCommandsImpl(ComponentsHub& comp_hub, Configuration& c + entry_cursor(&cmd_names::KEY_CMD_CURSOR, &GlobalCommandsImpl::local_command), + entry_resource(&cmd_names::KEY_CMD_RESOURCE, &GlobalCommandsImpl::cmd_resource), + entry_connection(&cmd_names::KEY_CMD_CONNECTION, &GlobalCommandsImpl::cmd_connection), +- entry_volume(&cmd_names::KEY_CMD_VOLUME, &GlobalCommandsImpl::cmd_volume) ++ entry_volume(&cmd_names::KEY_CMD_VOLUME, &GlobalCommandsImpl::cmd_volume), ++ entry_close(&cmd_names::KEY_CMD_CLOSE, &GlobalCommandsImpl::cmd_close) + { + add_command(entry_exit); + add_command(entry_display); +@@ -40,6 +41,7 @@ GlobalCommandsImpl::GlobalCommandsImpl(ComponentsHub& comp_hub, Configuration& c + add_command(entry_resource); + add_command(entry_connection); + add_command(entry_volume); ++ add_command(entry_close); + } + + GlobalCommandsImpl::~GlobalCommandsImpl() noexcept +@@ -303,6 +305,15 @@ bool GlobalCommandsImpl::cmd_volume(const std::string& command, StringTokenizer& + return accepted; + } + ++bool GlobalCommandsImpl::cmd_close(const std::string& command, StringTokenizer& tokenizer) ++{ ++ bool accepted = true; ++ ++ dsp_comp_hub.dsp_selector->leave_display(); ++ ++ return accepted; ++} ++ + // Dummy method for display local commands + bool GlobalCommandsImpl::local_command(const std::string& command, StringTokenizer& tokenizer) + { +diff --git a/user/drbdmon/terminal/GlobalCommandsImpl.h b/user/drbdmon/terminal/GlobalCommandsImpl.h +index aa72863c..564693c9 100644 +--- a/user/drbdmon/terminal/GlobalCommandsImpl.h ++++ b/user/drbdmon/terminal/GlobalCommandsImpl.h +@@ -36,6 +36,7 @@ class GlobalCommandsImpl : public GlobalCommands, public CommandsBase +Date: Fri, 23 Feb 2024 15:49:57 +0100 +Subject: [PATCH 072/100] DRBDmon: Add debug log displays + +--- + user/drbdmon/DrbdMon.cpp | 1 + + user/drbdmon/terminal/ComponentsHub.cpp | 1 + + user/drbdmon/terminal/ComponentsHub.h | 1 + + user/drbdmon/terminal/DisplayController.cpp | 18 ++- + user/drbdmon/terminal/DisplayController.h | 3 + + user/drbdmon/terminal/DisplayId.cpp | 2 + + user/drbdmon/terminal/DisplayId.h | 4 + + user/drbdmon/terminal/DisplayIdMap.cpp | 4 + + user/drbdmon/terminal/DisplayIdMap.h | 2 + + user/drbdmon/terminal/MDspLogViewer.cpp | 136 +++++++++++++------- + user/drbdmon/terminal/MDspLogViewer.h | 10 +- + user/drbdmon/terminal/MDspMessage.cpp | 15 ++- + user/drbdmon/terminal/MDspMessage.h | 5 +- + user/drbdmon/terminal/SharedData.cpp | 2 + + user/drbdmon/terminal/SharedData.h | 3 + + 15 files changed, 148 insertions(+), 59 deletions(-) + +diff --git a/user/drbdmon/DrbdMon.cpp b/user/drbdmon/DrbdMon.cpp +index 9703e6f7..2d27f2a0 100644 +--- a/user/drbdmon/DrbdMon.cpp ++++ b/user/drbdmon/DrbdMon.cpp +@@ -163,6 +163,7 @@ void DrbdMon::run() + rsc_map, + prb_rsc_map, + log, ++ debug_log, + config, + node_name + ); +diff --git a/user/drbdmon/terminal/ComponentsHub.cpp b/user/drbdmon/terminal/ComponentsHub.cpp +index c699f952..94443ccd 100644 +--- a/user/drbdmon/terminal/ComponentsHub.cpp ++++ b/user/drbdmon/terminal/ComponentsHub.cpp +@@ -46,6 +46,7 @@ void ComponentsHub::verify() const + rsc_map == nullptr || + prb_rsc_map == nullptr || + log == nullptr || ++ debug_log == nullptr || + node_name == nullptr || + ansi_ctl == nullptr || + style_coll == nullptr || +diff --git a/user/drbdmon/terminal/ComponentsHub.h b/user/drbdmon/terminal/ComponentsHub.h +index 38b091c3..28f36a2b 100644 +--- a/user/drbdmon/terminal/ComponentsHub.h ++++ b/user/drbdmon/terminal/ComponentsHub.h +@@ -37,6 +37,7 @@ class ComponentsHub + ResourcesMap* rsc_map {nullptr}; + ResourcesMap* prb_rsc_map {nullptr}; + MessageLog* log {nullptr}; ++ MessageLog* debug_log {nullptr}; + GlobalCommands* global_cmd_exec {nullptr}; + DrbdCommands* drbd_cmd_exec {nullptr}; + const Configuration* config {nullptr}; +diff --git a/user/drbdmon/terminal/DisplayController.cpp b/user/drbdmon/terminal/DisplayController.cpp +index 26f67790..6d44e956 100644 +--- a/user/drbdmon/terminal/DisplayController.cpp ++++ b/user/drbdmon/terminal/DisplayController.cpp +@@ -46,6 +46,7 @@ DisplayController::DisplayController( + ResourcesMap& rsc_map_ref, + ResourcesMap& prb_rsc_map_ref, + MessageLog& log_ref, ++ MessageLog& debug_log_ref, + Configuration& config_ref, + const std::string* const node_name_ptr + ): +@@ -73,6 +74,7 @@ DisplayController::DisplayController( + dsp_comp_hub_mgr->rsc_map = &rsc_map_ref; + dsp_comp_hub_mgr->prb_rsc_map = &prb_rsc_map_ref; + dsp_comp_hub_mgr->log = &log_ref; ++ dsp_comp_hub_mgr->debug_log = &debug_log_ref; + dsp_comp_hub_mgr->node_name = node_name_ptr; + dsp_comp_hub_mgr->style_coll = dsp_styles_mgr.get(); + dsp_comp_hub_mgr->ansi_ctl = ansi_ctl_mgr.get(); +@@ -226,10 +228,16 @@ DisplayController::DisplayController( + dynamic_cast (new MDspHelp(dsp_comp_hub)) + ); + log_view_mgr = std::unique_ptr( +- dynamic_cast (new MDspLogViewer(dsp_comp_hub)) ++ dynamic_cast (new MDspLogViewer(dsp_comp_hub, log_ref)) ++ ); ++ debug_log_view_mgr = std::unique_ptr( ++ dynamic_cast (new MDspLogViewer(dsp_comp_hub, debug_log_ref)) + ); + msg_view_mgr = std::unique_ptr( +- dynamic_cast (new MDspMessage(dsp_comp_hub)) ++ dynamic_cast (new MDspMessage(dsp_comp_hub, log_ref)) ++ ); ++ debug_msg_view_mgr = std::unique_ptr( ++ dynamic_cast (new MDspMessage(dsp_comp_hub, debug_log_ref)) + ); + pgm_info_mgr = std::unique_ptr( + dynamic_cast (new MDspPgmInfo(dsp_comp_hub)) +@@ -736,9 +744,15 @@ void DisplayController::get_display( + case DisplayId::display_page::LOG_VIEWER: + dsp_obj = log_view_mgr.get(); + break; ++ case DisplayId::display_page::DEBUG_LOG_VIEWER: ++ dsp_obj = debug_log_view_mgr.get(); ++ break; + case DisplayId::display_page::MSG_VIEWER: + dsp_obj = msg_view_mgr.get(); + break; ++ case DisplayId::display_page::DEBUG_MSG_VIEWER: ++ dsp_obj = debug_msg_view_mgr.get(); ++ break; + case DisplayId::display_page::RSC_ACTIONS: + dsp_obj = resource_actions_mgr.get(); + break; +diff --git a/user/drbdmon/terminal/DisplayController.h b/user/drbdmon/terminal/DisplayController.h +index 6c758ba2..2108faba 100644 +--- a/user/drbdmon/terminal/DisplayController.h ++++ b/user/drbdmon/terminal/DisplayController.h +@@ -53,6 +53,7 @@ class DisplayController : public GenericDisplay, public DisplaySelector + ResourcesMap& rsc_map_ref, + ResourcesMap& prb_rsc_map_ref, + MessageLog& log_ref, ++ MessageLog& debug_log_ref, + Configuration& config_ref, + const std::string* const node_name_ptr + ); +@@ -131,7 +132,9 @@ class DisplayController : public GenericDisplay, public DisplaySelector + std::unique_ptr help_idx_mgr; + std::unique_ptr help_view_mgr; + std::unique_ptr log_view_mgr; ++ std::unique_ptr debug_log_view_mgr; + std::unique_ptr msg_view_mgr; ++ std::unique_ptr debug_msg_view_mgr; + std::unique_ptr pgm_info_mgr; + std::unique_ptr config_mgr; + +diff --git a/user/drbdmon/terminal/DisplayId.cpp b/user/drbdmon/terminal/DisplayId.cpp +index 48ef18c7..9bc4f92b 100644 +--- a/user/drbdmon/terminal/DisplayId.cpp ++++ b/user/drbdmon/terminal/DisplayId.cpp +@@ -16,7 +16,9 @@ const std::string DisplayId::MDSP_TASKQ_FIN = {"FINQ"}; + const std::string DisplayId::MDSP_SYNC_LIST = {"SYNC"}; + const std::string DisplayId::MDSP_HELP_IDX = {"HELP"}; + const std::string DisplayId::MDSP_LOG_VIEW = {"LOG"}; ++const std::string DisplayId::MDSP_DEBUG_LOG_VIEW = {"DBGLOG"}; + const std::string DisplayId::MDSP_MSG_VIEW = {"MSG"}; ++const std::string DisplayId::MDSP_DEBUG_MSG_VIEW = {"DBGMSG"}; + const std::string DisplayId::MDSP_RSC_ACT = {"RSCA"}; + const std::string DisplayId::MDSP_VLM_ACT = {"VLMA"}; + const std::string DisplayId::MDSP_CON_ACT = {"CONA"}; +diff --git a/user/drbdmon/terminal/DisplayId.h b/user/drbdmon/terminal/DisplayId.h +index 48db7ff5..35b2dde4 100644 +--- a/user/drbdmon/terminal/DisplayId.h ++++ b/user/drbdmon/terminal/DisplayId.h +@@ -26,7 +26,9 @@ class DisplayId + HELP_VIEWER, + SYNC_LIST, + LOG_VIEWER, ++ DEBUG_LOG_VIEWER, + MSG_VIEWER, ++ DEBUG_MSG_VIEWER, + RSC_ACTIONS, + VLM_ACTIONS, + CON_ACTIONS, +@@ -52,7 +54,9 @@ class DisplayId + static const std::string MDSP_HELP_IDX; + static const std::string MDSP_SYNC_LIST; + static const std::string MDSP_LOG_VIEW; ++ static const std::string MDSP_DEBUG_LOG_VIEW; + static const std::string MDSP_MSG_VIEW; ++ static const std::string MDSP_DEBUG_MSG_VIEW; + static const std::string MDSP_RSC_ACT; + static const std::string MDSP_VLM_ACT; + static const std::string MDSP_CON_ACT; +diff --git a/user/drbdmon/terminal/DisplayIdMap.cpp b/user/drbdmon/terminal/DisplayIdMap.cpp +index 205086e3..8d0a3871 100644 +--- a/user/drbdmon/terminal/DisplayIdMap.cpp ++++ b/user/drbdmon/terminal/DisplayIdMap.cpp +@@ -21,7 +21,9 @@ namespace dspid + const DisplayId ID_HELP_IDX(&DisplayId::MDSP_HELP_IDX, DisplayId::display_page::HELP_IDX); + const DisplayId ID_SYNC_LIST(&DisplayId::MDSP_SYNC_LIST, DisplayId::display_page::SYNC_LIST); + const DisplayId ID_LOG_VIEW(&DisplayId::MDSP_LOG_VIEW, DisplayId::display_page::LOG_VIEWER); ++ const DisplayId ID_DEBUG_LOG_VIEW(&DisplayId::MDSP_DEBUG_LOG_VIEW, DisplayId::display_page::DEBUG_LOG_VIEWER); + const DisplayId ID_MSG_VIEW(&DisplayId::MDSP_MSG_VIEW, DisplayId::display_page::MSG_VIEWER); ++ const DisplayId ID_DEBUG_MSG_VIEW(&DisplayId::MDSP_DEBUG_MSG_VIEW, DisplayId::display_page::DEBUG_MSG_VIEWER); + const DisplayId ID_RSC_ACT(&DisplayId::MDSP_RSC_ACT, DisplayId::display_page::RSC_ACTIONS); + const DisplayId ID_VLM_ACT(&DisplayId::MDSP_VLM_ACT, DisplayId::display_page::VLM_ACTIONS); + const DisplayId ID_CON_ACT(&DisplayId::MDSP_CON_ACT, DisplayId::display_page::CON_ACTIONS); +@@ -51,7 +53,9 @@ namespace dspid + map.insert(&DisplayId::MDSP_HELP_IDX, &ID_HELP_IDX); + map.insert(&DisplayId::MDSP_SYNC_LIST, &ID_SYNC_LIST); + map.insert(&DisplayId::MDSP_LOG_VIEW, &ID_LOG_VIEW); ++ map.insert(&DisplayId::MDSP_DEBUG_LOG_VIEW, &ID_DEBUG_LOG_VIEW); + map.insert(&DisplayId::MDSP_MSG_VIEW, &ID_MSG_VIEW); ++ map.insert(&DisplayId::MDSP_DEBUG_MSG_VIEW, &ID_DEBUG_MSG_VIEW); + map.insert(&DisplayId::MDSP_RSC_ACT, &ID_RSC_ACT); + map.insert(&DisplayId::MDSP_VLM_ACT, &ID_VLM_ACT); + map.insert(&DisplayId::MDSP_CON_ACT, &ID_CON_ACT); +diff --git a/user/drbdmon/terminal/DisplayIdMap.h b/user/drbdmon/terminal/DisplayIdMap.h +index 922dbbbd..ddcc3342 100644 +--- a/user/drbdmon/terminal/DisplayIdMap.h ++++ b/user/drbdmon/terminal/DisplayIdMap.h +@@ -25,7 +25,9 @@ namespace dspid + extern const DisplayId ID_SYNC_LIST; + extern const DisplayId ID_HELP_IDX; + extern const DisplayId ID_LOG_VIEW; ++ extern const DisplayId ID_DEBUG_LOG_VIEW; + extern const DisplayId ID_MSG_VIEW; ++ extern const DisplayId ID_DEBUG_MSG_VIEW; + extern const DisplayId ID_RSC_ACT; + extern const DisplayId ID_VLM_ACT; + extern const DisplayId ID_CON_ACT; +diff --git a/user/drbdmon/terminal/MDspLogViewer.cpp b/user/drbdmon/terminal/MDspLogViewer.cpp +index ceeece73..047c12ec 100644 +--- a/user/drbdmon/terminal/MDspLogViewer.cpp ++++ b/user/drbdmon/terminal/MDspLogViewer.cpp +@@ -10,8 +10,9 @@ + const uint8_t MDspLogViewer::LOG_HEADER_Y = 3; + const uint8_t MDspLogViewer::LOG_LIST_Y = 4; + +-MDspLogViewer::MDspLogViewer(const ComponentsHub& comp_hub): +- MDspStdListBase::MDspStdListBase(comp_hub) ++MDspLogViewer::MDspLogViewer(const ComponentsHub& comp_hub, MessageLog& log_ref): ++ MDspStdListBase::MDspStdListBase(comp_hub), ++ log(log_ref) + { + log_key_func = + [](MessageLog::Entry* msg_entry) -> const uint64_t& +@@ -26,27 +27,30 @@ MDspLogViewer::~MDspLogViewer() noexcept + + void MDspLogViewer::display_list() + { +- dsp_comp_hub.dsp_common->display_page_id(DisplayId::MDSP_LOG_VIEW); ++ dsp_comp_hub.dsp_common->display_page_id( ++ (&log == dsp_comp_hub.debug_log) ? DisplayId::MDSP_DEBUG_LOG_VIEW : DisplayId::MDSP_LOG_VIEW ++ ); + display_log_header(); + +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + + const uint32_t lines_per_page = get_lines_per_page(); +- MessageLog::Queue::ValuesIterator msg_iter = dsp_comp_hub.log->iterator(); ++ MessageLog::Queue::ValuesIterator msg_iter = log.iterator(); + if (msg_iter.get_size() >= 1) + { + const bool selecting = is_selecting(); + if (is_cursor_nav()) + { + uint32_t msg_idx = 0; ++ const uint64_t& message_id = get_message_id(); + MessageLog::Entry* const first_entry = navigation::find_first_item_on_cursor_page( +- dsp_comp_hub.dsp_shared->message_id, log_key_func, msg_iter, lines_per_page, msg_idx ++ message_id, log_key_func, msg_iter, lines_per_page, msg_idx + ); + + if (first_entry != nullptr) + { + const uint64_t first_entry_id = first_entry->get_id(); +- MessageLog::Queue::ValuesIterator dsp_msg_iter = dsp_comp_hub.log->iterator(first_entry_id); ++ MessageLog::Queue::ValuesIterator dsp_msg_iter = log.iterator(first_entry_id); + uint32_t current_line = LOG_LIST_Y; + uint32_t line_ctr = 0; + while (dsp_msg_iter.has_next() && line_ctr < lines_per_page) +@@ -94,9 +98,12 @@ bool MDspLogViewer::key_pressed(const uint32_t key) + { + if (key == KeyCodes::ENTER) + { +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ const uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { +- dsp_comp_hub.dsp_selector->switch_to_display(DisplayId::display_page::MSG_VIEWER); ++ DisplayId::display_page msg_dsp = (&log == dsp_comp_hub.debug_log) ? ++ DisplayId::display_page::DEBUG_MSG_VIEWER : DisplayId::display_page::MSG_VIEWER; ++ dsp_comp_hub.dsp_selector->switch_to_display(msg_dsp); + } + intercepted = true; + } +@@ -105,27 +112,29 @@ bool MDspLogViewer::key_pressed(const uint32_t key) + { + if (is_selecting()) + { ++ MessageMap& selection_map = get_selected_log_entries(); + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- MessageMap::KeysIterator iter(*(dsp_comp_hub.dsp_shared->selected_log_entries)); ++ MessageMap::KeysIterator iter(selection_map); + while (iter.has_next()) + { + const uint64_t* const entry_id_ptr = iter.next(); + const uint64_t entry_id = *entry_id_ptr; +- dsp_comp_hub.log->delete_entry(entry_id); ++ log.delete_entry(entry_id); + } + } +- dsp_comp_hub.dsp_shared->clear_log_entry_selection(*(dsp_comp_hub.dsp_shared->selected_log_entries)); ++ dsp_comp_hub.dsp_shared->clear_log_entry_selection(selection_map); + cursor_to_nearest_item(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + else + if (is_cursor_nav()) + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- dsp_comp_hub.log->delete_entry(dsp_comp_hub.dsp_shared->message_id); ++ const uint64_t& message_id = get_message_id(); ++ log.delete_entry(message_id); + cursor_to_nearest_item(); + dsp_comp_hub.dsp_selector->refresh_display(); + } +@@ -164,9 +173,9 @@ void MDspLogViewer::list_item_clicked(MouseEvent& mouse) + const uint32_t lines_per_page = get_lines_per_page(); + const uint32_t selected_line = mouse.coord_row - LOG_LIST_Y; + +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- MessageLog::Queue::ValuesIterator msg_iter = dsp_comp_hub.log->iterator(); ++ MessageLog::Queue::ValuesIterator msg_iter = log.iterator(); + navigation::find_first_item_on_page(get_page_nr(), get_line_offset(), lines_per_page, msg_iter); + uint32_t line_ctr = 0; + while (msg_iter.has_next() && line_ctr <= selected_line) +@@ -174,7 +183,8 @@ void MDspLogViewer::list_item_clicked(MouseEvent& mouse) + MessageLog::Entry* const msg_entry = msg_iter.next(); + if (line_ctr == selected_line) + { +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ uint64_t& message_id = get_message_id(); ++ message_id = msg_entry->get_id(); + if (mouse.button == MouseEvent::button_id::BUTTON_01 && + mouse.coord_column <= DisplayConsts::MAX_SELECT_X) + { +@@ -208,7 +218,8 @@ void MDspLogViewer::display_deactivated() + void MDspLogViewer::reset_display() + { + MDspStdListBase::reset_display(); +- dsp_comp_hub.dsp_shared->message_id = MessageLog::ID_NONE; ++ uint64_t& message_id = get_message_id(); ++ message_id = MessageLog::ID_NONE; + } + + void MDspLogViewer::synchronize_data() +@@ -217,24 +228,25 @@ void MDspLogViewer::synchronize_data() + + void MDspLogViewer::cursor_to_next_item() + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { +- MessageLog::Entry* msg_entry = dsp_comp_hub.log->get_next_entry(dsp_comp_hub.dsp_shared->message_id); ++ MessageLog::Entry* msg_entry = log.get_next_entry(message_id); + if (msg_entry != nullptr) + { +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ message_id = msg_entry->get_id(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + } + else + { +- MessageLog::Queue::ValuesIterator msg_iter = dsp_comp_hub.log->iterator(); ++ MessageLog::Queue::ValuesIterator msg_iter = log.iterator(); + if (msg_iter.has_next()) + { + MessageLog::Entry* const msg_entry = msg_iter.next(); +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ message_id = msg_entry->get_id(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + } +@@ -242,24 +254,25 @@ void MDspLogViewer::cursor_to_next_item() + + void MDspLogViewer::cursor_to_previous_item() + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { +- MessageLog::Entry* msg_entry = dsp_comp_hub.log->get_previous_entry(dsp_comp_hub.dsp_shared->message_id); ++ MessageLog::Entry* msg_entry = log.get_previous_entry(message_id); + if (msg_entry != nullptr) + { +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ message_id = msg_entry->get_id(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + } + else + { +- MessageLog::Queue::ValuesIterator msg_iter = dsp_comp_hub.log->iterator(); ++ MessageLog::Queue::ValuesIterator msg_iter = log.iterator(); + if (msg_iter.has_next()) + { + MessageLog::Entry* const msg_entry = msg_iter.next(); +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ message_id = msg_entry->get_id(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + } +@@ -290,51 +303,56 @@ void MDspLogViewer::display_log_header() + + bool MDspLogViewer::is_cursor_nav() + { +- return dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE; ++ const uint64_t& message_id = get_message_id(); ++ return message_id != MessageLog::ID_NONE; + } + + void MDspLogViewer::reset_cursor_position() + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- MessageLog::Queue::ValuesIterator msg_iter = dsp_comp_hub.log->iterator(); ++ MessageLog::Queue::ValuesIterator msg_iter = log.iterator(); + + navigation::find_first_item_on_page(get_page_nr(), get_line_offset(), get_lines_per_page(), msg_iter); + if (msg_iter.has_next()) + { + MessageLog::Entry* const msg_entry = msg_iter.next(); +- dsp_comp_hub.dsp_shared->message_id = msg_entry->get_id(); ++ uint64_t& message_id = get_message_id(); ++ message_id = msg_entry->get_id(); + dsp_comp_hub.dsp_selector->refresh_display(); + } + } + + void MDspLogViewer::clear_cursor() + { +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { + dsp_comp_hub.dsp_selector->refresh_display(); + } +- dsp_comp_hub.dsp_shared->message_id = MessageLog::ID_NONE; ++ message_id = MessageLog::ID_NONE; + } + + bool MDspLogViewer::is_selecting() + { +- return dsp_comp_hub.dsp_shared->have_log_entry_selection(*(dsp_comp_hub.dsp_shared->selected_log_entries)); ++ MessageMap& selection_map = get_selected_log_entries(); ++ return dsp_comp_hub.dsp_shared->have_log_entry_selection(selection_map); + } + + void MDspLogViewer::toggle_select_cursor_item() + { +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ const uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { +- dsp_comp_hub.dsp_shared->toggle_log_entry_selection( +- *(dsp_comp_hub.dsp_shared->selected_log_entries), dsp_comp_hub.dsp_shared->message_id +- ); ++ MessageMap& selection_map = get_selected_log_entries(); ++ dsp_comp_hub.dsp_shared->toggle_log_entry_selection(selection_map, message_id); + } + } + + void MDspLogViewer::clear_selection() + { +- dsp_comp_hub.dsp_shared->clear_log_entry_selection(*(dsp_comp_hub.dsp_shared->selected_log_entries)); ++ MessageMap& selection_map = get_selected_log_entries(); ++ dsp_comp_hub.dsp_shared->clear_log_entry_selection(selection_map); + } + + void MDspLogViewer::write_log_line(MessageLog::Entry* const msg_entry, const bool selecting, uint32_t& current_line) +@@ -343,9 +361,13 @@ void MDspLogViewer::write_log_line(MessageLog::Entry* const msg_entry, const boo + + dsp_io->cursor_xy(1, current_line); + const uint64_t message_id = msg_entry->get_id(); +- const bool is_under_cursor = message_id == dsp_comp_hub.dsp_shared->message_id; ++ ++ const uint64_t& cursor_message_id = get_message_id(); ++ const bool is_under_cursor = message_id == cursor_message_id; ++ ++ MessageMap& selection_map = get_selected_log_entries(); + const bool is_selected = selecting && dsp_comp_hub.dsp_shared->is_log_entry_selected( +- *(dsp_comp_hub.dsp_shared->selected_log_entries), msg_entry->get_id() ++ selection_map, msg_entry->get_id() + ); + + const std::string& rst_bg = is_under_cursor ? +@@ -408,18 +430,18 @@ void MDspLogViewer::cursor_to_nearest_item() + { + if (is_cursor_nav()) + { +- const uint64_t cursor_message_id = dsp_comp_hub.dsp_shared->message_id; +- if (cursor_message_id != MessageLog::ID_NONE) ++ uint64_t& message_id = get_message_id(); ++ if (message_id != MessageLog::ID_NONE) + { +- MessageLog::Entry* const near_entry = dsp_comp_hub.log->get_entry_near(cursor_message_id); ++ MessageLog::Entry* const near_entry = log.get_entry_near(message_id); + if (near_entry != nullptr) + { +- dsp_comp_hub.dsp_shared->message_id = near_entry->get_id(); ++ message_id = near_entry->get_id(); + } + else + { + // No items, cancel cursor navigation +- dsp_comp_hub.dsp_shared->message_id = MessageLog::ID_NONE; ++ message_id = MessageLog::ID_NONE; + set_page_nr(1); + } + dsp_comp_hub.dsp_selector->refresh_display(); +@@ -431,3 +453,17 @@ uint64_t MDspLogViewer::get_update_mask() noexcept + { + return update_event::UPDATE_FLAG_MESSAGE_LOG; + } ++ ++uint64_t& MDspLogViewer::get_message_id() noexcept ++{ ++ return (&log == dsp_comp_hub.debug_log) ? ++ dsp_comp_hub.dsp_shared->debug_message_id : dsp_comp_hub.dsp_shared->message_id; ++} ++ ++MessageMap& MDspLogViewer::get_selected_log_entries() noexcept ++{ ++ MessageMap* const map = (&log == dsp_comp_hub.debug_log) ? ++ dsp_comp_hub.dsp_shared->selected_debug_log_entries.get() : ++ dsp_comp_hub.dsp_shared->selected_log_entries.get(); ++ return *map; ++} +diff --git a/user/drbdmon/terminal/MDspLogViewer.h b/user/drbdmon/terminal/MDspLogViewer.h +index 58eeef46..b4a8e8be 100644 +--- a/user/drbdmon/terminal/MDspLogViewer.h ++++ b/user/drbdmon/terminal/MDspLogViewer.h +@@ -2,6 +2,8 @@ + #define MDSPLOGVIEWER_H + + #include ++#include ++#include + #include + #include + +@@ -13,7 +15,7 @@ class MDspLogViewer : public MDspStdListBase + static const uint8_t LOG_HEADER_Y; + static const uint8_t LOG_LIST_Y; + +- MDspLogViewer(const ComponentsHub& comp_hub); ++ MDspLogViewer(const ComponentsHub& comp_hub, MessageLog& log_ref); + virtual ~MDspLogViewer() noexcept; + + virtual void display_list() override; +@@ -39,11 +41,17 @@ class MDspLogViewer : public MDspStdListBase + virtual uint64_t get_update_mask() noexcept override; + + private: ++ MessageLog& log; ++ + uint32_t get_lines_per_page() noexcept; + void list_item_clicked(MouseEvent& mouse); + void display_log_header(); + void write_log_line(MessageLog::Entry* const msg_entry, const bool selecting, uint32_t& current_line); + void cursor_to_nearest_item(); ++ // Returns a reference to the message ID that is shared between displays ++ uint64_t& get_message_id() noexcept; ++ // Returns a reference to the map of selected log entries ++ MessageMap& get_selected_log_entries() noexcept; + }; + + #endif /* MDSPLOGVIEWER_H */ +diff --git a/user/drbdmon/terminal/MDspMessage.cpp b/user/drbdmon/terminal/MDspMessage.cpp +index 5b4940a3..c20a47ee 100644 +--- a/user/drbdmon/terminal/MDspMessage.cpp ++++ b/user/drbdmon/terminal/MDspMessage.cpp +@@ -6,8 +6,9 @@ + + const uint16_t MDspMessage::MAX_MSG_TEXT_WIDTH = 160; + +-MDspMessage::MDspMessage(const ComponentsHub& comp_hub): ++MDspMessage::MDspMessage(const ComponentsHub& comp_hub, MessageLog& log_ref): + MDspBase::MDspBase(comp_hub), ++ log(log_ref), + format_text(comp_hub) + { + } +@@ -18,7 +19,9 @@ MDspMessage::~MDspMessage() noexcept + + void MDspMessage::display_content() + { +- dsp_comp_hub.dsp_common->display_page_id(DisplayId::MDSP_MSG_VIEW); ++ dsp_comp_hub.dsp_common->display_page_id( ++ (&log == dsp_comp_hub.debug_log) ? DisplayId::MDSP_DEBUG_MSG_VIEW : DisplayId::MDSP_MSG_VIEW ++ ); + + uint32_t current_line = DisplayConsts::PAGE_NAV_Y + 1; + if (have_message) +@@ -165,11 +168,13 @@ void MDspMessage::display_activated() + saved_term_rows = 0; + have_message = false; + +- if (dsp_comp_hub.dsp_shared->message_id != MessageLog::ID_NONE) ++ const uint64_t message_id = (&log == dsp_comp_hub.debug_log) ? ++ dsp_comp_hub.dsp_shared->debug_message_id : dsp_comp_hub.dsp_shared->message_id; ++ if (message_id != MessageLog::ID_NONE) + { +- std::unique_lock lock(dsp_comp_hub.log->queue_lock); ++ std::unique_lock lock(log.queue_lock); + +- MessageLog::Entry* log_entry = dsp_comp_hub.log->get_entry(dsp_comp_hub.dsp_shared->message_id); ++ MessageLog::Entry* log_entry = log.get_entry(message_id); + if (log_entry != nullptr) + { + level = log_entry->get_log_level(); +diff --git a/user/drbdmon/terminal/MDspMessage.h b/user/drbdmon/terminal/MDspMessage.h +index 56d3a35e..f590c92d 100644 +--- a/user/drbdmon/terminal/MDspMessage.h ++++ b/user/drbdmon/terminal/MDspMessage.h +@@ -2,6 +2,7 @@ + #define MDSPMESSAGE_H + + #include ++#include + #include + #include + #include +@@ -11,7 +12,7 @@ class MDspMessage : public MDspBase + public: + static const uint16_t MAX_MSG_TEXT_WIDTH; + +- MDspMessage(const ComponentsHub& comp_hub); ++ MDspMessage(const ComponentsHub& comp_hub, MessageLog& log_ref); + virtual ~MDspMessage() noexcept; + + virtual void display_content() override; +@@ -35,6 +36,8 @@ class MDspMessage : public MDspBase + virtual uint64_t get_update_mask() noexcept override; + + private: ++ MessageLog& log; ++ + uint16_t saved_term_cols {0}; + uint16_t saved_term_rows {0}; + TextColumn format_text; +diff --git a/user/drbdmon/terminal/SharedData.cpp b/user/drbdmon/terminal/SharedData.cpp +index 9eb37d02..d98be3be 100644 +--- a/user/drbdmon/terminal/SharedData.cpp ++++ b/user/drbdmon/terminal/SharedData.cpp +@@ -14,6 +14,7 @@ SharedData::SharedData() + selected_finq_entries = std::unique_ptr(new TaskEntryMap(&comparators::compare)); + + selected_log_entries = std::unique_ptr(new MessageMap(&comparators::compare)); ++ selected_debug_log_entries = std::unique_ptr(new MessageMap(&comparators::compare)); + } + + SharedData::~SharedData() noexcept +@@ -29,6 +30,7 @@ SharedData::~SharedData() noexcept + generic_id_clear_selection(*selected_finq_entries); + + generic_id_clear_selection(*selected_log_entries); ++ generic_id_clear_selection(*selected_debug_log_entries); + } + + void SharedData::update_monitor_rsc(const std::string& rsc_name) +diff --git a/user/drbdmon/terminal/SharedData.h b/user/drbdmon/terminal/SharedData.h +index 7dd0b0e8..4fdffd20 100644 +--- a/user/drbdmon/terminal/SharedData.h ++++ b/user/drbdmon/terminal/SharedData.h +@@ -24,6 +24,8 @@ class SharedData + uint16_t monitor_peer_vlm {DisplayConsts::VLM_NONE}; + // The selected message in the message log + uint64_t message_id {MessageLog::ID_NONE}; ++ // The selected message in the debug message log ++ uint64_t debug_message_id {MessageLog::ID_NONE}; + // The selected task for a task details display + uint64_t task_id {SubProcessQueue::TASKQ_NONE}; + +@@ -45,6 +47,7 @@ class SharedData + std::unique_ptr selected_finq_entries; + + std::unique_ptr selected_log_entries; ++ std::unique_ptr selected_debug_log_entries; + + bool activate_tasks {true}; + +-- +2.33.1.windows.1 + diff --git a/backport-DRBDmon-Update-command-description-for-invalidate-im.patch b/backport-DRBDmon-Update-command-description-for-invalidate-im.patch new file mode 100644 index 0000000000000000000000000000000000000000..4183661d45ea72cca96d34d68ea00eaee407524c --- /dev/null +++ b/backport-DRBDmon-Update-command-description-for-invalidate-im.patch @@ -0,0 +1,42 @@ +From 1a53ed8213d6acbdd4d51ff675addca99ebcd0a0 Mon Sep 17 00:00:00 2001 +From: Robert Altnoeder +Date: Tue, 20 Feb 2024 16:26:50 +0100 +Subject: [PATCH 071/100] DRBDmon: Update command description for invalidate, + improved clarity + +--- + user/drbdmon/terminal/MDspResourceActions.cpp | 3 ++- + user/drbdmon/terminal/MDspVolumeActions.cpp | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/user/drbdmon/terminal/MDspResourceActions.cpp b/user/drbdmon/terminal/MDspResourceActions.cpp +index 621a8019..1fab05e8 100644 +--- a/user/drbdmon/terminal/MDspResourceActions.cpp ++++ b/user/drbdmon/terminal/MDspResourceActions.cpp +@@ -530,8 +530,9 @@ void MDspResourceActions::action_invalidate(const std::string& rsc_name) + + std::string text; + text.reserve(DisplayConsts::ACTION_DESC_PREALLOC); +- text.append("Invalidate data & resync resource "); ++ text.append("Invalidate local data, resource "); + text.append(rsc_name); ++ text.append(", all volumes"); + + command->set_description(text); + +diff --git a/user/drbdmon/terminal/MDspVolumeActions.cpp b/user/drbdmon/terminal/MDspVolumeActions.cpp +index cb949a35..63aa8f0a 100644 +--- a/user/drbdmon/terminal/MDspVolumeActions.cpp ++++ b/user/drbdmon/terminal/MDspVolumeActions.cpp +@@ -288,7 +288,7 @@ void MDspVolumeActions::action_invalidate(const std::string& rsc_name, const uin + + std::string text; + text.reserve(DisplayConsts::ACTION_DESC_PREALLOC); +- text.append("Invalidate data, resource "); ++ text.append("Invalidate local data, resource "); + text.append(rsc_name); + text.append(", volume "); + text.append(std::to_string(static_cast (vlm_nr))); +-- +2.33.1.windows.1 + diff --git a/drbd.spec b/drbd.spec index ea06a6bedf518792834ca87a18e252d823034d7f..60a7b94c73082aa38d9c274a5c3fd7a62dafb2c9 100644 --- a/drbd.spec +++ b/drbd.spec @@ -1,7 +1,7 @@ Name: drbd Summary: DRBD user-land tools and scripts Version: 9.28.0 -Release: 10 +Release: 11 Source0: http://www.linbit.com/downloads/%{name}/utils/%{name}-utils-%{version}.tar.gz Patch0: drbd-utils-9.12.2-disable_xsltproc_network_read.patch Patch1: drbd-utils-9.15.0-make_configure-workaround.patch @@ -49,6 +49,9 @@ Patch25: backport-DRBDmon-Adjust-display_activated-method.patch Patch26: backport-DRBDmon-Fix-resource-volume-selection-count-labels.patch Patch27: backport-DRBDmon-Always-prefix-completed-DRBD-commands-with-t.patch Patch28: backport-DRBDmon-Add-DRBD-commands-logic-for-peer-volume-comm.patch +Patch29: backport-DRBDmon-Add-CLOSE-command.patch +Patch30: backport-DRBDmon-Update-command-description-for-invalidate-im.patch +Patch31: backport-DRBDmon-Add-debug-log-displays.patch License: GPL-2.0-or-later ExclusiveOS: linux @@ -258,6 +261,11 @@ management utility. %systemd_preun drbd.service %changelog +* Fri Oct 18 2024 liupei - 9.28.0-11 +- DRBDmon: Add /CLOSE command +- DRBDmon: Update command description for invalidate, improved clarity +- DRBDmon: Add debug log displays + * Mon Oct 14 2024 liupei - 9.28.0-10 - DRBDmon: Fix resource & volume selection count labels - DRBDmon: Always prefix completed DRBD commands with two slashes