Accepting request 125060 from Base:System

- Remove "# pidfile: /var/run/tgtd.pid" from tgt.init, as it makes
  the script hang on systemd-based systems. This is the same bug as
  rh#797913, and the fix was used in Fedora. Apparently, there's no
  such pid file written by tgtd.

- Update to latest upstream release 1.0.23
  * Improved SCSI emulation
  * Various small fixes

OBS-URL: https://build.opensuse.org/request/show/125060
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/tgt?expand=0&rev=15
This commit is contained in:
Stephan Kulow 2012-06-18 15:34:41 +00:00 committed by Git OBS Bridge
commit 25ad93340f
9 changed files with 377 additions and 3579 deletions

View File

@ -1,108 +0,0 @@
/*
* SCSI target kernel/user interface
*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __SCSI_TARGET_IF_H
#define __SCSI_TARGET_IF_H
/* user -> kernel */
#define TGT_UEVENT_CMD_RSP 0x0001
#define TGT_UEVENT_IT_NEXUS_RSP 0x0002
#define TGT_UEVENT_TSK_MGMT_RSP 0x0003
/* kernel -> user */
#define TGT_KEVENT_CMD_REQ 0x1001
#define TGT_KEVENT_CMD_DONE 0x1002
#define TGT_KEVENT_IT_NEXUS_REQ 0x1003
#define TGT_KEVENT_TSK_MGMT_REQ 0x1004
struct tgt_event_hdr {
uint16_t version;
uint16_t status;
uint16_t type;
uint16_t len;
} __attribute__ ((aligned (sizeof(uint64_t))));
struct tgt_event {
struct tgt_event_hdr hdr;
union {
/* user-> kernel */
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 tag;
aligned_u64 uaddr;
aligned_u64 sense_uaddr;
uint32_t len;
uint32_t sense_len;
uint8_t rw;
} cmd_rsp;
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 mid;
} tsk_mgmt_rsp;
struct {
__s32 host_no;
__s32 result;
aligned_u64 itn_id;
__u32 function;
} it_nexus_rsp;
/* kernel -> user */
struct {
int host_no;
uint32_t data_len;
aligned_u64 itn_id;
uint8_t scb[16];
uint8_t lun[8];
int attribute;
aligned_u64 tag;
} cmd_req;
struct {
int host_no;
int result;
aligned_u64 itn_id;
aligned_u64 tag;
} cmd_done;
struct {
int host_no;
int function;
aligned_u64 itn_id;
aligned_u64 tag;
uint8_t lun[8];
aligned_u64 mid;
} tsk_mgmt_req;
struct {
__s32 host_no;
__u32 function;
aligned_u64 itn_id;
__u32 max_cmds;
__u8 initiator_id[16];
} it_nexus_req;
} p;
} __attribute__ ((aligned (sizeof(uint64_t))));
#define TGT_RING_SIZE (1UL << 16)
#endif

File diff suppressed because it is too large Load Diff

3
tgt-1.0.28.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:efbf102d2345f0648a091fbd58e3c35e0c810ed4a5f15c872bb8b28f090c5e08
size 193228

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:98fdd166cd0af2b944ab53df0d1f4290aacc833e3b49ee926e213339f31ca216
size 223414

View File

