diff --git a/RHEL-5397-fence_scsi-1-fix-ISID-reg-handling.patch b/RHEL-5397-fence_scsi-1-fix-ISID-reg-handling.patch new file mode 100644 index 0000000..7110b9d --- /dev/null +++ b/RHEL-5397-fence_scsi-1-fix-ISID-reg-handling.patch @@ -0,0 +1,68 @@ +From 9d0d0d013c7edae43a4ebc5f46bf2e7a4f127654 Mon Sep 17 00:00:00 2001 +From: "sreejit.mohanan" +Date: Fri, 17 Feb 2023 18:04:03 -0800 +Subject: [PATCH] fence_scsi: fix registration handling if ISID conflicts ISID + (Initiator Session ID) belonging to I_T Nexus changes for RHEL based on the + session ID. This means that the connection to the device can be set up with + different ISID on reconnects. + +fence_scsi treats same key as a tip to ignore issuing registration +to the device but if the device was registered using a different +ISID, the key would be the same but the I_T Nexus (new ISID) would +not have access to the device. + +Fixing this by preempting the old key and replacing with the current +one. +--- + agents/scsi/fence_scsi.py | 35 ++++++++++++++++++++++++++++++++--- + 1 file changed, 32 insertions(+), 3 deletions(-) + +diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py +index f9e6823b2..85e4f29e6 100644 +--- a/agents/scsi/fence_scsi.py ++++ b/agents/scsi/fence_scsi.py +@@ -137,12 +137,41 @@ def register_dev(options, dev): + for slave in get_mpath_slaves(dev): + register_dev(options, slave) + return True +- if get_reservation_key(options, dev, False) == options["--key"]: +- return True ++ ++ # Check if any registration exists for the key already. We track this in ++ # order to decide whether the existing registration needs to be cleared. ++ # This is needed since the previous registration could be for a ++ # different I_T nexus (different ISID). ++ registration_key_exists = False ++ if options["--key"] in get_registration_keys(options, dev): ++ registration_key_exists = True ++ if not register_helper(options, options["--key"], dev): ++ return False ++ ++ if registration_key_exists: ++ # If key matches, make sure it matches with the connection that ++ # exists right now. To do this, we can issue a preempt with same key ++ # which should replace the old invalid entries from the target. ++ if not preempt(options, options["--key"], dev): ++ return False ++ ++ # If there was no reservation, we need to issue another registration ++ # since the previous preempt would clear registration made above. ++ if get_reservation_key(options, dev, False) != options["--key"]: ++ return register_helper(options, options["--key"], dev) ++ return True ++ ++# cancel registration without aborting tasks ++def preempt(options, host, dev): ++ reset_dev(options,dev) ++ cmd = options["--sg_persist-path"] + " -n -o -P -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev ++ return not bool(run_cmd(options, cmd)["rc"]) ++ ++# helper function to send the register command ++def register_helper(options, host, dev): + reset_dev(options, dev) + cmd = options["--sg_persist-path"] + " -n -o -I -S " + options["--key"] + " -d " + dev + cmd += " -Z" if "--aptpl" in options else "" +- #cmd return code != 0 but registration can be successful + return not bool(run_cmd(options, cmd)["err"]) + + diff --git a/RHEL-5397-fence_scsi-2-fix-ISID-reg-handling-off.patch b/RHEL-5397-fence_scsi-2-fix-ISID-reg-handling-off.patch new file mode 100644 index 0000000..cfafaa7 --- /dev/null +++ b/RHEL-5397-fence_scsi-2-fix-ISID-reg-handling-off.patch @@ -0,0 +1,103 @@ +From 34baef58db442148b8e067509d2cdd37b7a91ef4 Mon Sep 17 00:00:00 2001 +From: "sreejit.mohanan" +Date: Thu, 7 Sep 2023 15:57:51 -0700 +Subject: [PATCH] fence_scsi: fix registration handling in device 'off' + workflows + +ISID (Initiator Session ID) belonging to I_T Nexus changes for +RHEL based on the session ID. This means that the connection to +the device can be set up with different ISID on reconnects. + +When a device is powered off, fence_scsi assumes that the client +has a registration to the device and sends a preempt-and-abort +request which ends up failing due to reservation conflict. + +Fixing this by registering the host key with the device and preempting +the old registration (if it exists). This should make sure that the +host is able to preempt the other key successfully. +--- + agents/scsi/fence_scsi.py | 29 +++++++++++++++-------------- + 1 file changed, 15 insertions(+), 14 deletions(-) + +diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py +index 42530ceb5..519319bf5 100644 +--- a/agents/scsi/fence_scsi.py ++++ b/agents/scsi/fence_scsi.py +@@ -41,7 +41,7 @@ def set_status(conn, options): + for dev in options["devices"]: + is_block_device(dev) + +- register_dev(options, dev) ++ register_dev(options, dev, options["--key"]) + if options["--key"] not in get_registration_keys(options, dev): + count += 1 + logging.debug("Failed to register key "\ +@@ -62,7 +62,7 @@ def set_status(conn, options): + fail_usage("Failed: keys cannot be same. You can not fence yourself.") + for dev in options["devices"]: + is_block_device(dev) +- ++ register_dev(options, dev, host_key) + if options["--key"] in get_registration_keys(options, dev): + preempt_abort(options, host_key, dev) + +@@ -131,11 +131,11 @@ def reset_dev(options, dev): + return run_cmd(options, options["--sg_turs-path"] + " " + dev)["rc"] + + +-def register_dev(options, dev): ++def register_dev(options, dev, key): + dev = os.path.realpath(dev) + if re.search(r"^dm", dev[5:]): + for slave in get_mpath_slaves(dev): +- register_dev(options, slave) ++ register_dev(options, slave, key) + return True + + # Check if any registration exists for the key already. We track this in +@@ -143,34 +143,35 @@ def register_dev(options, dev): + # This is needed since the previous registration could be for a + # different I_T nexus (different ISID). + registration_key_exists = False +- if options["--key"] in get_registration_keys(options, dev): ++ if key in get_registration_keys(options, dev): ++ logging.debug("Registration key exists for device " + dev) + registration_key_exists = True +- if not register_helper(options, options["--key"], dev): ++ if not register_helper(options, dev, key): + return False + + if registration_key_exists: + # If key matches, make sure it matches with the connection that + # exists right now. To do this, we can issue a preempt with same key + # which should replace the old invalid entries from the target. +- if not preempt(options, options["--key"], dev): ++ if not preempt(options, key, dev, key): + return False + + # If there was no reservation, we need to issue another registration + # since the previous preempt would clear registration made above. +- if get_reservation_key(options, dev, False) != options["--key"]: +- return register_helper(options, options["--key"], dev) ++ if get_reservation_key(options, dev, False) != key: ++ return register_helper(options, dev, key) + return True + +-# cancel registration without aborting tasks +-def preempt(options, host, dev): ++# helper function to preempt host with 'key' using 'host_key' without aborting tasks ++def preempt(options, host_key, dev, key): + reset_dev(options,dev) +- cmd = options["--sg_persist-path"] + " -n -o -P -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev ++ cmd = options["--sg_persist-path"] + " -n -o -P -T 5 -K " + host_key + " -S " + key + " -d " + dev + return not bool(run_cmd(options, cmd)["rc"]) + + # helper function to send the register command +-def register_helper(options, host, dev): ++def register_helper(options, dev, key): + reset_dev(options, dev) +- cmd = options["--sg_persist-path"] + " -n -o -I -S " + options["--key"] + " -d " + dev ++ cmd = options["--sg_persist-path"] + " -n -o -I -S " + key + " -d " + dev + cmd += " -Z" if "--aptpl" in options else "" + return not bool(run_cmd(options, cmd)["rc"]) + diff --git a/fence-agents.spec b/fence-agents.spec index 051afed..b919076 100644 --- a/fence-agents.spec +++ b/fence-agents.spec @@ -87,7 +87,7 @@ Name: fence-agents Summary: Set of unified programs capable of host isolation ("fencing") Version: 4.2.1 -Release: 125%{?alphatag:.%{alphatag}}%{?dist} +Release: 126%{?alphatag:.%{alphatag}}%{?dist} License: GPLv2+ and LGPLv2+ Group: System Environment/Base URL: https://github.com/ClusterLabs/fence-agents @@ -277,6 +277,8 @@ Patch134: bz2155453-fence_ibm_powervs-performance-improvements.patch Patch135: RHEL-14343-fence_zvmip-document-user-permissions.patch Patch136: RHEL-14031-1-all-agents-metadata-update-IO-Power-Network.patch Patch137: RHEL-14031-2-fence_cisco_mds-undo-metadata-change.patch +Patch138: RHEL-5397-fence_scsi-1-fix-ISID-reg-handling.patch +Patch139: RHEL-5397-fence_scsi-2-fix-ISID-reg-handling-off.patch ### HA support libs/utils ### # all archs @@ -362,144 +364,146 @@ BuildRequires: python3-google-api-client python3-pip python3-wheel python3-jinja %prep %setup -q -n %{name}-%{version} -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -p1 -%patch14 -p1 -%patch15 -p1 -%patch16 -p1 -%patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -%patch21 -p1 -%patch22 -p1 -%patch23 -p1 -%patch24 -p1 -%patch25 -p1 -%patch26 -p1 -%patch27 -p1 -%patch28 -p1 -%patch29 -p1 -%patch30 -p1 -F2 -%patch31 -p1 -F2 -%patch32 -p1 -%patch33 -p1 -%patch34 -p1 -%patch35 -p1 -%patch36 -p1 -F1 -%patch37 -p1 -%patch38 -p1 -%patch39 -p1 -%patch40 -p1 -F2 -%patch41 -p1 -%patch42 -p1 -%patch43 -p1 -%patch44 -p1 -%patch45 -p1 -%patch46 -p1 -%patch47 -p1 -%patch48 -p1 -F1 -%patch49 -p1 -%patch50 -p1 -%patch51 -p1 -%patch52 -p1 -%patch53 -p1 -%patch54 -p1 -%patch55 -p1 -%patch56 -p1 -%patch57 -p1 -%patch58 -p1 -%patch59 -p1 -%patch60 -p1 -F1 -%patch61 -p1 -%patch62 -p1 -%patch63 -p1 -%patch64 -p1 -%patch65 -p1 -F1 -%patch66 -p1 -%patch67 -p1 -%patch68 -p1 -%patch69 -p1 -%patch70 -p1 -%patch71 -p1 -%patch72 -p1 -%patch73 -p1 -%patch74 -p1 -%patch75 -p1 -%patch76 -p1 -%patch77 -p1 -%patch78 -p1 -%patch79 -p1 -%patch80 -p1 -%patch81 -p1 -%patch82 -p1 -%patch83 -p1 -%patch84 -p1 -%patch85 -p1 -%patch86 -p1 -F1 -%patch87 -p1 -%patch88 -p1 -%patch89 -p1 -%patch90 -p1 -%patch91 -p1 -%patch92 -p1 -%patch93 -p1 -%patch94 -p1 -%patch95 -p1 -%patch96 -p1 -F2 -%patch97 -p1 -%patch98 -p1 -%patch99 -p1 -%patch100 -p1 -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -F1 -%patch105 -p1 -%patch106 -p1 -%patch107 -p1 -%patch108 -p1 -%patch109 -p1 -%patch110 -p1 -%patch111 -p1 -%patch112 -p1 -%patch113 -p1 -%patch114 -p1 -%patch115 -p1 -%patch116 -p1 -%patch117 -p1 -%patch118 -p1 -%patch119 -p1 -%patch120 -p1 -%patch121 -p1 -%patch122 -p1 -F2 -%patch123 -p1 -%patch124 -p1 -%patch125 -p1 -%patch126 -p1 -%patch127 -p1 -%patch128 -p1 -F2 -%patch129 -p1 -%patch130 -p1 -%patch131 -p1 -%patch132 -p1 -%patch133 -p1 -%patch134 -p1 -%patch135 -p1 -%patch136 -p1 -F2 -%patch137 -p1 +%patch -p1 -P 0 +%patch -p1 -P 1 +%patch -p1 -P 2 +%patch -p1 -P 3 +%patch -p1 -P 4 +%patch -p1 -P 5 +%patch -p1 -P 6 +%patch -p1 -P 7 +%patch -p1 -P 8 +%patch -p1 -P 9 +%patch -p1 -P 10 +%patch -p1 -P 11 +%patch -p1 -P 12 +%patch -p1 -P 13 +%patch -p1 -P 14 +%patch -p1 -P 15 +%patch -p1 -P 16 +%patch -p1 -P 17 +%patch -p1 -P 18 +%patch -p1 -P 19 +%patch -p1 -P 20 +%patch -p1 -P 21 +%patch -p1 -P 22 +%patch -p1 -P 23 +%patch -p1 -P 24 +%patch -p1 -P 25 +%patch -p1 -P 26 +%patch -p1 -P 27 +%patch -p1 -P 28 +%patch -p1 -P 29 +%patch -p1 -P 30 -F2 +%patch -p1 -P 31 -F2 +%patch -p1 -P 32 +%patch -p1 -P 33 +%patch -p1 -P 34 +%patch -p1 -P 35 +%patch -p1 -P 36 -F1 +%patch -p1 -P 37 +%patch -p1 -P 38 +%patch -p1 -P 39 +%patch -p1 -P 40 -F2 +%patch -p1 -P 41 +%patch -p1 -P 42 +%patch -p1 -P 43 +%patch -p1 -P 44 +%patch -p1 -P 45 +%patch -p1 -P 46 +%patch -p1 -P 47 +%patch -p1 -P 48 -F1 +%patch -p1 -P 49 +%patch -p1 -P 50 +%patch -p1 -P 51 +%patch -p1 -P 52 +%patch -p1 -P 53 +%patch -p1 -P 54 +%patch -p1 -P 55 +%patch -p1 -P 56 +%patch -p1 -P 57 +%patch -p1 -P 58 +%patch -p1 -P 59 +%patch -p1 -P 60 -F1 +%patch -p1 -P 61 +%patch -p1 -P 62 +%patch -p1 -P 63 +%patch -p1 -P 64 +%patch -p1 -P 65 -F1 +%patch -p1 -P 66 +%patch -p1 -P 67 +%patch -p1 -P 68 +%patch -p1 -P 69 +%patch -p1 -P 70 +%patch -p1 -P 71 +%patch -p1 -P 72 +%patch -p1 -P 73 +%patch -p1 -P 74 +%patch -p1 -P 75 +%patch -p1 -P 76 +%patch -p1 -P 77 +%patch -p1 -P 78 +%patch -p1 -P 79 +%patch -p1 -P 80 +%patch -p1 -P 81 +%patch -p1 -P 82 +%patch -p1 -P 83 +%patch -p1 -P 84 +%patch -p1 -P 85 +%patch -p1 -P 86 -F1 +%patch -p1 -P 87 +%patch -p1 -P 88 +%patch -p1 -P 89 +%patch -p1 -P 90 +%patch -p1 -P 91 +%patch -p1 -P 92 +%patch -p1 -P 93 +%patch -p1 -P 94 +%patch -p1 -P 95 +%patch -p1 -P 96 -F2 +%patch -p1 -P 97 +%patch -p1 -P 98 +%patch -p1 -P 99 +%patch -p1 -P 100 +%patch -p1 -P 101 +%patch -p1 -P 102 +%patch -p1 -P 103 +%patch -p1 -P 104 -F1 +%patch -p1 -P 105 +%patch -p1 -P 106 +%patch -p1 -P 107 +%patch -p1 -P 108 +%patch -p1 -P 109 +%patch -p1 -P 110 +%patch -p1 -P 111 +%patch -p1 -P 112 +%patch -p1 -P 113 +%patch -p1 -P 114 +%patch -p1 -P 115 +%patch -p1 -P 116 +%patch -p1 -P 117 +%patch -p1 -P 118 +%patch -p1 -P 119 +%patch -p1 -P 120 +%patch -p1 -P 121 +%patch -p1 -P 122 -F2 +%patch -p1 -P 123 +%patch -p1 -P 124 +%patch -p1 -P 125 +%patch -p1 -P 126 +%patch -p1 -P 127 +%patch -p1 -P 128 -F2 +%patch -p1 -P 129 +%patch -p1 -P 130 +%patch -p1 -P 131 +%patch -p1 -P 132 +%patch -p1 -P 133 +%patch -p1 -P 134 +%patch -p1 -P 135 +%patch -p1 -P 136 -F2 +%patch -p1 -P 137 +%patch -p1 -P 138 +%patch -p1 -P 139 -F2 # prevent compilation of something that won't get used anyway sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac @@ -1508,6 +1512,10 @@ Fence agent for IBM z/VM over IP. %endif %changelog +* Tue Oct 24 2023 Oyvind Albrigtsen - 4.2.1-126 +- fence_scsi: fix registration handling if ISID conflicts + Resolves: RHEL-5397 + * Mon Oct 23 2023 Oyvind Albrigtsen - 4.2.1-125 - all agents: update metadata in non-I/O agents to Power or Network fencing