Blob Blame History Raw
From 8cd85ba88193f9cdb0c933ba9f7261f1c3631868 Mon Sep 17 00:00:00 2001
From: John Ruemker <jruemker@redhat.com>
Date: Tue, 22 Sep 2015 17:52:56 -0400
Subject: [PATCH 1/4] fence_scsi: Reset device prior to all uses of sg_persist

Currently the agent will reset prior to several areas where it runs
sg_persist, to clear out any "Unit Attention" conditions that could
otherwise cause the sg_persist command to report failures.  However
several paths remain that could fail if a "Unit Attention" condition
exist, so we should reset before any use of sg_persist.
---
 fence/agents/scsi/fence_scsi.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
index e18e473..8680828 100644
--- a/fence/agents/scsi/fence_scsi.py
+++ b/fence/agents/scsi/fence_scsi.py
@@ -125,6 +125,7 @@ def is_block_device(dev):
 
 # cancel registration
 def preempt_abort(options, host, dev):
+	reset_dev(options,dev)
 	cmd = options["--sg_persist-path"] + " -n -o -A -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev
 	return not bool(run_cmd(options, cmd)["err"])
 
@@ -147,11 +148,13 @@ def register_dev(options, dev):
 
 
 def reserve_dev(options, dev):
+	reset_dev(options,dev)
 	cmd = options["--sg_persist-path"] + " -n -o -R -T 5 -K " + options["--key"] + " -d " + dev
 	return not bool(run_cmd(options, cmd)["err"])
 
 
 def get_reservation_key(options, dev):
+	reset_dev(options,dev)
 	cmd = options["--sg_persist-path"] + " -n -i -r -d " + dev
 	out = run_cmd(options, cmd)
 	if out["err"]:
@@ -161,6 +164,7 @@ def get_reservation_key(options, dev):
 
 
 def get_registration_keys(options, dev):
+	reset_dev(options,dev)
 	keys = []
 	cmd = options["--sg_persist-path"] + " -n -i -k -d " + dev
 	out = run_cmd(options, cmd)
-- 
2.4.3