@ -1,260 +1,20 @@
diff --git a/scripts/tgt-setup-lun b/scripts/tgt-setup-lun
index 1e214ee..2ae9193 100755
--- a/scripts/tgt-setup-lun
+++ b/scripts/tgt-setup-lun
@@ -1,3 +1,5 @@
+#!/bin/bash
+
# LUN assignment script
#
# Copyright (C) 2007 Erez Zilber <erezz@voltaire.com>
@@ -17,8 +19,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-#!/bin/bash
-
usage()
{
name=$(basename $0)
diff --git a/usr/Makefile b/usr/Makefile
index a59364b..bf264f4 100644
index 64cb58c..deb7e39 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -50,7 +50,7 @@ INCLUDES += -I. -I../include -I$(KERNELSRC)/include
@@ -28,12 +28,15 @@ INCLUDES += -I.
CFLAGS += -D_GNU_SOURCE
CFLAGS += $(INCLUDES)
-CFLAGS += -g -O2 -Wall -Wstrict-prototypes -fPIC
+ifneq ($(OPTFLAGS),)
+CFLAGS += $(OPTFLAGS)
ifneq ($(DEBUG),)
CFLAGS += -g -O0 -ggdb -rdynamic
else
CFLAGS += -g -O2 -fno-strict-aliasing
endif
CFLAGS += -Wall -Wstrict-prototypes -fPIC
+endif
CFLAGS += -DTGT_VERSION=\"$(VERSION)$(EXTRAVERSION)\"
LIBS += -lpthread
diff --git a/usr/fc/fc.c b/usr/fc/fc.c
index febb1e9..59f7573 100644
--- a/usr/fc/fc.c
+++ b/usr/fc/fc.c
@@ -29,6 +29,8 @@
#include <syscall.h>
#include <unistd.h>
#include <linux/fs.h>
+#include <linux/types.h>
+typedef __u8 u8;
#include <scsi/scsi.h>
#include <sys/mman.h>
diff --git a/usr/iscsi/iscsi_rdma.c b/usr/iscsi/iscsi_rdma.c
index d3b5147..c155b48 100644
--- a/usr/iscsi/iscsi_rdma.c
+++ b/usr/iscsi/iscsi_rdma.c
@@ -144,7 +144,7 @@ struct conn_info {
/* but count so we can drain CQ on close */
int recvl_posted;
- struct tgt_event tx_sched;
+ struct tgtd_event tx_sched;
/* login phase resources, freed at full-feature */
void *srbuf_login;
@@ -196,7 +196,7 @@ struct iser_device {
void *mempool_listbuf;
struct ibv_mr *mempool_mr;
- struct tgt_event poll_sched;
+ struct tgtd_event poll_sched;
/* free and allocated mempool entries */
struct list_head mempool_free, mempool_alloc;
@@ -281,9 +281,9 @@ static void iscsi_rdma_release(struct iscsi_connection *conn);
static int iscsi_rdma_show(struct iscsi_connection *conn, char *buf,
int rest);
static void iscsi_rdma_event_modify(struct iscsi_connection *conn, int events);
-static void iser_sched_poll_cq(struct tgt_event *tev);
-static void iser_sched_consume_cq(struct tgt_event *tev);
-static void iser_sched_tx(struct tgt_event *evt);
+static void iser_sched_poll_cq(struct tgtd_event *tev);
+static void iser_sched_consume_cq(struct tgtd_event *tev);
+static void iser_sched_tx(struct tgtd_event *evt);
/*
* Called when ready for full feature, builds resources.
@@ -1058,7 +1058,7 @@ static void iser_poll_cq_armable(struct iser_device *dev)
/* Scheduled to poll cq after a completion event has been
received and acknowledged, if no more completions are found
the interrupts are re-armed */
-static void iser_sched_poll_cq(struct tgt_event *tev)
+static void iser_sched_poll_cq(struct tgtd_event *tev)
{
struct iser_device *dev = tev->data;
iser_poll_cq_armable(dev);
@@ -1069,7 +1069,7 @@ static void iser_sched_poll_cq(struct tgt_event *tev)
the notification interrupts were re-armed.
Intended to consume those remaining completions only,
this function does not re-arm interrupts. */
-static void iser_sched_consume_cq(struct tgt_event *tev)
+static void iser_sched_consume_cq(struct tgtd_event *tev)
{
struct iser_device *dev = tev->data;
int ret;
@@ -1112,7 +1112,7 @@ static void iser_cqe_handler(int fd __attribute__((unused)),
* tries to push tx on a connection, until nothing
* is ready anymore. No progress limit here.
*/
-static void iser_sched_tx(struct tgt_event *evt)
+static void iser_sched_tx(struct tgtd_event *evt)
{
struct conn_info *ci = evt->data;
struct iscsi_connection *conn = &ci->iscsi_conn;
diff --git a/usr/tgtd.c b/usr/tgtd.c
index 62aaa04..a226906 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -99,7 +99,7 @@ static int oom_adjust(void)
int tgt_event_add(int fd, int events, event_handler_t handler, void *data)
{
struct epoll_event ev;
- struct tgt_event *tev;
+ struct tgtd_event *tev;
int err;
tev = zalloc(sizeof(*tev));
@@ -123,9 +123,9 @@ int tgt_event_add(int fd, int events, event_handler_t handler, void *data)
return err;
}
-static struct tgt_event *tgt_event_lookup(int fd)
+static struct tgtd_event *tgt_event_lookup(int fd)
{
- struct tgt_event *tev;
+ struct tgtd_event *tev;
list_for_each_entry(tev, &tgt_events_list, e_list) {
if (tev->fd == fd)
@@ -136,7 +136,7 @@ static struct tgt_event *tgt_event_lookup(int fd)
void tgt_event_del(int fd)
{
- struct tgt_event *tev;
+ struct tgtd_event *tev;
tev = tgt_event_lookup(fd);
if (!tev) {
@@ -152,7 +152,7 @@ void tgt_event_del(int fd)
int tgt_event_modify(int fd, int events)
{
struct epoll_event ev;
- struct tgt_event *tev;
+ struct tgtd_event *tev;
tev = tgt_event_lookup(fd);
if (!tev) {
@@ -167,7 +167,7 @@ int tgt_event_modify(int fd, int events)
return epoll_ctl(ep_fd, EPOLL_CTL_MOD, fd, &ev);
}
-void tgt_init_sched_event(struct tgt_event *evt,
+void tgt_init_sched_event(struct tgtd_event *evt,
sched_event_handler_t sched_handler, void *data)
{
evt->sched_handler = sched_handler;
@@ -176,7 +176,7 @@ void tgt_init_sched_event(struct tgt_event *evt,
INIT_LIST_HEAD(&evt->e_list);
}
-void tgt_add_sched_event(struct tgt_event *evt)
+void tgt_add_sched_event(struct tgtd_event *evt)
{
if (!evt->scheduled) {
evt->scheduled = 1;
@@ -184,7 +184,7 @@ void tgt_add_sched_event(struct tgt_event *evt)
}
}
-void tgt_remove_sched_event(struct tgt_event *evt)
+void tgt_remove_sched_event(struct tgtd_event *evt)
{
if (evt->scheduled) {
evt->scheduled = 0;
@@ -195,7 +195,7 @@ void tgt_remove_sched_event(struct tgt_event *evt)
static int tgt_exec_scheduled(void)
{
struct list_head *last_sched;
- struct tgt_event *tev, *tevn;
+ struct tgtd_event *tev, *tevn;
int work_remains = 0;
if (!list_empty(&tgt_sched_events_list)) {
@@ -218,7 +218,7 @@ static void event_loop(void)
{
int nevent, i, sched_remains, timeout;
struct epoll_event events[1024];
- struct tgt_event *tev;
+ struct tgtd_event *tev;
retry:
sched_remains = tgt_exec_scheduled();
@@ -232,7 +232,7 @@ retry:
}
} else if (nevent) {
for (i = 0; i < nevent; i++) {
- tev = (struct tgt_event *) events[i].data.ptr;
+ tev = (struct tgtd_event *) events[i].data.ptr;
tev->handler(tev->fd, events[i].events, tev->data);
}
} else
diff --git a/usr/tgtd.h b/usr/tgtd.h
index da751c8..207c167 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -206,21 +206,21 @@ extern int tgt_bind_host_to_target(int tid, int host_no);
extern int tgt_unbind_host_to_target(int tid, int host_no);
extern int tgt_bound_target_lookup(int host_no);
-struct tgt_event;
-typedef void (*sched_event_handler_t)(struct tgt_event *tev);
+struct tgtd_event;
+typedef void (*sched_event_handler_t)(struct tgtd_event *tev);
-extern void tgt_init_sched_event(struct tgt_event *evt,
+extern void tgt_init_sched_event(struct tgtd_event *evt,
sched_event_handler_t sched_handler, void *data);
typedef void (*event_handler_t)(int fd, int events, void *data);
-extern int tgt_event_add(int fd, int events, event_handler_t handler, void *data);
-extern void tgt_event_del(int fd);
+extern int tgtd_event_add(int fd, int events, event_handler_t handler, void *data);
+extern void tgtd_event_del(int fd);
-extern void tgt_add_sched_event(struct tgt_event *evt);
-extern void tgt_remove_sched_event(struct tgt_event *evt);
+extern void tgt_add_sched_event(struct tgtd_event *evt);
+extern void tgt_remove_sched_event(struct tgtd_event *evt);
-extern int tgt_event_modify(int fd, int events);
+extern int tgtd_event_modify(int fd, int events);
extern int target_cmd_queue(int tid, struct scsi_cmd *cmd);
extern void target_cmd_done(struct scsi_cmd *cmd);
struct scsi_cmd *target_cmd_lookup(int tid, uint64_t itn_id, uint64_t tag);
@@ -269,7 +269,7 @@ extern int dtd_load_unload(int tid, uint64_t lun, int load, char *file);
extern int register_backingstore_template(struct backingstore_template *bst);
extern struct backingstore_template *get_backingstore_template(const char *name);
-struct tgt_event {
+struct tgtd_event {
union {
event_handler_t handler;
sched_event_handler_t sched_handler;
diff --git a/usr/tgtif.c b/usr/tgtif.c
index fd5ad5b..9b87b13 100644
--- a/usr/tgtif.c
+++ b/usr/tgtif.c
@@ -36,7 +36,7 @@
#ifndef aligned_u64
#define aligned_u64 unsigned long long __attribute__((aligned(8)))
#endif
-#include <scsi/scsi_tgt_if.h>
+#include "scsi_tgt_if.h"
#include "list.h"
#include "util.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Thu Jun 14 09:51:09 CEST 2012 - vuntz@opensuse.org
- Remove "# pidfile: /var/run/tgtd.pid" from tgt.init, as it makes
the script hang on systemd-based systems. This is the same bug as
rh#797913, and the fix was used in Fedora. Apparently, there's no
such pid file written by tgtd.
-------------------------------------------------------------------
Mon Jun 4 14:39:47 CEST 2012 - hare@suse.de
- Update to latest upstream release 1.0.23
* Improved SCSI emulation
* Various small fixes
-------------------------------------------------------------------
Mon Sep 21 11:02:59 CEST 2009 - dmueller@suse.de

130
tgt.init
View File

@ -16,10 +16,10 @@
#
#
# pidfile: /var/run/tgtd.pid
DAEMON=/usr/sbin/tgtd
PIDFILE=/var/run/tgtd.pid
TGTD_CONFIG=/etc/tgt/targets.conf
# Source LSB init functions
. /etc/rc.status
@ -28,29 +28,133 @@ rc_reset
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start()
{
echo "Starting target framework daemon"
# Start tgtd first.
tgtd &>/dev/null
RETVAL=$?
if [ "$RETVAL" -ne 0 ] ; then
rc_failed -v
else
# 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.
tgtadm --op update --mode sys --name State -v offline
# Configure the targets.
tgt-admin -e -c $TGTD_CONFIG
# Put tgtd into "ready" state.
tgtadm --op update --mode sys --name State -v ready
rc_failed 0
fi
rc_status -v
}
stop()
{
if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
forcedstop
fi
echo "Stopping target framework daemon"
# Remove all targets. It only removes targets which are not in use.
tgt-admin --update ALL -c /dev/null &>/dev/null
# tgtd will exit if all targets were removed
tgtadm --op delete --mode system &>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 107 ] ; then
rc_failed 7
[ "$TASK" != "restart" ] && exit 1
elif [ "$RETVAL" -ne 0 ] ; then
echo -n "(Some initiators are still connected)"
rc_failed 1
fi
rc_status -v
}
forcedstop()
{
# NOTE: Forced shutdown of the iscsi target may cause data corruption
# for initiators that are connected.
echo "Force-stopping target framework daemon"
# Offline everything first. May be needed if we're rebooting, but
# expect the initiators to reconnect cleanly when we boot again
# (i.e. we don't want them to reconnect to a tgtd which is still
# working, but the target is gone).
tgtadm --op update --mode sys --name State -v offline &>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 107 ] ; then
rc_failed 7
[ "$TASK" != "restart" ] && exit 1
else
tgt-admin --offline ALL
# Remove all targets, even if they are still in use.
tgt-admin --update ALL -c /dev/null -f
# It will shut down tgtd only after all targets were removed.
tgtadm --op delete --mode system
RETVAL=$?
if [ "$RETVAL" -ne 0 ] ; then
rc_failed 1
fi
fi
}
reload()
{
echo "Updating target framework daemon configuration"
# Update configuration for targets. Only targets which
# are not in use will be updated.
tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 107 ] ; then
rc_failed 7
fi
}
forcedreload()
{
echo "Force-updating target framework daemon configuration"
# Update configuration for targets, even those in use.
tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
RETVAL=$?
if [ "$RETVAL" -eq 107 ] ; then
rc_failed 7
fi
}
case "$1" in
start)
echo -n "Starting SCSI target service: "
modprobe crc32c
modprobe scsi_tgt
startproc -p $PIDFILE $DAEMON
start
rc_status -v
;;
stop)
echo -n "Stopping SCSI target service: "
tgtadm --op delete >/dev/null 2>/dev/null
killproc -p $PIDFILE -TERM $DAEMON
modprobe -r scsi_tgt 2>/dev/null
RETVAL=$?
modprobe -r crc32c 2>/dev/null
stop
if [ $RETVAL != "0" ]; then
rc_failed
rc_failed
else
modprobe -r scsi_tgt 2>/dev/null
modprobe -r crc32c 2>/dev/null
rc_failed 0
fi
rc_status -v
;;
forcedstop)
forcedstop
rc_status -v
;;
forcereload)
forcedreload
rc_status -v
;;
restart|reload)
$0 stop
$0 start
TASK=$1
stop
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
start
fi
rc_status -v
;;
status)
echo -n "Checking for SCSI target service"
@ -58,7 +162,7 @@ case "$1" in
rc_status -v
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
echo $"Usage: $0 {start|stop|restart|reload|forcedreload|forcedstop|status}"
exit 1
esac
rc_exit

View File

@ -1,7 +1,7 @@
#
# spec file for package tgt (Version 0.9.0)
# spec file for package tgt
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -15,28 +15,26 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: tgt
BuildRequires: libaio-devel openssl-devel perl-Config-General
BuildRequires: docbook-xsl-stylesheets
BuildRequires: libaio-devel
BuildRequires: libxslt
BuildRequires: openssl-devel
BuildRequires: perl-Config-General
Obsoletes: iscsitarget
Provides: iscsitarget
Requires: perl-Config-General
Url: http://stgt.berlios.de
PreReq: %fillup_prereq %insserv_prereq
Version: 1.0.28
Release: 0
Summary: Generic Linux target framework (tgt)
License: GPL-2.0+
Group: System/Daemons
PreReq: %fillup_prereq %insserv_prereq
AutoReqProv: on
Version: 0.9.0
Release: 2
Summary: Generic Linux target framework (tgt)
Source: %{name}-20080805.tar.bz2
Source: %{name}-%{version}.tar.bz2
Source1: %{name}.init
Source2: scsi_tgt_if.h
Source3: %{name}.services
Patch1: %{name}-0.9.0-update
Patch2: %{name}-git-update
Patch1: %{name}-git-update
Patch11: %{name}-fix-build
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -56,14 +54,11 @@ Authors:
Mike Christie <michaelc@cs.wisc.edu>
%prep
%setup -n %{name}-20080805
%setup -n %{name}-%{version}
%patch1 -p1
%patch2 -p1
%patch11 -p1
cp %{S:2} usr
%build
cd usr
%ifarch ppc ppc64
%define backends ISCSI=1 FCP=1 FCOE=1 IBMVIO=1
%else
@ -72,10 +67,7 @@ cd usr
%{__make} OPTFLAGS="${RPM_OPT_FLAGS}" %{backends}
%install
cd usr
%{__make} DESTDIR=${RPM_BUILD_ROOT} install
cd ../scripts
install -vD -m 755 tgt-admin ${RPM_BUILD_ROOT}/usr/sbin/tgt-admin
%{__make} DESTDIR=${RPM_BUILD_ROOT} docdir=%_docdir/%{name} install
install -vD -m 755 %{S:1} ${RPM_BUILD_ROOT}/etc/init.d/tgtd
ln -sf /etc/init.d/tgtd ${RPM_BUILD_ROOT}/usr/sbin/rctgtd
install -vD %{S:3} ${RPM_BUILD_ROOT}/etc/sysconfig/SuSEfirewall2.d/services/iscsitarget
@ -97,8 +89,13 @@ rm -f filelist
%defattr(-,root,root)
/usr/sbin/*
/etc/init.d/tgtd
%dir /etc/tgt
%dir /etc/tgt/examples
%config %attr(0644,root,root) /etc/tgt/targets.conf
%config %attr(0644,root,root) /etc/tgt/examples/*
%config %attr(0644,root,root) /etc/sysconfig/SuSEfirewall2.d/services/iscsitarget
%doc README doc/README.iscsi doc/TODO
%doc README doc/README.iscsi doc/README.iser doc/README.lu_configuration
%doc doc/README.mmc doc/README.passthrough doc/README.sbcjukebox doc/README.ssc
%doc %{_mandir}/man8/*
%changelog