This file is indexed.

/usr/lib/ocf/resource.d/heartbeat/LinuxSCSI is in cluster-agents 1:1.0.4-0ubuntu2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/bin/sh
#
#
# LinuxSCSI
#
# Description:	Enables/Disables SCSI devices to protect them from being
#		used by mistake
#
#
# Author:	Alan Robertson
#		Support: linux-ha@lists.linux-ha.org
# License:	GNU General Public License (GPL)
# Copyright:	(C) 2002 - 2005 IBM
#
# CAVEATS:	See the usage message for some important warnings
#
# usage: ./LinuxSCSI (start|stop|status|monitor|meta-data|validate-all|methods)
#
#	  OCF parameters are as below:
#		OCF_RESKEY_scsi
#
# An example usage in /etc/ha.d/haresources:
#       node1  10.0.0.170 LinuxSCSI:0:0:11
#

#######################################################################
# Initialization:

: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs

#######################################################################

zeropat="[ 0]0"

PROCSCSI=/proc/scsi/scsi

usage() {
  cat <<EOF
	usage: $0 (start|stop|status|monitor|meta-data|validate-all|methods)

	$0 manages the availability of a SCSI device from the point
	of view of the linux kernel.  It make Linux believe the
	device has gone away, and it can make it come back again.

	The purpose of this resource script is to keep admins from
	accidentally messing with a shared disk that is managed by the
	HA subsystem and is currently owned by the other side.

	To get maximum benefit from this feature, you should (manually)
	disable the resources on boot, and let your HA software enable
	them when it wants to acquire the disk.
	
	The kernel code says this is potentially dangerous.  DO NOT USE
	IT ON AN ACTIVE DEVICE.  If the device is inactive, this script
	will make it stay inactive, when given "off".  If you inactivate
	the wrong device, you may have to reboot your machine, and your
	data may take a hit.

	On the other hand, at least one RAID controller requires the
	use of this technique for it to work correctly in a failover
	environment - so it is believed that it is more stable in this
	usage than the comments in the code imply.

	Here are the warnings from the kernel source about the "stop"
	operation as of 2.4.10:

	------------------------------
	Consider this feature pre-BETA.
	    CAUTION: This is not for hotplugging your peripherals. As
	    SCSI was not designed for this, you could damage your
	    hardware and thoroughly confuse the SCSI subsystem.

	Similar warnings apply to the "start" operation...

	 Consider this feature BETA.
	     CAUTION: This is not for hotplugging your peripherals.
	     As SCSI was not designed for this you could damage your
	     hardware !
	However perhaps it is legal to switch on an already connected
	device. It is perhaps not guaranteed this device doesn't corrupt
	an ongoing data transfer.
	-------------------------

	So, Caveat Emptor, and test this feature thoroughly on
	your kernel and your configuration with real load on the SCSI
	bus before using it in production!

	Another potential trouble spot...
	The order in which you bring up LinuxSCSI resources determines which
	SCSI device they show up as on Linux.  If you have two SCSI devices
	in different resource groups they will be brought up asyncronously
	resulting in indeterminate device name assignments.  This usually
	happens in an active-active configuration.
	
	To solve this you probably should use LVM or EVMS to manage these
	volumes.  LVM and EVMS solve this problem for you by labels they
	keep in the volumes.  If you don't use a reasonable volume manager,
	then you'll have to mount by UUID.

EOF
}

meta_data() {
	cat <<EOF
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="LinuxSCSI">
<version>1.0</version>

<longdesc lang="en">
Deprecation warning: This agent makes use of Linux SCSI hot-plug
functionality which has been superseded by SCSI reservations. It is
deprecated and may be removed from a future release. See the
scsi2reservation and sfex agents for alternatives. --
This is a resource agent for LinuxSCSI. It manages the availability of a
SCSI device from the point of view of the linux kernel. It make Linux
believe the device has gone away, and it can make it come back again.
</longdesc>
<shortdesc lang="en">Enables and disables SCSI devices through the
kernel SCSI hot-plug subsystem (deprecated)</shortdesc>

<parameters>
<parameter name="scsi" unique="0" required="1">
<longdesc lang="en">
The SCSI instance to be managed.
</longdesc>
<shortdesc lang="en">SCSI instance</shortdesc>
<content type="string" default="" />
</parameter>

<parameter name="ignore_deprecation">
<longdesc lang="en">
If set to true, suppresses the deprecation warning for this agent.
</longdesc>
<shortdesc lang="en">Suppress deprecation warning</shortdesc>
<content type="boolean" default="false" />
</parameter>

</parameters>

<actions>
<action name="start" timeout="20s" />
<action name="stop" timeout="20s" />
<action name="methods" timeout="5" />
<action name="status" depth="0" timeout="20s" interval="10" />
<action name="monitor" depth="0" timeout="20s" interval="10" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="5" />
</actions>
</resource-agent>
EOF
}

