Default number of iothreads for rdwr target is 16. Setting it to 2 lowers
memory footprint dramatically.
By default tgtd binds to wildcard address. Now it's possible to specify
address and port to listen to.
New options have been added to configure keepalives.

Signed-off-by: Maxim Storchak <m.storc...@gmail.com>
---
 net/tgt/files/etc/config/tgt |    8 ++++++++
 net/tgt/files/etc/init.d/tgt |   21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/net/tgt/files/etc/config/tgt b/net/tgt/files/etc/config/tgt
index 250d12d..98b2206 100644
--- a/net/tgt/files/etc/config/tgt
+++ b/net/tgt/files/etc/config/tgt
@@ -1,3 +1,11 @@
+config options 'tgt'
+# iothreads limits number of worker threads per rdwr target, default is 16
+# which seems to be too much for an avarage router
+       option iothreads '2'
+#      option portal '0.0.0.0:3260'
+#      option nop_count '3'
+#      option nop_interval '5'
+
 config target 1
        option name 'iqn.2012-06.org.openwrt:target1'
        option allow ALL
diff --git a/net/tgt/files/etc/init.d/tgt b/net/tgt/files/etc/init.d/tgt
index 38efa2b..82648b6 100755
--- a/net/tgt/files/etc/init.d/tgt
+++ b/net/tgt/files/etc/init.d/tgt
@@ -85,9 +85,30 @@ configure() {
        return 0
 }
 
+validate_tgt_section() {
+       uci_validate_section tgt options $1 \
+               'iothreads:uinteger' \
+               'portal:string' \
+               'nop_interval:uinteger' \
+               'nop_count:uinteger'
+}
+
 start_service() {
+       local iothreads portal nop_interval nop_count
+       validate_tgt_section tgt || {
+               echo "validation failed"
+               return 1
+       }
        procd_open_instance
        procd_set_param command $PROG -f
+       [ "$iothreads" ] && procd_append_param command -t $iothreads
+       [ "${portal}${nop_interval}${nop_count}" ] && {
+               local iscsi
+               [ "$portal" ] && iscsi="portal=$portal"
+               [ "$nop_interval" ] && iscsi="nop_interval=$nop_interval,$iscsi"
+               [ "$nop_count" ] && iscsi="nop_count=$nop_count,$iscsi"
+               procd_append_param command --iscsi $iscsi
+       }
        procd_set_param respawn
        procd_close_instance
        logger -t $NAME -s "Configuration will be loaded in seconds"
-- 
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to