From e8248bd86e74a16f06f01530770da56cb171b3b3 Mon Sep 17 00:00:00 2001 From: Maxim Storchak Date: Mon, 6 May 2019 15:45:19 +0300 Subject: [PATCH] tgt: update to 1.0.77 - update to 1.0.77 - apply patches from Rosen Penev for compatibility with uClibc-ng - add an option for rotation_rate selection Signed-off-by: Maxim Storchak --- net/tgt/Makefile | 4 +-- net/tgt/files/tgt.config | 2 ++ net/tgt/files/tgt.init | 33 ++++++++--------- ...p-Replace-deprecated-valloc-function.patch | 31 ++++++++++++++++ .../111-iscsi_tcp-fix-compile-warning.patch | 36 +++++++++++++++++++ 5 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 net/tgt/patches/110-iscsi_tcp-Replace-deprecated-valloc-function.patch create mode 100644 net/tgt/patches/111-iscsi_tcp-fix-compile-warning.patch diff --git a/net/tgt/Makefile b/net/tgt/Makefile index fa65f3c75..1c4c6522d 100644 --- a/net/tgt/Makefile +++ b/net/tgt/Makefile @@ -4,12 +4,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=tgt -PKG_VERSION:=1.0.76 +PKG_VERSION:=1.0.77 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/fujita/tgt/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=fda84ae0cfc71e2b67ca2d073978f60cb52feea5a697601938ff86656bfdd8f9 +PKG_HASH:=7eab72f47e69102c709be2b48b11228470d7a84c88e64f5c354b83ed84d2d04e PKG_MAINTAINER:=Maxim Storchak PKG_LICENSE:=GPL-2.0 diff --git a/net/tgt/files/tgt.config b/net/tgt/files/tgt.config index de5239d36..e226f6586 100644 --- a/net/tgt/files/tgt.config +++ b/net/tgt/files/tgt.config @@ -44,6 +44,8 @@ config target 1 # option 'removable' '0' # 0 = Classic sense format, 1 = Support descriptor format. # option 'sense_format' '0' +# Rotaion rate: 0: not reported, 1: non-rotational medium (SSD), 2-1024: reserverd, 1025+: "Nominal rotation rate" +# option 'rotation_rate' '0' #config lun 2_1 # option device /mnt/iscsi.img diff --git a/net/tgt/files/tgt.init b/net/tgt/files/tgt.init index b627d5dbd..c10057d65 100755 --- a/net/tgt/files/tgt.init +++ b/net/tgt/files/tgt.init @@ -28,7 +28,8 @@ validate_lun_section() { 'scsi_id:string' \ 'scsi_sn:string' \ 'sense_format:range(0, 1)' \ - 'vendor_id:string' + 'vendor_id:string' \ + 'rotation_rate:uinteger' } handle_lun() { @@ -36,7 +37,7 @@ handle_lun() { local my_tgtid=${tgt_lun%_*} local lun=${tgt_lun#*_} - [ $my_tgtid -eq $tgtid ] || return 0 + [ "$my_tgtid" -eq "$tgtid" ] || return 0 [ "$2" = 0 ] || { $logger "Validation failed for LUN $tgt_lun" @@ -47,22 +48,22 @@ handle_lun() { return 1 } - if [ $sync -ne 0 -o $direct -ne 0 ]; then + if [ "$sync" -ne 0 ] || [ "$direct" -ne 0 ]; then 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" fi blocksize=${blocksize+--blocksize=$blocksize} 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 done 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" return 1 } @@ -117,7 +118,7 @@ bind_account_to_target() { local t for t in $target; do [ "$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" return 1 } @@ -137,24 +138,24 @@ handle_target() { local tgtid=$1 local _tgtadm="$tgtadm --mode target" - [ $tgtid -ge 0 ] || return 1 + [ "$tgtid" -ge 0 ] || return 1 [ "$2" = 0 ] || { $logger "Validation failed for target $tgtid" return 1 } - $_tgtadm --op new --tid $tgtid --targetname $name || { + $_tgtadm --op new --tid "$tgtid" --targetname "$name" || { $logger "Failed to create target $tgtid" return 1 } local i 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" return 1 } done 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" return 1 } @@ -193,7 +194,7 @@ start_tgt_instance() { } procd_open_instance 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" ] && { local iscsi="" i for i in nop_interval nop_count; do @@ -202,11 +203,11 @@ start_tgt_instance() { for i in $portal; do iscsi="portal=$i,$iscsi" done - procd_append_param command --iscsi $iscsi + procd_append_param command --iscsi "$iscsi" } procd_set_param respawn 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; } ) & } diff --git a/net/tgt/patches/110-iscsi_tcp-Replace-deprecated-valloc-function.patch b/net/tgt/patches/110-iscsi_tcp-Replace-deprecated-valloc-function.patch new file mode 100644 index 000000000..0c7c4614d --- /dev/null +++ b/net/tgt/patches/110-iscsi_tcp-Replace-deprecated-valloc-function.patch @@ -0,0 +1,31 @@ +From ced49c99ef0b120d32bcbb3bb6985ff90833052e Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Tue, 30 Apr 2019 22:34:45 -0700 +Subject: [PATCH 1/2] iscsi_tcp: Replace deprecated valloc function + +Replaced with posix_memalign as valloc is not available on uClibc. + +Signed-off-by: Rosen Penev +--- + usr/iscsi/iscsi_tcp.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c +index 536f22e..5762c23 100644 +--- a/usr/iscsi/iscsi_tcp.c ++++ b/usr/iscsi/iscsi_tcp.c +@@ -578,7 +578,10 @@ static void iscsi_tcp_free_task(struct iscsi_task *task) + + static void *iscsi_tcp_alloc_data_buf(struct iscsi_connection *conn, size_t sz) + { +- return valloc(sz); ++ void *addr = NULL; ++ ++ posix_memalign(&addr, sysconf(_SC_PAGESIZE), sz); ++ return addr; + } + + static void iscsi_tcp_free_data_buf(struct iscsi_connection *conn, void *buf) +-- +2.21.0 + diff --git a/net/tgt/patches/111-iscsi_tcp-fix-compile-warning.patch b/net/tgt/patches/111-iscsi_tcp-fix-compile-warning.patch new file mode 100644 index 000000000..8555cc27e --- /dev/null +++ b/net/tgt/patches/111-iscsi_tcp-fix-compile-warning.patch @@ -0,0 +1,36 @@ +From 23f3bb1ab8311601db03757a6d4538e747364454 Mon Sep 17 00:00:00 2001 +From: FUJITA Tomonori +Date: Fri, 3 May 2019 19:30:07 +0900 +Subject: [PATCH 2/2] iscsi_tcp: fix compile warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +iscsi/iscsi_tcp.c: In function ‘iscsi_tcp_alloc_data_buf’: +iscsi/iscsi_tcp.c:583:2: error: ignoring return value of ‘posix_memalign’, declared with attribute warn_unused_result [-Werror=unused-result] + posix_memalign(&addr, sysconf(_SC_PAGESIZE), sz); + ^ + +Signed-off-by: FUJITA Tomonori +--- + usr/iscsi/iscsi_tcp.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c +index 5762c23..0a076b0 100644 +--- a/usr/iscsi/iscsi_tcp.c ++++ b/usr/iscsi/iscsi_tcp.c +@@ -579,8 +579,8 @@ static void iscsi_tcp_free_task(struct iscsi_task *task) + static void *iscsi_tcp_alloc_data_buf(struct iscsi_connection *conn, size_t sz) + { + void *addr = NULL; +- +- posix_memalign(&addr, sysconf(_SC_PAGESIZE), sz); ++ if (posix_memalign(&addr, sysconf(_SC_PAGESIZE), sz) != 0) ++ return addr; + return addr; + } + +-- +2.21.0 +