From d60f920fd8d4898ad426ce04073a1ceca679addd Mon Sep 17 00:00:00 2001 From: Kleber Sacilotto de Souza Date: Mon, 11 Mar 2013 20:48:45 -0300 Subject: [PATCH] iprutils: fix wrong secondary status In some scenarios the adapters can be wrongly identified as secondaries, despite the fact that they are not connected to other adapters. The function get_dual_ioa_state() relies on the information from the cur_state field of the ipr_dual_ioa_entry struct to set the is_secondary flag, even though the query multiple adapter status returns 0 as the number of multiple adapter entries. In this case, if we use the ioa_entry struct we can wrongly change the is_secondary flag. This patch fix this issue by not changing the default multi adapter configuration when the number of multiple adapter entries is 0. Signed-off-by: Kleber Sacilotto de Souza --- iprlib.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/iprlib.c b/iprlib.c index 13fd9f4..62d039a 100644 --- a/iprlib.c +++ b/iprlib.c @@ -5681,6 +5681,7 @@ static void get_dual_ioa_state(struct ipr_ioa *ioa) sprintf(ioa->dual_state, "Primary"); sprintf(ioa->preferred_dual_state, "No Preference"); + ioa->is_secondary = 0; if (!ioa->dual_raid_support) return; @@ -5690,15 +5691,15 @@ static void get_dual_ioa_state(struct ipr_ioa *ioa) if (rc) return; - ioa_entry = (struct ipr_dual_ioa_entry *) - (((unsigned long)&ioa->ioa_status.cap) + ntohl(ioa->ioa_status.cap.length)); - if (ntohl(ioa->ioa_status.num_entries)) - print_ioa_state(ioa->dual_state, ioa_entry->cur_state); print_ioa_state(ioa->preferred_dual_state, ioa->ioa_status.cap.preferred_role); - if (ioa_entry->cur_state == IPR_IOA_STATE_SECONDARY) - ioa->is_secondary = 1; - else - ioa->is_secondary = 0; + + if (ntohl(ioa->ioa_status.num_entries)) { + ioa_entry = (struct ipr_dual_ioa_entry *) + (((unsigned long)&ioa->ioa_status.cap) + ntohl(ioa->ioa_status.cap.length)); + print_ioa_state(ioa->dual_state, ioa_entry->cur_state); + if (ioa_entry->cur_state == IPR_IOA_STATE_SECONDARY) + ioa->is_secondary = 1; + } } /**