tgt: enable support for thin_provisioning
authorMaxim Storchak <m.storchak@gmail.com>
Mon, 7 Oct 2024 16:10:58 +0000 (19:10 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Sun, 3 Nov 2024 17:24:08 +0000 (19:24 +0200)
Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
net/tgt/Makefile
net/tgt/files/tgt.config
net/tgt/files/tgt.init

index 3504a7c14d64169dec748025d58205cae183672c..990a3c0312730693ec292f71a0dc2e24276c186b 100644 (file)
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=tgt
 PKG_VERSION:=1.0.93
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/fujita/tgt/tar.gz/v$(PKG_VERSION)?
index 069f59472d26523eecbc8fb30517846365c48062..f157c9552110356d6fd61b31d8ecd6f734b1b7b8 100644 (file)
@@ -47,6 +47,10 @@ config target 1
 #      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'
+# A thin-provisioned LUN is represented as a sparse file.
+# When initiators use the SCSI UNMAP command TGTD will release the affected areas back to the filesystem using FALLOC_FL_PUNCH_HOLE.
+# This option applies to the disk type and rdwr bstype
+#      option 'thin_provisioning' '1'
 
 #config lun 2_1
 #      option device /mnt/iscsi.img
index 594cdf819c57178463130c1afd413998e2b48847..ec369b9756a41fd14d8416238b3f2e65b56aac85 100755 (executable)
@@ -28,7 +28,8 @@ validate_lun_section() {
                'scsi_sn:string' \
                'sense_format:range(0, 1)' \
                'vendor_id:string' \
-               'rotation_rate:uinteger'
+               'rotation_rate:uinteger' \
+               'thin_provisioning:bool:0'
 }
 
 handle_lun() {
@@ -55,9 +56,20 @@ handle_lun() {
                bsoflags="--bsoflags $bsoflags"
        fi
 
+       if [ "$thin_provisioning" -eq 1 ]; then
+               [ "$type" = disk ] || {
+                       $logger "Thin provisioning is supported only for the 'disk' type" 
+                       return 1
+               }
+               [ "$bstype" = rdwr ] || {
+                       $logger "Thin provisioning is supported onfy for the 'rdwr' bstype"
+                       return 1
+               }
+       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 rotation_rate; do
+       for i in mode_page product_id product_rev readonly removable scsi_id scsi_sn sense_format vendor_id rotation_rate thin_provisioning; do
                eval params=\${$i+$i=\$$i,}\$params
        done