|
@ -28,7 +28,8 @@ validate_lun_section() { |
|
|
'scsi_id:string' \ |
|
|
'scsi_id:string' \ |
|
|
'scsi_sn:string' \ |
|
|
'scsi_sn:string' \ |
|
|
'sense_format:range(0, 1)' \ |
|
|
'sense_format:range(0, 1)' \ |
|
|
'vendor_id:string' |
|
|
|
|
|
|
|
|
'vendor_id:string' \ |
|
|
|
|
|
'rotation_rate:uinteger' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handle_lun() { |
|
|
handle_lun() { |
|
@ -36,7 +37,7 @@ handle_lun() { |
|
|
local my_tgtid=${tgt_lun%_*} |
|
|
local my_tgtid=${tgt_lun%_*} |
|
|
local lun=${tgt_lun#*_} |
|
|
local lun=${tgt_lun#*_} |
|
|
|
|
|
|
|
|
[ $my_tgtid -eq $tgtid ] || return 0 |
|
|
|
|
|
|
|
|
[ "$my_tgtid" -eq "$tgtid" ] || return 0 |
|
|
|
|
|
|
|
|
[ "$2" = 0 ] || { |
|
|
[ "$2" = 0 ] || { |
|
|
$logger "Validation failed for LUN $tgt_lun" |
|
|
$logger "Validation failed for LUN $tgt_lun" |
|
@ -47,22 +48,22 @@ handle_lun() { |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if [ $sync -ne 0 -o $direct -ne 0 ]; then |
|
|
|
|
|
|
|
|
if [ "$sync" -ne 0 ] || [ "$direct" -ne 0 ]; then |
|
|
local bsoflags |
|
|
local bsoflags |
|
|
[ $sync -ne 0 ] && bsoflags="sync" |
|
|
|
|
|
[ $direct -ne 0 ] && bsoflags="direct" |
|
|
|
|
|
[ $sync -ne 0 -a $direct -ne 0 ] && bsoflags="sync:direct" |
|
|
|
|
|
|
|
|
[ "$sync" -ne 0 ] && bsoflags="sync" |
|
|
|
|
|
[ "$direct" -ne 0 ] && bsoflags="direct" |
|
|
|
|
|
[ "$sync" -ne 0 ] && [ "$direct" -ne 0 ] && bsoflags="sync:direct" |
|
|
bsoflags="--bsoflags $bsoflags" |
|
|
bsoflags="--bsoflags $bsoflags" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
blocksize=${blocksize+--blocksize=$blocksize} |
|
|
blocksize=${blocksize+--blocksize=$blocksize} |
|
|
local params='' i |
|
|
local params='' i |
|
|
for i in mode_page product_id product_rev readonly removable scsi_id scsi_sn sense_format vendor_id; do |
|
|
|
|
|
|
|
|
for i in mode_page product_id product_rev readonly removable scsi_id scsi_sn sense_format vendor_id rotation_rate; do |
|
|
eval params=\${$i+$i=\$$i,}\$params |
|
|
eval params=\${$i+$i=\$$i,}\$params |
|
|
done |
|
|
done |
|
|
|
|
|
|
|
|
local _tgtadm="$tgtadm --mode logicalunit --tid $tgtid --lun $lun" |
|
|
local _tgtadm="$tgtadm --mode logicalunit --tid $tgtid --lun $lun" |
|
|
$_tgtadm --op new --backing-store $device --device-type $type --bstype $bstype $bsoflags $blocksize || { |
|
|
|
|
|
|
|
|
$_tgtadm --op new --backing-store "$device" --device-type "$type" --bstype "$bstype" $bsoflags $blocksize || { |
|
|
$logger "Failed to create lun $tgt_lun" |
|
|
$logger "Failed to create lun $tgt_lun" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
@ -117,7 +118,7 @@ bind_account_to_target() { |
|
|
local t |
|
|
local t |
|
|
for t in $target; do |
|
|
for t in $target; do |
|
|
[ "$t" -eq "$tgtid" ] && { |
|
|
[ "$t" -eq "$tgtid" ] && { |
|
|
$_tgtadm --op bind --tid $tgtid --user "$user" $outgoing || { |
|
|
|
|
|
|
|
|
$_tgtadm --op bind --tid "$tgtid" --user "$user" $outgoing || { |
|
|
$logger "Failed to bind user $username to target $tgtid" |
|
|
$logger "Failed to bind user $username to target $tgtid" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
@ -137,24 +138,24 @@ handle_target() { |
|
|
local tgtid=$1 |
|
|
local tgtid=$1 |
|
|
local _tgtadm="$tgtadm --mode target" |
|
|
local _tgtadm="$tgtadm --mode target" |
|
|
|
|
|
|
|
|
[ $tgtid -ge 0 ] || return 1 |
|
|
|
|
|
|
|
|
[ "$tgtid" -ge 0 ] || return 1 |
|
|
[ "$2" = 0 ] || { |
|
|
[ "$2" = 0 ] || { |
|
|
$logger "Validation failed for target $tgtid" |
|
|
$logger "Validation failed for target $tgtid" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
$_tgtadm --op new --tid $tgtid --targetname $name || { |
|
|
|
|
|
|
|
|
$_tgtadm --op new --tid "$tgtid" --targetname "$name" || { |
|
|
$logger "Failed to create target $tgtid" |
|
|
$logger "Failed to create target $tgtid" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
local i |
|
|
local i |
|
|
for i in $allow_address; do |
|
|
for i in $allow_address; do |
|
|
$_tgtadm --op bind --tid $tgtid --initiator-address $i || { |
|
|
|
|
|
|
|
|
$_tgtadm --op bind --tid "$tgtid" --initiator-address "$i" || { |
|
|
$logger "Failed to set allow $i to connect to target $tgtid" |
|
|
$logger "Failed to set allow $i to connect to target $tgtid" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
|
done |
|
|
done |
|
|
for i in $allow_name; do |
|
|
for i in $allow_name; do |
|
|
$_tgtadm --op bind --tid $tgtid --initiator-name $i || { |
|
|
|
|
|
|
|
|
$_tgtadm --op bind --tid "$tgtid" --initiator-name "$i" || { |
|
|
$logger "Failed to set allow $i to connect to target $tgtid" |
|
|
$logger "Failed to set allow $i to connect to target $tgtid" |
|
|
return 1 |
|
|
return 1 |
|
|
} |
|
|
} |
|
@ -193,7 +194,7 @@ start_tgt_instance() { |
|
|
} |
|
|
} |
|
|
procd_open_instance |
|
|
procd_open_instance |
|
|
procd_set_param command $PROG -f |
|
|
procd_set_param command $PROG -f |
|
|
[ "$iothreads" ] && procd_append_param command -t $iothreads |
|
|
|
|
|
|
|
|
[ "$iothreads" ] && procd_append_param command -t "$iothreads" |
|
|
[ "$portal$nop_interval$nop_count" ] && { |
|
|
[ "$portal$nop_interval$nop_count" ] && { |
|
|
local iscsi="" i |
|
|
local iscsi="" i |
|
|
for i in nop_interval nop_count; do |
|
|
for i in nop_interval nop_count; do |
|
@ -202,11 +203,11 @@ start_tgt_instance() { |
|
|
for i in $portal; do |
|
|
for i in $portal; do |
|
|
iscsi="portal=$i,$iscsi" |
|
|
iscsi="portal=$i,$iscsi" |
|
|
done |
|
|
done |
|
|
procd_append_param command --iscsi $iscsi |
|
|
|
|
|
|
|
|
procd_append_param command --iscsi "$iscsi" |
|
|
} |
|
|
} |
|
|
procd_set_param respawn |
|
|
procd_set_param respawn |
|
|
procd_close_instance |
|
|
procd_close_instance |
|
|
logger -p daemon.info -t $NAME -s "Configuration will be loaded in seconds" |
|
|
|
|
|
|
|
|
logger -p daemon.info -t "$NAME" -s "Configuration will be loaded in seconds" |
|
|
( sleep 5; configure || { stop_service; exit 1; } ) & |
|
|
( sleep 5; configure || { stop_service; exit 1; } ) & |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|