diff --git a/kmod/src/quorum.c b/kmod/src/quorum.c index 5830deb1..fbaa31e4 100644 --- a/kmod/src/quorum.c +++ b/kmod/src/quorum.c @@ -1046,13 +1046,17 @@ static inline bool valid_ipv4_port(__be16 port) static int verify_quorum_slots(struct super_block *sb) { struct scoutfs_super_block *super = &SCOUTFS_SB(sb)->super; + struct mount_options *opts = &SCOUTFS_SB(sb)->opts; + char slots[(SCOUTFS_QUORUM_MAX_SLOTS * 3) + 1]; DECLARE_QUORUM_INFO(sb, qinf); struct sockaddr_in other; struct sockaddr_in sin; int found = 0; + int ret; int i; int j; + for (i = 0; i < SCOUTFS_QUORUM_MAX_SLOTS; i++) { if (!quorum_slot_present(super, i)) continue; @@ -1093,6 +1097,25 @@ static int verify_quorum_slots(struct super_block *sb) return -EINVAL; } + if (!quorum_slot_present(super, opts->quorum_slot_nr)) { + char *str = slots; + *str = '\0'; + for (i = 0; i < SCOUTFS_QUORUM_MAX_SLOTS; i++) { + if (quorum_slot_present(super, i)) { + ret = snprintf(str, &slots[ARRAY_SIZE(slots)] - str, "%c%u", + str == slots ? ' ' : ',', i); + if (ret < 2 || ret > 3) { + scoutfs_err(sb, "error gathering populated slots"); + return -EINVAL; + } + str += ret; + } + } + scoutfs_err(sb, "quorum_slot_nr=%u option references unused slot, must be one of the following configured slots:%s", + opts->quorum_slot_nr, slots); + return -EINVAL; + } + /* * Always require a majority except in the pathological cases of * 1 or 2 members.