Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755562AbbK0VcA (ORCPT ); Fri, 27 Nov 2015 16:32:00 -0500 Received: from mailrelay119.isp.belgacom.be ([195.238.20.146]:2817 "EHLO mailrelay119.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755473AbbK0V3z (ORCPT ); Fri, 27 Nov 2015 16:29:55 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B/AgC5ylhW/6YUtFtegmlSgUK8BYIaAQ2BZIYPAoE+ORQBAQEBAQEBgQqENQEBBFYjEFE5HhmIMgGycIoOAQEBByOGVIolhBIFlleNOJxhHwEBQoIRHYFXPTSFUgEBAQ From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: Philipp Reisner , Fabian Frederick , Lars Ellenberg , drbd-dev@lists.linbit.com Subject: [PATCH 15/21] drbd: introduce peer state union Date: Fri, 27 Nov 2015 22:29:30 +0100 Message-Id: <1448659775-13596-6-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448659775-13596-1-git-send-email-fabf@skynet.be> References: <1448659575-13485-1-git-send-email-fabf@skynet.be> <1448659775-13596-1-git-send-email-fabf@skynet.be> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3034 Lines: 89 Add peer structure and propagate in conn_khelper() instead of hardcoded values. Signed-off-by: Fabian Frederick --- drivers/block/drbd/drbd_nl.c | 13 +++++++------ include/linux/drbd.h | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index ef136a9..7a5f148 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -387,7 +387,8 @@ int drbd_khelper(struct drbd_device *device, char *cmd) return ret; } -static int conn_khelper(struct drbd_connection *connection, char *cmd) +static enum drbd_peer_state conn_khelper(struct drbd_connection *connection, + char *cmd) { char *envp[] = { "HOME=/", "TERM=linux", @@ -485,17 +486,17 @@ bool conn_try_outdate_peer(struct drbd_connection *connection) r = conn_khelper(connection, "fence-peer"); switch ((r>>8) & 0xff) { - case 3: /* peer is inconsistent */ + case P_INCONSISTENT: /* peer is inconsistent */ ex_to_string = "peer is inconsistent or worse"; mask.pdsk = D_MASK; val.pdsk = D_INCONSISTENT; break; - case 4: /* peer got outdated, or was already outdated */ + case P_OUTDATED: /* peer got outdated, or was already outdated */ ex_to_string = "peer was fenced"; mask.pdsk = D_MASK; val.pdsk = D_OUTDATED; break; - case 5: /* peer was down */ + case P_DOWN: /* peer was down */ if (conn_highest_disk(connection) == D_UP_TO_DATE) { /* we will(have) create(d) a new UUID anyways... */ ex_to_string = "peer is unreachable, assumed to be dead"; @@ -505,7 +506,7 @@ bool conn_try_outdate_peer(struct drbd_connection *connection) ex_to_string = "peer unreachable, doing nothing since disk != UpToDate"; } break; - case 6: /* Peer is primary, voluntarily outdate myself. + case P_PRIMARY: /* Peer is primary, voluntarily outdate myself. * This is useful when an unconnected R_SECONDARY is asked to * become R_PRIMARY, but finds the other peer being active. */ ex_to_string = "peer is active"; @@ -513,7 +514,7 @@ bool conn_try_outdate_peer(struct drbd_connection *connection) mask.disk = D_MASK; val.disk = D_OUTDATED; break; - case 7: + case P_FENCING: if (fp != FP_STONITH) drbd_err(connection, "fence-peer() = 7 && fencing != Stonith !!!\n"); ex_to_string = "peer was stonithed"; diff --git a/include/linux/drbd.h b/include/linux/drbd.h index d6b3c99..1f20a62 100644 --- a/include/linux/drbd.h +++ b/include/linux/drbd.h @@ -370,6 +370,14 @@ enum drbd_notification_type { NOTIFY_FLAGS = NOTIFY_CONTINUES, }; +enum drbd_peer_state { + P_INCONSISTENT = 3, + P_OUTDATED = 4, + P_DOWN = 5, + P_PRIMARY = 6, + P_FENCING = 7 +}; + #define UUID_JUST_CREATED ((__u64)4) enum write_ordering_e { -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/