Merge r7516 from trunk

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@7768 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2018-11-04 17:03:09 +00:00
parent 0c98bfd6d3
commit abdb80fe67
8 changed files with 88 additions and 88 deletions

View File

@@ -13,14 +13,14 @@ mail.
INSTALLATION
Place files SCSTTarget and SCSTLun into pacemaker ocf directory (usually
Place files SCSTTarget and SCSTLun into pacemaker ocf directory (usually
/usr/lib/ocf/resource.d or /usr/lib64/ocf/resource.d)
EXAMPLE OF USAGE
Assumptions:
Assumptions:
- you are using DRBD as backing device (/dev/drbd1)
- your target iqn is iqn.2012-02.com.mysuperhasan:vdisk.lun
- your nic reserved for iscsi is eth2 and your iscsi subnet is 192.168.103.x
@@ -36,7 +36,7 @@ primitive ISCSI_IP ocf:heartbeat:IPaddr2 \
op monitor interval="10s"
primitive ISCSI_LUN ocf:scst:SCSTLun \
params target_iqn="iqn.2012-02.com.mysuperhasan:vdisk.lun" lun="0" \
path="/dev/drbd1" handler="vdisk_fileio" device_name="VDISK-LUN10" \
path="/dev/drbd1" handler="vdisk_fileio" device_name="VDISK-LUN10" \
additional_parameters="nv_cache=1" \
op monitor interval="10s" timeout="120s"
primitive ISCSI_TGT ocf:scst:SCSTTarget \
@@ -54,7 +54,7 @@ order OR_DRBD_BEFORE_ISCSI inf: MS_DRBD_VOLUME:promote GR_ISCSI:start
CURRENT LIMITATIONS
Scripts are tested only with straight drbd or lvm over drbd as backing device,
Scripts are tested only with straight drbd or lvm over drbd as backing device,
using vdisk_fileio, with one lun per target.
CHAP authentication is configurable, but not yet tested. My current version of SCST

View File

@@ -7,8 +7,8 @@
# and Linux-HA contributors
#
# Based on ISCSILogicalUnit from Florian Haas, Dejan Muhamedagic,
#
#
#
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
@@ -43,7 +43,7 @@ meta_data() {
<version>1.0</version>
<longdesc lang="en">
Manages SCST iSCSI Logical Unit. An iSCSI Logical unit is a subdivision of
Manages SCST iSCSI Logical Unit. An iSCSI Logical unit is a subdivision of
an SCSI Target, exported via a daemon that speaks the iSCSI protocol.
</longdesc>
<shortdesc lang="en">Manages iSCSI Logical Units (LUs)</shortdesc>
@@ -86,7 +86,7 @@ The handler used (vdisk_blockio, vdisk_fileio, dev_tape ...).</longdesc>
<parameter name="scsi_id" required="0" unique="0">
<longdesc lang="en">
The t10 device ID of LUN. If not specified default SCST value will be used.
Please note that some initiators, like ESXi, are using only some of the first
Please note that some initiators, like ESXi, are using only some of the first
characters to identify LUN, like 4-6 chars.
</longdesc>
<shortdesc lang="en">t10 device id</shortdesc>
@@ -171,7 +171,7 @@ l_check_module () {
}
l_start_handler () {
#Check Handler, then load module
#Check Handler, then load module
l_check_module
l_load_module $l_module
}
@@ -179,21 +179,21 @@ l_start_handler () {
l_stop_handler () {
local HANDLER_NOT_REQUIRED=true;
#Check if handler is used for other devices, then unload module.
for i in $( ls "${SYSFS_ROOTPATH}/handlers/${OCF_RESKEY_handler}" ) ; do
if [ -d ${SYSFS_ROOTPATH}/handlers/${OCF_RESKEY_handler}/${i} ]; then
HANDLER_NOT_REQUIRED=false
break
fi
done
if $HANDLER_NOT_REQUIRED ; then
ocf_log info "Handler ${OCF_RESKEY_handler} not required, unloading kernel module"
l_check_module
l_check_module
rmmod $l_module
return $?
fi
return 0
return 0
}
SCSTLun_usage() {
@@ -210,48 +210,48 @@ SCSTLun_start() {
return $OCF_SUCCESS
fi
local params
local params
if [ ! ${OCF_RESKEY_path} == "" ]; then
params="filename=${OCF_RESKEY_path}"
fi
if [ ! ${OCF_RESKEY_additional_parameters} == "" ]; then
fi
if [ ! ${OCF_RESKEY_additional_parameters} == "" ]; then
params="${params} ${OCF_RESKEY_additional_parameters}"
fi
ocf_log info "Disabling target ${OCF_RESKEY_target_iqn}"
echo 0 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/enabled"
echo 0 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/enabled"
ocf_log info "Starting lun ${OCF_RESKEY_lun} on target ${OCF_RESKEY_target_iqn}"
# Load Handler Modules
l_start_handler #|| exit $OCF_ERR_GENERIC
# Open Device
ocf_log info "Opening device ${OCF_RESKEY_device_name}, target ${OCF_RESKEY_target_iqn}"
echo "add_device ${OCF_RESKEY_device_name} ${params// /;}" > "${SCST_BASE}/handlers/${OCF_RESKEY_handler}/mgmt"
echo "add_device ${OCF_RESKEY_device_name} ${params// /;}" > "${SCST_BASE}/handlers/${OCF_RESKEY_handler}/mgmt"
if [ $? -ne 0 ]; then
ocf_log err "FAILED to open device ${OCF_RESKEY_device_name}"
return $OCF_ERR_GENERIC
fi
# Set SCSI SN and t10 dev id
if [ ! ${OCF_RESKEY_scsi_sn} == "" ]; then
ocf_log info "Setting SCSI S/N ${OCF_RESKEY_scsi_sn}"
echo "${OCF_RESKEY_scsi_sn}" > "${SCST_BASE}/devices/${OCF_RESKEY_device_name}/usn"
if [ $? -ne 0 ]; then
ocf_log warn "FAILED to set SCSI S/N!"
fi
fi
if [ ! ${OCF_RESKEY_scsi_id} == "" ]; then
ocf_log info "Setting SCSI ID ${OCF_RESKEY_scsi_sn}-${OCF_RESKEY_scsi_id}"
echo "${OCF_RESKEY_scsi_sn}-${OCF_RESKEY_scsi_id}" > "${SCST_BASE}/devices/${OCF_RESKEY_device_name}/t10_dev_id"
if [ $? -ne 0 ]; then
ocf_log warn "FAILED to set SCSI ID!"
fi
fi
fi
fi
fi
# Assign Device to the Target
ocf_log info "Adding LUN ${OCF_RESKEY_lun}, device ${OCF_RESKEY_device_name}, target ${OCF_RESKEY_target_iqn}"
echo "add ${OCF_RESKEY_device_name} ${OCF_RESKEY_lun}" > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/luns/mgmt"
@@ -259,11 +259,11 @@ SCSTLun_start() {
ocf_log err "FAILED to add lun ${OCF_RESKEY_lun}"
return $OCF_ERR_GENERIC
fi
#Enable target
ocf_log info "Enabling target ${OCF_RESKEY_target_iqn}"
echo 1 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/enabled"
ocf_log info "Started lun ${OCF_RESKEY_lun} on target ${OCF_RESKEY_target_iqn}"
#Debugging purpose
@@ -276,23 +276,23 @@ SCSTLun_stop() {
if [ $? = $OCF_SUCCESS ]; then
ocf_log info "Stopping lun ${OCF_RESKEY_lun} on target ${OCF_RESKEY_target_iqn}"
# Disable Target
ocf_log info "Disabling target ${OCF_RESKEY_target_iqn}"
echo 0 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/enabled"
# Drop connections, only if session is using lun
for i in $( ls "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/sessions" ) ; do
for i in $( ls "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/sessions" ) ; do
if [ -d "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/sessions/${i}/luns/${OCF_RESKEY_lun}" ]; then
ocf_log warn "Force closing session to initiator ${i}"
echo 1 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/sessions/${i}/force_close"
fi
done
ocf_log info "Removing LUN ${OCF_RESKEY_lun}, device ${OCF_RESKEY_device_name}, target ${OCF_RESKEY_target_iqn}"
echo "del ${OCF_RESKEY_lun}" >${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/luns/mgmt
if [ $? -ne 0 ]; then
ocf_log err "FAILED to remove LUN ${OCF_RESKEY_lun} from target ${OCF_RESKEY_target_iqn}"
#return $OCF_ERR_GENERIC
#return $OCF_ERR_GENERIC
#Don't exit, try to remove device anyway.
fi
@@ -302,20 +302,20 @@ SCSTLun_stop() {
if [ $? -ne 0 ]; then
ocf_log err "FAILED to remove device ${OCF_RESKEY_device_name}"
return $OCF_ERR_GENERIC
fi
fi
# Enable Target
ocf_log info "Enabling target ${OCF_RESKEY_target_iqn}"
echo 1 > "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/enabled"
#Debugging purpose
#scstadmin -write_config /tmp/scst.conf.stop
#Stop Handler
l_stop_handler || exit $OCF_ERR_GENERIC
fi
return $OCF_SUCCESS
}
@@ -324,7 +324,7 @@ SCSTLun_monitor() {
if [ -e "${SCST_BASE}/handlers/${OCF_RESKEY_handler}/${OCF_RESKEY_device_name}" ]; then
return $OCF_SUCCESS
fi
# Check if lun is running.
if [ -e "${ISCSI_BASE}/${OCF_RESKEY_target_iqn}/luns/${OCF_RESKEY_lun}" ]; then
return $OCF_SUCCESS
@@ -336,7 +336,7 @@ SCSTLun_monitor() {
SCSTLun_validate() {
# Do we have all required variables?
# TODO: make this check more precise considering handler used!
for var in target_iqn lun device_name handler; do
param="OCF_RESKEY_${var}"
if [ -z "${!param}" ]; then
@@ -348,7 +348,7 @@ SCSTLun_validate() {
if ! ocf_is_probe; then
# Do we have all required binaries?
check_binary scstadmin
# Is the required kernel functionality available?
if [ ! -d ${SCST_BASE} ]; then
ocf_log err "${SCST_BASE} does not exist or is not a directory -- check if required modules are loaded."

View File

@@ -144,21 +144,21 @@ l_load_module () {
}
l_start_service () {
local running
local running
# Handler modules are loaded in LUN resource agent
# Check if modules are loaded
if [ ! -d ${SYSFS_PATH} ]; then
ocf_log info "Loading scst Modules"
l_load_module scst || return 1
l_load_module iscsi_scst || return 1
#Not critical modules, not unloaded on stop.
l_load_module crc32c
#Not critical modules, not unloaded on stop.
l_load_module crc32c
l_load_module crc32c_intel
fi
# Start Daemon
if [ ! "$(pidof ${ISCSI_DAEMON})" ]; then
ocf_run $ISCSI_DAEMON || return 1
@@ -178,7 +178,7 @@ l_stop_service () {
TARGET_NOT_PRESENT=false
fi
done
#Close sessions
for i in `/bin/ls ${ISCSI_BASE}/${OCF_RESKEY_iqn}/sessions`; do
ocf_log warn "Force closing session to initiator ${i}"
@@ -187,8 +187,8 @@ l_stop_service () {
#Stop process and unload modules
if $TARGET_NOT_PRESENT ; then
ocf_log warn "Daemon not required, stopping ..."
pkill -TERM -f $ISCSI_DAEMON
ocf_log warn "Daemon not required, stopping ..."
pkill -TERM -f $ISCSI_DAEMON
rmmod iscsi_scst
rmmod scst
fi
@@ -212,9 +212,9 @@ SCSTTarget_start() {
local name
local value
local initiator
# Start Service
l_start_service
l_start_service
# Set incoming username and password globally
if [ "${OCF_RESKEY_incoming_username}" != "" ]; then
echo "add_attribute IncomingUser ${OCF_RESKEY_incoming_username} ${OCF_RESKEY_incoming_password}" > ${ISCSI_BASE}/mgmt
@@ -222,39 +222,39 @@ SCSTTarget_start() {
ocf_log warn "Unable to set CHAP Authentication!"
fi
fi
ocf_log info "target ${OCF_RESKEY_iqn}: Starting..."
# Create Target
echo "add_target ${OCF_RESKEY_iqn}" > ${ISCSI_BASE}/mgmt || exit $OCF_ERR_GENERIC
# Set Allowed Portals
if [ "${OCF_RESKEY_portals}" != "none" ]; then
if [ "${OCF_RESKEY_portals}" != "none" ]; then
for param in ${OCF_RESKEY_portals}; do
ocf_log info "Adding allowed portal ${param} to target ${OCF_RESKEY_iqn}"
ocf_log info "Adding allowed portal ${param} to target ${OCF_RESKEY_iqn}"
echo "add_target_attribute ${OCF_RESKEY_iqn} allowed_portal ${param}" > ${ISCSI_BASE}/mgmt
if [ $? -ne 0 ]; then
ocf_log warn "Unable to set Allowed Portal!"
fi
done
done
fi
# Set incoming username and password
if [ "${OCF_RESKEY_incoming_username}" != "" ]; then
echo "add_target_attribute ${OCF_RESKEY_iqn} IncomingUser ${OCF_RESKEY_incoming_username} ${OCF_RESKEY_incoming_password}" > ${ISCSI_BASE}/mgmt
if [ "${OCF_RESKEY_incoming_username}" != "" ]; then
echo "add_target_attribute ${OCF_RESKEY_iqn} IncomingUser ${OCF_RESKEY_incoming_username} ${OCF_RESKEY_incoming_password}" > ${ISCSI_BASE}/mgmt
if [ $? -ne 0 ]; then
ocf_log warn "Unable to set CHAP Authentication!"
fi
fi
fi
ocf_log info "Enabling target ${OCF_RESKEY_iqn}"
ocf_log info "Enabling target ${OCF_RESKEY_iqn}"
# Enable iSCSI Target
echo 1 > "${ISCSI_BASE}/enabled" || exit $OCF_ERR_GENERIC
echo 1 > "${ISCSI_BASE}/enabled" || exit $OCF_ERR_GENERIC
ocf_log debug "SCST target ${OCF_RESKEY_iqn}: Started."
#Debugging purpose
#scstadmin -write_config /tmp/scst.conf.start
#scstadmin -write_config /tmp/scst.conf.start
return $OCF_SUCCESS
}
@@ -262,9 +262,9 @@ SCSTTarget_stop() {
SCSTTarget_monitor
if [ $? = $OCF_SUCCESS ]; then
local param
local param
ocf_log info "target ${OCF_RESKEY_iqn}: Stopping..."
# Check if there are connected luns
for i in $( ls "${ISCSI_BASE}/${OCF_RESKEY_iqn}/luns" ) ; do
if [ -d "${ISCSI_BASE}/${OCF_RESKEY_iqn}/luns/${i}" ]; then
@@ -272,11 +272,11 @@ SCSTTarget_stop() {
exit $OCF_ERR_GENERIC
fi
done
# Disable Target
ocf_log info "disabling target ${OCF_RESKEY_iqn}"
echo 0 > ${ISCSI_BASE}/${OCF_RESKEY_iqn}/enabled || exit $OCF_ERR_GENERIC
#Remove Target
ocf_log info "deleting target ${OCF_RESKEY_iqn}"
echo "del_target ${OCF_RESKEY_iqn}" > ${ISCSI_BASE}/mgmt
@@ -285,20 +285,20 @@ SCSTTarget_stop() {
exit $OCF_ERR_GENERIC
fi
#Debugging purpose
#scstadmin -write_config /tmp/scst.conf.stop
#Check if other targets are running, then stop service and unload modules
#scstadmin -write_config /tmp/scst.conf.stop
#Check if other targets are running, then stop service and unload modules
l_stop_service
ocf_log info "target ${OCF_RESKEY_iqn}: Stopped."
fi
return $OCF_SUCCESS
}
SCSTTarget_monitor() {
if [ -d "${SYSFS_PATH}/${OCF_RESKEY_iqn}" ]; then
if [ -d "${SYSFS_PATH}/${OCF_RESKEY_iqn}" ]; then
return $OCF_SUCCESS
else
else
return $OCF_NOT_RUNNING
fi
}
@@ -317,7 +317,7 @@ SCSTTarget_validate() {
if ! ocf_is_probe; then
check_binary scstadmin
fi
fi
return $OCF_SUCCESS
}

View File

@@ -20,8 +20,8 @@
# all (the default) : make all
# clean : clean files
# extraclean : clean + clean dependencies
# install : install
# uninstall : uninstall
# install : install
# uninstall : uninstall
#
# Notes :
# - install and uninstall must be made as root

View File

@@ -1,15 +1,15 @@
#
# SCSI target mid-level dev handler's makefile
#
#
# Copyright (C) 2015 - 2018 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2005 Leonid Stoljar
# Copyright (C) 2007 - 2018 Western Digital Corporation
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, version 2
# of the License.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -20,8 +20,8 @@
# all (the default) : make all
# clean : clean files
# extraclean : clean + clean dependencies
# install : install
# uninstall : uninstall
# install : install
# uninstall : uninstall
#
# Notes :
# - install and uninstall must be made as root

View File

@@ -97,7 +97,7 @@ HANDLER dev_cdrom {
DEVICE 2:0:0:0
}
Virtual devices are opened through special CREATE attributes. For example, a
Virtual devices are opened through special CREATE attributes. For example, a
virtual disk named "disk1" pointing to a disk partition /dev/hda1 would be look
like:

View File

@@ -29,7 +29,7 @@ The following pertains to the older procfs based SCST.
The scstadmin script is much more functional than scst_db at this point but uses a
standard text-based config file. The original thought behind scst_db was to write
a daemon process which would except network connections and issue SCST commands. A
client app would then connect to that port.
client app would then connect to that port.
Copy scst.conf to /etc and edit it to your liking. if you have an existing configuration
then have scstadmin write it out to a config file for you:

View File

@@ -250,7 +250,7 @@ start_scst() {
options=""
if [ "$(basename "$d")" = "iscsi-scstd" ]; then
options="${ISCSID_OPTIONS}"
fi
fi
if ! start_daemon $d $options; then
echo "Starting $d failed"
unload_scst