scsi_methods() {
  cat <<EOF
	start
	stop
	status
	monitor
	validate-all
	methods
EOF
}


parseinst() {
  lun=0
  case "$1" in
	
    [0-9]*:[0-9]*:[0-9]*);;

    [0-9]*:[0-9]*:[0-9]*:[0-9]*)
	lun=`echo "$1" | cut -d: -f4`;;

    *)	#host=error
	#channel=error
	#target=error
	#lun=error
	ocf_log err "Invalid SCSI instance $1"
	exit $OCF_ERR_ARGS
  esac
  host=`echo "$1" | cut -d: -f1`
  channel=`echo "$1" | cut -d: -f2`
  target=`echo "$1" | cut -d: -f3`
}

#
# start: Enable the given SCSI device in the kernel
#
scsi_start() {
  parseinst "$1"
#  [ $target = error ] && exit 1
#  echo "scsi-add-single-device $host $channel $target $lun" >>$PROCSCSI
  echo "scsi add-single-device $host $channel $target $lun" >>$PROCSCSI
  if
    scsi_status "$1"
  then
    return $OCF_SUCCESS
  else
    ocf_log err "SCSI device $1 not active!"
    return $OCF_ERR_GENERIC
  fi
}


#
# stop: Disable the given SCSI device in the kernel
#
scsi_stop() {
  parseinst "$1"
#  [ $target = error ] && exit 1
  echo "scsi remove-single-device $host $channel $target $lun" >>$PROCSCSI
  if
    scsi_status "$1"
  then
    ocf_log err "SCSI device $1 still active!"
    return $OCF_ERR_GENERIC
  else
    return $OCF_SUCCESS
  fi
}


#
# status: is the given device now available?
#
scsi_status() {
  parseinst "$1"
#  [ $target = error ] && exit 1
  [ $channel -eq 0 ]	&& channel=$zeropat
  [ $target -eq 0 ]	&& target=$zeropat
  [ $lun -eq 0 ]	&& lun=$zeropat
  greppat="Host: *scsi$host *Channel: *$channel *Id: *$target *Lun: *$lun"
  grep -i "$greppat" $PROCSCSI >/dev/null
  if [ $? -eq 0 ]; then
	return $OCF_SUCCESS
  else
	return $OCF_NOT_RUNNING
  fi
}

#
# validate_all: Check the OCF instance parameters
#
scsi_validate_all() {
  parseinst $instance
  return $OCF_SUCCESS
}

if
  ( [ $# -ne 1 ] )
then
  ocf_log err "Parameter number error."
  usage
  exit $OCF_ERR_GENERIC
fi

#if
#  [ -z "$OCF_RESKEY_scsi" ] && [ "X$1" = "Xmethods" ]
#then
#  scsi_methods
#  exit #?
#fi
case $1 in
  methods)		scsi_methods
			exit $OCF_SUCCESS
			;;
  meta-data)		meta_data
			exit $OCF_SUCCESS
			;;
  usage)		usage
			exit $OCF_SUCCESS
			;;
  *)			;;
esac

# Be obnoxious, log deprecation warning on every invocation (unless
# suppressed by resource configuration).
ocf_deprecated

if
  [ -z "$OCF_RESKEY_scsi" ]
then
  ocf_log err "You have to set a valid scsi id at least!"
#  usage
  exit $OCF_ERR_GENERIC
fi

instance=$OCF_RESKEY_scsi

case $1 in
  start)		scsi_start $instance
			;;
  stop)			scsi_stop $instance
			;;
  status|monitor)	
	 		if
			  scsi_status $instance
			then
			  ocf_log info "SCSI device $instance is running"
			  return $OCF_SUCCESS
			else
			  ocf_log info "SCSI device $instance is stopped"
			  exit $OCF_NOT_RUNNING
			fi
			;;
  validate-all)		scsi_validate_all
			;;
  *)			usage
			exit $OCF_ERR_UNIMPLEMENTED
			;;
esac
exit $?