!1 scsi-target-utils: Package init

Merge pull request !1 from Grooooot/master
This commit is contained in:
openeuler-ci-bot 2020-02-19 16:22:18 +08:00 committed by Gitee
commit 5c6b162ae7
10 changed files with 616 additions and 0 deletions

View File

@ -0,0 +1,67 @@
From 0eb1f18cda01673eb3661641351ab6e7ac2644e2 Mon Sep 17 00:00:00 2001
From: Andy Grover <agrover@redhat.com>
Date: Wed, 2 Nov 2011 22:15:32 -0700
Subject: [PATCH] remove check for xsltproc
It should always be there, since we added libxslt as a BuildRequires.
Use local stylesheet.
Signed-off-by: Andy Grover <agrover@redhat.com>
---
doc/Makefile | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/doc/Makefile b/doc/Makefile
index 0516dc8..91a51f6 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -33,35 +33,38 @@ clean:
rm -f $(XMLMAN) $(XMLHTML)
-rm -f manpages htmlpages
+STYLEMAN = /usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl
+STYLEHTML = /usr/share/sgml/docbook/xsl-stylesheets/html/docbook.xsl
+
manpages/tgtd.8: tgtd.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEMAN) $<
htmlpages/tgtd.8.html: tgtd.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEHTML) $<
manpages/tgtadm.8: tgtadm.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEMAN) $<
htmlpages/tgtadm.8.html: tgtadm.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEHTML) $<
manpages/tgt-admin.8: tgt-admin.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEMAN) $<
htmlpages/tgt-admin.8.html: tgt-admin.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEHTML) $<
manpages/tgtimg.8: tgtimg.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEMAN) $<
htmlpages/tgtimg.8.html: tgtimg.8.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEHTML) $<
manpages/targets.conf.5: targets.conf.5.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEMAN) $<
htmlpages/targets.conf.5.html: targets.conf.5.xml
- -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+ $(XSLTPROC) -o $@ $(STYLEHTML) $<
manpages/tgt-setup-lun.8: tgt-setup-lun.8.xml
-test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<

44
0003-default-config.patch Normal file
View File

@ -0,0 +1,44 @@
From e09e0138d87107298d7ac233f234ca5ff4fd4fa9 Mon Sep 17 00:00:00 2001
From: Andy Grover <agrover@redhat.com>
Date: Tue, 18 Jun 2013 13:43:22 -0700
Subject: [PATCH] default-config
---
scripts/initd.sample | 2 +-
scripts/tgt-admin | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/initd.sample b/scripts/initd.sample
index 9ca86ce..7b67722 100755
--- a/scripts/initd.sample
+++ b/scripts/initd.sample
@@ -13,7 +13,7 @@
# Description: tgtd provides the SCSI and software transport target state machine daemon.
### END INIT INFO
-TGTD_CONFIG=/etc/tgt/targets.conf
+TGTD_CONFIG=/etc/tgt/tgtd.conf
TASK=$1
diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index 8f6fb7f..b9c9658 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# This tools parses /etc/tgt/targets.conf file and configures tgt
+# This tools parses /etc/tgt/tgtd.conf file and configures tgt
#
# Author: Tomasz Chmielewski
# License: GPLv2
@@ -11,7 +11,7 @@ use Config::General qw(ParseConfig);
use Getopt::Long;
# Our config file
-my $configfile = "/etc/tgt/targets.conf";
+my $configfile = "/etc/tgt/tgtd.conf";
sub usage {
print <<EOF;

224
sample.conf Normal file
View File

@ -0,0 +1,224 @@
# This is a sample config file for tgt-admin.
# The files ending with '.conf' in this directory will be included.
#
# The "#" symbol disables the processing of a line.
# Sample target with one LUN only. Defaults to allow access for all initiators:
#<target iqn.2008-09.com.example:server.target1>
# backing-store /dev/LVM/somedevice
#</target>
# Similar, but we use "direct-store" instead of "backing-store".
# "direct-store" reads drive parameters with sg_inq command and sets them to
# the target.
# Parameters fatched with sg_inq are:
# - Vendor identification
# - Product identification
# - Product revision level
# - Unit serial number (if present)
# We also specify "incominguser".
#<target iqn.2008-09.com.example:server.target2>
# direct-store /dev/sdd
# incominguser someuser secretpass12
#</target>
# An example with multiple LUNs, disabled write-cache (tgtd enables write-cache
# by default) and vendor identification set to "MyVendor"
#<target iqn.2008-09.com.example:server.target3>
# backing-store /dev/LVM/somedevice1 # Becomes LUN 1
# backing-store /dev/LVM/somedevice2 # Becomes LUN 2
# backing-store /dev/LVM/somedevice3 # Becomes LUN 3
# write-cache off
# vendor_id MyCompany Inc.
#</target>
# Similar to the one above, but we fetch vendor_id, product_id, product_rev and
# scsi_sn from the disks.
# Vendor identification (vendor_id) is replaced in all disks by "MyVendor"
#<target iqn.2008-09.com.example:server.target4>
# direct-store /dev/sdb # Becomes LUN 1
# direct-store /dev/sdc # Becomes LUN 2
# direct-store /dev/sdd # Becomes LUN 3
# write-cache off
# vendor_id MyCompany Inc.
#</target>
# Note that "first-device-first-lun numbering" will work only for simple
# scenarios above, where _only_ direct-store _or_ backing-store is used.
# If you mix backing-store and direct-store, then all backing-store entries
# are processed before direct-store-entries.
#<target iqn.2008-09.com.example:server.target4>
# direct-store /dev/sdb # Becomes LUN 3
# backing-store /dev/sdc # Becomes LUN 1
# direct-store /dev/sdd # Becomes LUN 4
# backing-store /dev/sde # Becomes LUN 2
#</target>
# Even more complicated example - each device has different parameters.
# You can use indentation to make the config file more readable.
# Note that LUNs will be assigned more or less randomly here (and still
# backing-store get LUNs assigned before drect-store).
# You can specify multiple mode_page parameters (they are commented out
# in this example).
# Note that some parameters (write-cache, scsi_sn) were specified "globally".
# "Global" parameters will be applied to all LUNs; they can be overwritten
# "locally", per LUN.
# If lun is not specified, it will be allocated automatically (first available).
#<target iqn.2008-09.com.example:server.target5>
# <direct-store /dev/sdd>
# vendor_id VENDOR1
# removable 1
# device-type cd
# lun 1
# </direct-store>
# <direct-store /dev/sda>
# vendor_id VENDOR2
# lun 2
# </direct-store>
# <backing-store /dev/sdb1>
# vendor_id back1
# scsi_sn SERIAL
# write-cache on
# lun 3 # lun is commented out - will be allocated automatically
# </backing-store>
# <backing-store /dev/sdd1>
# vendor_id back2
#mode_page 8:0:18:0x10:0:0xff....
#mode_page 8:0:18:0x10:0:0xff....
#bs-type aio
# lun 15
# </backing-store>
# Some more parameters which can be specified locally or globally:
#scsi_id ...
#scsi_sn ...
#vendor_id ...
#product_id ...
#product_rev ...
#sense_format ...
#removable ...
#online ...
#path ...
#mode_page 8:0:18:0x10:0:0xff....
#mode_page 8:0:18:0x10:0:0xff....
#device-type ...
#bs-type ... # backing store type - default rdwr, can be aio, mmap, etc...
#allow-in-use yes # if specified globally, can't be overwritten locally
# write-cache off
# scsi_sn multipath-10
# Parameters below are only global. They can't be configured per LUN.
# Only allow connections from 192.168.100.1 and 192.168.200.5
# initiator-address 192.168.100.1
# initiator-address 192.168.200.5
# Tuning parameters (global, per target)
#MaxRecvDataSegmentLength 8192
#MaxXmitDataSegmentLength 8192
#HeaderDigest None
#DataDigest None
#InitialR2T Yes
#MaxOutstandingR2T 1
#ImmediateData Yes
#FirstBurstLength 65536
#MaxBurstLength 262144
#DataPDUInOrder Yes
#DataSequenceInOrder Yes
#ErrorRecoveryLevel 0
#IFMarker No
#OFMarker No
#DefaultTime2Wait 2
#DefaultTime2Retain 20
#OFMarkInt Reject
#IFMarkInt Reject
#MaxConnections 1
# Allowed incoming users
# incominguser user1 secretpass12
# incominguser user2 secretpass23
# Outgoing user
# outgoinguser userA secretpassA
#</target>
# The device will have lun 1 unless you specify something else
#<target iqn.2008-09.com.example:server.target6>
# backing-store /dev/LVM/somedevice
# lun 10
#</target>
# Devices which are in use (by system: mounted, for swap, part of RAID, or by
# userspace: dd, by tgtd for another target etc.) can't be used, unless you use
# --force flag or add 'allow-in-use yes' option
#<target iqn.2008-09.com.example:server.target7>
# backing-store /dev/LVM/somedevice
# allow-in-use yes
#</target>
#<target iqn.2008-09.com.example:server.target8>
# <backing-store /dev/LVM/somedevice>
# scsi_sn serial1
# </backing-store>
# <backing-store /dev/LVM/somedevice2>
# scsi_sn serial2
# </backing-store>
# allow-in-use yes
#</target>
# Not supported configurations, and therefore, commented out:
#<target iqn.2008-09.com.example:server.target9>
# backing-store /dev/LVM/somedevice1
# backing-store /dev/LVM/somedevice2
# lun 10
# lun 11
#</target>
#<target iqn.2008-09.com.example:server.target10>
# <direct-store /dev/sdd>
# vendor_id VENDOR1
# </direct-store>
#
# direct-store /dev/sdc
#</target>
# This one will break the parser:
#<target iqn.2008-09.com.example:server.target11>
# <direct-store /dev/sdd>
# vendor_id VENDOR1
# </direct-store>
#
# direct-store /dev/sdc
#
# <direct-store /dev/sdd>
# vendor_id VENDOR1
# </direct-store>
#</target>

121
scsi-target-utils.spec Normal file
View File

@ -0,0 +1,121 @@
%global oname tgt
%global with_rdma 1
%global with_rbd 1
%global with_glfs 1
Summary: The SCSI target daemon and utility programs
Name: scsi-target-utils
Version: 1.0.79
Release: 1
License: GPLv2
URL: http://stgt.sourceforge.net/
Source0: https://github.com/fujita/tgt/archive/v%{version}/tgt-v%{version}.tar.gz
Source1: tgtd.service
Source2: sysconfig.tgtd
Source3: targets.conf
Source4: sample.conf
Source5: tgtd.conf
Patch1: 0002-remove-check-for-xsltproc.patch
Patch2: 0003-default-config.patch
Patch3: tgt-1.0.79-Adapt-to-glusterfs-api-7.6.3.patch
BuildRequires: docbook-style-xsl gcc libaio-devel libxslt perl-generators pkgconfig systemd-devel systemd-units
%if 0%{?with_rdma}
BuildRequires: libibverbs-devel librdmacm-devel
Requires: libibverbs librdmacm
%endif
Requires: lsof sg3_utils
Requires(post): systemd-units
%description
The SCSI target package contains the daemon and tools to setup a SCSI targets.
Currently, software iSCSI targets are supported.
%if 0%{?with_rbd}
%package rbd
Summary: Support for the Ceph rbd backstore to scsi-target-utils
BuildRequires: librbd-devel
Requires: %{name}%{?_isa} = %{version}-%{release}
%description rbd
Adds support for the Ceph rbd backstore to scsi-target-utils.
%endif
%if 0%{?with_glfs}
%package gluster
Summary: Support for the Gluster backstore to scsi-target-utils
BuildRequires: glusterfs-api-devel
Requires: %{name}%{?_isa} = %{version}-%{release}
%description gluster
Adds support for the Gluster glfs backstore to scsi-target-utils.
%endif
%package_help
%prep
%autosetup -n %{oname}-%{version} -Sgit -p1
%build
%{__sed} -i -e 's|-g -O2 -fno-strict-aliasing|%{optflags} -fcommon|' -e 's| -Werror | |' usr/Makefile
%{__make} %{?_smp_mflags} %{?with_rdma:ISCSI_RDMA=1} %{?with_rbd:CEPH_RBD=1} %{?with_glfs:GLFS_BD=1} SD_NOTIFY=1 libdir=%{_libdir}/tgt
%install
install -D -p -m 0755 scripts/tgt-setup-lun %{buildroot}%{_sbindir}/tgt-setup-lun
install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_unitdir}/tgtd.service
install -p -m 0755 scripts/tgt-admin %{buildroot}/%{_sbindir}/tgt-admin
install -D -p -m 0644 doc/manpages/targets.conf.5 %{buildroot}/%{_mandir}/man5/targets.conf.5
install -D -p -m 0644 doc/manpages/tgtadm.8 %{buildroot}/%{_mandir}/man8/tgtadm.8
install -p -m 0644 doc/manpages/tgt-admin.8 %{buildroot}/%{_mandir}/man8
install -p -m 0644 doc/manpages/tgt-setup-lun.8 %{buildroot}/%{_mandir}/man8
install -D -p -m 0600 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/tgtd
install -D -p -m 0600 %{SOURCE3} %{buildroot}%{_sysconfdir}/tgt/targets.conf
install -D -p -m 0600 %{SOURCE4} %{buildroot}%{_sysconfdir}/tgt/conf.d/sample.conf
install -p -m 0600 %{SOURCE5} %{buildroot}%{_sysconfdir}/tgt/tgtd.conf
pushd usr
%{__make} install %{?with_rdma:ISCSI_RDMA=1} %{?with_rbd:CEPH_RBD=1} %{?with_glfs:GLFS_BD=1} SD_NOTIFY=1 DESTDIR=%{buildroot} sbindir=%{_sbindir} libdir=%{_libdir}/tgt
%post
%systemd_post tgtd.service
%preun
%systemd_preun tgtd.service
%postun
%systemd_postun tgtd.service
%files
%doc README doc/README.iscsi doc/README.iser doc/README.lu_configuration doc/README.mmc doc/README.ssc
%{_sbindir}/tgtd
%{_sbindir}/tgtadm
%{_sbindir}/tgt-setup-lun
%{_sbindir}/tgt-admin
%{_sbindir}/tgtimg
%{_unitdir}/tgtd.service
%{_sysconfdir}/tgt
%{_sysconfdir}/tgt/conf.d
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/tgtd
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/tgt/targets.conf
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/tgt/tgtd.conf
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/tgt/conf.d/sample.conf
%if 0%{?with_rbd}
%files rbd
%{_libdir}/tgt/backing-store/bs_rbd.so
%doc doc/README.rbd
%endif
%if 0%{?with_glfs}
%files gluster
%{_libdir}/tgt/backing-store/bs_glfs.so
%doc doc/README.glfs
%endif
%files help
%{_mandir}/man5/*
%{_mandir}/man8/*
%changelog
* Fri Dec 13 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.0.79-1
- Package init

5
sysconfig.tgtd Normal file
View File

@ -0,0 +1,5 @@
# options for tgtd
TGTD_OPTS=""
# configuration file
TGTD_CONFIG=/etc/tgt/tgtd.conf

17
targets.conf Normal file
View File

@ -0,0 +1,17 @@
# This is a sample config file for tgt-admin.
#
# The "#" symbol disables the processing of a line.
# Set the driver. If not specified, defaults to "iscsi".
default-driver iscsi
# Set iSNS parameters, if needed
#iSNSServerIP 192.168.111.222
#iSNSServerPort 3205
#iSNSAccessControl On
#iSNS On
# Continue if tgtadm exits with non-zero code (equivalent of
# --ignore-errors command line option)
#ignore-errors yes

View File

@ -0,0 +1,100 @@
From ee3456567a639fbff8ce33c5fe166efaed5cee26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 4 Jul 2019 18:30:28 +0200
Subject: [PATCH] Adapt to glusterfs-api 7.6.3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Glusterfs API has changed. Some functions as can be seen in glusterfs-6.3 got
new arguments.
Samba dealt with it by using NULL arguments
<https://bugzilla.samba.org/show_bug.cgi?id=13330>. This patch mimics it.
Not tested.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
usr/bs_glfs.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/usr/bs_glfs.c b/usr/bs_glfs.c
index 93984b4..9da30e1 100644
--- a/usr/bs_glfs.c
+++ b/usr/bs_glfs.c
@@ -110,7 +110,7 @@ static void bs_glfs_request(struct scsi_cmd *cmd)
break;
}
- ret = glfs_pread(gfd, tmpbuf, length, offset, lu->bsoflags);
+ ret = glfs_pread(gfd, tmpbuf, length, offset, lu->bsoflags, NULL);
if (ret != length) {
set_medium_error(&result, &key, &asc);
@@ -147,7 +147,7 @@ static void bs_glfs_request(struct scsi_cmd *cmd)
break;
}
- ret = glfs_pread(gfd, tmpbuf, length, offset, SEEK_SET);
+ ret = glfs_pread(gfd, tmpbuf, length, offset, SEEK_SET, NULL);
if (ret != length) {
set_medium_error(&result, &key, &asc);
@@ -190,7 +190,7 @@ static void bs_glfs_request(struct scsi_cmd *cmd)
key = ILLEGAL_REQUEST;
asc = ASC_INVALID_FIELD_IN_CDB;
} else {
- glfs_fdatasync(gfd);
+ glfs_fdatasync(gfd, NULL, NULL);
}
break;
case WRITE_VERIFY:
@@ -204,7 +204,7 @@ static void bs_glfs_request(struct scsi_cmd *cmd)
length = scsi_get_out_length(cmd);
write_buf = scsi_get_out_buffer(cmd);
write:
- ret = glfs_pwrite(gfd, write_buf, length, offset, lu->bsoflags);
+ ret = glfs_pwrite(gfd, write_buf, length, offset, lu->bsoflags, NULL, NULL);
if (ret == length) {
struct mode_pg *pg;
@@ -222,7 +222,7 @@ write:
}
if (((cmd->scb[0] != WRITE_6) && (cmd->scb[1] & 0x8)) ||
!(pg->mode_data[0] & 0x04))
- glfs_fdatasync(gfd);
+ glfs_fdatasync(gfd, NULL, NULL);
} else
set_medium_error(&result, &key, &asc);
@@ -258,7 +258,7 @@ write:
}
ret = glfs_pwrite(gfd, tmpbuf, blocksize,
- offset, lu->bsoflags);
+ offset, lu->bsoflags, NULL, NULL);
if (ret != blocksize)
set_medium_error(&result, &key, &asc);
@@ -273,7 +273,7 @@ write:
case READ_16:
length = scsi_get_in_length(cmd);
ret = glfs_pread(gfd, scsi_get_in_buffer(cmd),
- length, offset, SEEK_SET);
+ length, offset, SEEK_SET, NULL);
if (ret != length) {
eprintf("Error on read %x %x", ret, length);
@@ -299,7 +299,7 @@ verify:
break;
}
- ret = glfs_pread(gfd, tmpbuf, length, offset, lu->bsoflags);
+ ret = glfs_pread(gfd, tmpbuf, length, offset, lu->bsoflags, NULL);
if (ret != length)
set_medium_error(&result, &key, &asc);
--
2.20.1

BIN
tgt-v1.0.79.tar.gz Normal file

Binary file not shown.

5
tgtd.conf Normal file
View File

@ -0,0 +1,5 @@
# The default config file
include /etc/tgt/targets.conf
# Config files from other packages etc.
include /etc/tgt/conf.d/*.conf

33
tgtd.service Normal file
View File

@ -0,0 +1,33 @@
[Unit]
Description=tgtd iSCSI target daemon
After=network.target
[Service]
EnvironmentFile=/etc/sysconfig/tgtd
ExecStart=/usr/sbin/tgtd -f $TGTD_OPTS
# see bz 848942. workaround for a race for now.
ExecStartPost=/bin/sleep 5
# Put tgtd into "offline" state until all the targets are configured.
# We don't want initiators to (re)connect and fail the connection
# if it's not ready.
ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
# Configure the targets.
ExecStartPost=/usr/sbin/tgt-admin -e -c $TGTD_CONFIG
# Put tgtd into "ready" state.
ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v ready
# Update configuration for targets. Only targets which
# are not in use will be updated.
ExecReload=/usr/sbin/tgt-admin --update ALL -c $TGTD_CONFIG
# NOTE: Shutdown of the iscsi target may cause data corruption
# for initiators that are connected.
ExecStop=/usr/sbin/tgtadm --op update --mode sys --name State -v offline
# Remove all targets. It only removes targets which are not in use.
ExecStop=/usr/sbin/tgt-admin --update ALL -c /dev/null
# tgtd will exit if all targets were removed
ExecStop=/usr/sbin/tgtadm --op delete --mode system
[Install]
WantedBy=multi-user.target