SHA256
1
0
forked from pool/open-iscsi
OBS User unknown 2008-04-29 22:53:50 +00:00 committed by Git OBS Bridge
parent 422bfe39c4
commit 0a0d6ef9fe
13 changed files with 12442 additions and 6504 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,112 +0,0 @@
commit a9552e7d8651ecdaefc39ea7913ba2a382a025fe
Author: Hannes Reinecke <hare@suse.de>
Date: Mon Mar 10 10:16:46 2008 +0100
Add SUSE boot script
For root on iSCSI SUSE requires a separate boot script to start
up iscsid as soon as possible.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/Makefile b/Makefile
index 046c0f9..8eb812c 100644
--- a/Makefile
+++ b/Makefile
@@ -79,6 +79,8 @@ install_initd_suse:
$(INSTALL) -d $(DESTDIR)$(initddir)
$(INSTALL) -m 755 etc/initd/initd.suse \
$(DESTDIR)$(initddir)/open-iscsi
+ $(INSTALL) -m 755 etc/initd/boot.suse \
+ $(DESTDIR)$(initddir)/boot.open-iscsi
install_initd_redhat:
$(INSTALL) -d $(DESTDIR)$(initddir)
diff --git a/etc/initd/boot.suse b/etc/initd/boot.suse
new file mode 100644
index 0000000..df64e21
--- /dev/null
+++ b/etc/initd/boot.suse
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# /etc/init.d/iscsi
+#
+### BEGIN INIT INFO
+# Provides: iscsiboot
+# Required-Start: boot.proc
+# Should-Start:
+# Required-Stop:
+# Should-Stop:
+# Default-Start: B
+# Default-Stop:
+# Short-Description: Starts the iSCSI initiator daemon
+#
+### END INIT INFO
+
+ISCSIADM=/sbin/iscsiadm
+PID_FILE=/var/run/iscsi.pid
+CONFIG_FILE=/etc/iscsid.conf
+DAEMON=/sbin/iscsid
+ARGS="-c $CONFIG_FILE -p $PID_FILE"
+
+# Source LSB init functions
+. /etc/rc.status
+
+#
+# This service is run right after booting. So all activated targets
+# must be enabled during mkinitrd run and thus should not be removed
+# when the open-iscsi service is stopped.
+#
+iscsi_mark_root_nodes()
+{
+ $ISCSIADM -m session 2> /dev/null | while read t num i target ; do
+ ip=${i%%:*}
+ STARTUP=`$ISCSIADM -m node -p $ip -T $target | grep "node.conn\[0\].startup" | cut -d' ' -f3`
+ if [ "$STARTUP" != "onboot" ] ; then
+ $ISCSIADM -m node -p $ip -T $target -o update -n node.conn[0].startup -v onboot
+ fi
+ done
+}
+
+# Reset status of this service
+rc_reset
+
+# We only need to start this for root on iSCSI
+if ! grep -q iscsi_tcp /proc/modules ; then
+ rc_failed 6
+ rc_exit
+fi
+
+case "$1" in
+ start)
+ [ ! -d /var/lib/open-iscsi ] && mkdir -p /var/lib/open-iscsi
+ echo -n "Starting iSCSI initiator for the root device: "
+ startproc $DAEMON $ARGS
+ rc_status -v
+ iscsi_mark_root_nodes
+ ;;
+ stop)
+ rc_failed 0
+ ;;
+ status)
+ echo -n "Checking for iSCSI initiator service: "
+ if checkproc $DAEMON ; then
+ rc_status -v
+ else
+ rc_failed 3
+ rc_status -v
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart}"
+ exit 1
+ ;;
+esac
+rc_exit
+

View File

@ -1,90 +0,0 @@
commit fa1429ee35e2dc2ea4895ec38216482afc3d95b5
Author: Hannes Reinecke <hare@suse.de>
Date: Wed Apr 2 11:31:18 2008 +0200
log_syslog might crash upon failure
log_dequeue returns 1 on two conditions; either the log queue is empty entirely
or this is the last message on the queue. When the first condition is true the
logger will crash as it tries to access an invalid message.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 2959821..2fbc387 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
if ((mgmt_ipc_fd = mgmt_ipc_listen()) < 0) {
log_close(log_pid);
- exit(-1);
+ exit(1);
}
if (log_daemon) {
@@ -413,7 +413,7 @@ int main(int argc, char *argv[])
if ((control_fd = ipc->ctldev_open()) < 0) {
log_close(log_pid);
- exit(-1);
+ exit(1);
}
chdir("/");
@@ -430,7 +430,7 @@ int main(int argc, char *argv[])
} else {
if ((control_fd = ipc->ctldev_open()) < 0) {
log_close(log_pid);
- exit(-1);
+ exit(1);
}
}
diff --git a/usr/log.c b/usr/log.c
index 9b82c46..a738454 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -196,7 +196,7 @@ int log_dequeue (void * buff)
int len;
if (la->empty)
- return 1;
+ return 0;
len = strlen((char *)&src->str) * sizeof(char) +
sizeof(struct logmsg) + 1;
@@ -215,7 +215,7 @@ int log_dequeue (void * buff)
memset((void *)src, 0, len);
- return la->empty;
+ return len;
}
/*
@@ -314,19 +314,22 @@ static void __dump_char(int level, unsigned char *buf, int *cp, int ch)
static void log_flush(void)
{
+ int msglen;
+
while (!la->empty) {
la->ops[0].sem_op = -1;
if (semop(la->semid, la->ops, 1) < 0) {
syslog(LOG_ERR, "semop up failed %d", errno);
exit(1);
}
- log_dequeue(la->buff);
+ msglen = log_dequeue(la->buff);
la->ops[0].sem_op = 1;
if (semop(la->semid, la->ops, 1) < 0) {
syslog(LOG_ERR, "semop down failed");
exit(1);
}
- log_syslog(la->buff);
+ if (msglen)
+ log_syslog(la->buff);
}
}

View File

@ -1,151 +0,0 @@
commit 824e3244cd75d33653eacde88acc8b456145543c
Author: Hannes Reinecke <hare@suse.de>
Date: Fri Apr 4 13:14:14 2008 +0200
Cleanup IPC segments and identifiers
Upon error we're not cleaning up IPC identifiers properly,
hence we're leaking IPC ids to the system. Not good.
And we're not invalidating the logarea itself, making the
daemon crash when started twice.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/usr/log.c b/usr/log.c
index a738454..013caed 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -37,6 +37,33 @@ int log_level = 0;
static int log_stop_daemon = 0;
+static void free_logarea (void)
+{
+ int shmid;
+
+ if (!la)
+ return;
+
+ if (la->semid != -1)
+ semctl(la->semid, 0, IPC_RMID, la->semarg);
+ if (la->buff) {
+ shmdt(la->buff);
+ shmctl(la->shmid_buff, IPC_RMID, NULL);
+ la->buff = NULL;
+ la->shmid_buff = -1;
+ }
+ if (la->start) {
+ shmdt(la->start);
+ shmctl(la->shmid_msg, IPC_RMID, NULL);
+ la->start = NULL;
+ la->shmid_msg = -1;
+ }
+ shmid = la->shmid;
+ shmdt(la);
+ shmctl(shmid, IPC_RMID, NULL);
+ la = NULL;
+}
+
static int logarea_init (int size)
{
int shmid;
@@ -48,21 +75,28 @@ static int logarea_init (int size)
return 1;
la = shmat(shmid, NULL, 0);
- if (!la)
+ if (!la) {
+ shmctl(shmid, IPC_RMID, NULL);
return 1;
+ }
+ la->shmid = shmid;
+ la->start = NULL;
+ la->buff = NULL;
+ la->semid = -1;
if (size < MAX_MSG_SIZE)
size = DEFAULT_AREA_SIZE;
if ((shmid = shmget(IPC_PRIVATE, size,
0644 | IPC_CREAT | IPC_EXCL)) == -1) {
- shmdt(la);
+ free_logarea();
return 1;
}
+ la->shmid_msg = shmid;
- la->start = shmat(shmid, NULL, 0);
+ la->start = shmat(la->shmid_msg, NULL, 0);
if (!la->start) {
- shmdt(la);
+ free_logarea();
return 1;
}
memset(la->start, 0, size);
@@ -74,32 +108,27 @@ static int logarea_init (int size)
if ((shmid = shmget(IPC_PRIVATE, MAX_MSG_SIZE + sizeof(struct logmsg),
0644 | IPC_CREAT | IPC_EXCL)) == -1) {
- shmdt(la->start);
- shmdt(la);
+ free_logarea();
return 1;
}
la->buff = shmat(shmid, NULL, 0);
if (!la->buff) {
- shmdt(la->start);
- shmdt(la);
+ free_logarea();
return 1;
}
if ((la->semid = semget(SEMKEY, 1, 0600 | IPC_CREAT)) < 0) {
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
+ free_logarea();
return 1;
}
la->semarg.val=1;
if (semctl(la->semid, 0, SETVAL, la->semarg) < 0) {
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
+ free_logarea();
return 1;
}
+ la->shmid_buff = shmid;
la->ops[0].sem_num = 0;
la->ops[0].sem_flg = 0;
@@ -107,14 +136,6 @@ static int logarea_init (int size)
}
-static void free_logarea (void)
-{
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
- semctl(la->semid, 0, IPC_RMID, la->semarg);
-}
-
#if LOGDBG
static void dump_logarea (void)
{
diff --git a/usr/log.h b/usr/log.h
index 4816a1b..4d2a265 100644
--- a/usr/log.h
+++ b/usr/log.h
@@ -51,6 +51,9 @@ struct logmsg {
};
struct logarea {
+ int shmid;
+ int shmid_msg;
+ int shmid_buff;
int empty;
void *head;
void *tail;

View File

@ -1,52 +0,0 @@
--- open-iscsi-2.0-707/etc/initd/initd.suse 2007/11/15 13:42:43 1.37
+++ open-iscsi-2.0-707/etc/initd/initd.suse 2007/11/30 08:10:00
@@ -94,6 +94,38 @@
done
}
+iscsi_discover_all_targets()
+{
+ # Strip off any existing ID information
+ RAW_NODE_LIST=`iscsiadm -m node | sed -nre 's/^(\[[0-9a-f]*\] )?(.*)$/\2/p'`
+ # Obtain IPv4 list
+ IPV4_NODE_LIST=`echo "$RAW_NODE_LIST" | sed -nre 's/^([0-9]{1,3}(\.[0-9]{1,3}){3}):[^: ]* (.*)$/\1 \3/p'`
+ # Now obtain IPv6 list
+ IPV6_NODE_LIST=`echo "$RAW_NODE_LIST" | sed -nre 's/^([0-9a-f]{1,4}(:[0-9a-f]{0,4}){6}:[0-9a-f]{1,4}):[^: ]* (.*)$/\1 \3/p'`
+
+ DISC_TARGETS=""
+ while read NODE_ADDR NODE_NAME; do
+ [ -z "$NODE_ADDR" -a -z "$NODE_NAME" ] && continue
+ NODE_ATTRS=`iscsiadm -m node -p "$NODE_ADDR" -T "$NODE_NAME"`
+ NODE_STATUS=`echo "$NODE_ATTRS" | sed -nre 's/^.*node\.conn\[0\]\.startup = ([a-z]*).*$/\1/p'`
+
+ if [ "$NODE_STATUS" == 'automatic' ]; then
+ DISC_TARGETS=`echo "$DISC_TARGETS" | sed -re '/'"$NODE_ADDR"'/!{s/(.*)/\1 '"$NODE_ADDR"'/}'`
+ fi
+ done < <(echo "$IPV4_NODE_LIST"; echo "$IPV6_NODE_LIST")
+
+ for TARGET_ADDR in $DISC_TARGETS; do
+ echo -n "Attempting discovery on target at ${TARGET_ADDR}: "
+ iscsiadm -m discovery -t st -p "$TARGET_ADDR" > /dev/null 2>&1
+ if [ "$?" -ne 0 ]; then
+ rc_failed 1
+ rc_status -v
+ return 1
+ fi
+ rc_status -v
+ done
+}
+
case "$1" in
start)
[ ! -d /var/lib/iscsi ] && mkdir -p /var/lib/iscsi
@@ -108,6 +140,10 @@
rc_status -v
fi
if [ "$RETVAL" == "0" ]; then
+ iscsi_discover_all_targets
+ RETVAL=$?
+ fi
+ if [ "$RETVAL" == "0" ]; then
iscsi_login_all_nodes
fi
;;

View File

@ -1,25 +0,0 @@
commit f866141b55c21b4697f31309054fb4ecdcda19b6
Author: Hannes Reinecke <hare@suse.de>
Date: Mon Mar 17 15:21:21 2008 +0100
Don't fail SUSE init script when calling 'stop' twice
When calling SUSE init script twice with 'stop' or once when
the daemon is not running, it will return failed.
References: 369300
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index a8b4a0c..d8b91cc 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -176,7 +176,7 @@ case "$1" in
fi
rc_failed $status
else
- rc_failed 1
+ rc_failed $RETVAL
fi
rc_status -v
;;

View File

@ -1,11 +0,0 @@
--- open-iscsi-2.0-865/usr/iscsiadm.c 2007/12/13 07:37:12 1.5
+++ open-iscsi-2.0-865/usr/iscsiadm.c 2007/12/13 07:30:41
@@ -80,7 +80,7 @@
{"logoutall", required_argument, NULL, 'U'},
{"stats", no_argument, NULL, 's'},
{"killiscsid", required_argument, NULL, 'k'},
- {"debug", required_argument, NULL, 'g'},
+ {"debug", required_argument, NULL, 'd'},
{"show", no_argument, NULL, 'S'},
{"version", no_argument, NULL, 'V'},
{"help", no_argument, NULL, 'h'},

View File

@ -1,34 +0,0 @@
--- open-iscsi-2.0-865/etc/initd/initd.suse 2007/12/06 07:55:12 1.9
+++ open-iscsi-2.0-865/etc/initd/initd.suse 2007/12/06 10:38:32
@@ -34,19 +34,26 @@
iscsi_login_all_nodes()
{
echo -n "Setting up iSCSI targets: "
- $ISCSIADM -m node --loginall=automatic
+ $ISCSIADM -m node --loginall=automatic 2> /dev/null
+ if [ $? == 19 ] ; then
+ rc_failed 6
+ fi
rc_status -v
}
iscsi_logout_all_nodes()
{
+ echo -n "Closing all iSCSI connections: "
# Logout from all active sessions
- if $ISCSIADM -m node --logoutall=all ; then
- rc_status -v
- else
- RETVAL=$?
+ if ! $ISCSIADM -m node --logoutall=automatic 2> /dev/null; then
+ if [ $? == 19 ] ; then
+ RETVAL=6
+ else
+ RETVAL=1
+ fi
rc_failed $RETVAL
fi
+ rc_status -v
# Not sure whether this is still needed
sleep 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
commit a58c90313743e5e1614aa8a0522d6a441dc79ed3
Author: Hannes Reinecke <hare@suse.de>
Date: Mon Apr 21 11:28:25 2008 +0200
Scan Memory area for iBFT correctly
The iBFT might be constructed in the main memory area, too.
For this we don't have a ROM header, so we have to skip the
checks for this, too.
Signed-off-by: Hannes Reinecke <hare@suse.de>
diff --git a/utils/fwparam_ibft/fwparam_ibft.c b/utils/fwparam_ibft/fwparam_ibft.c
index dc0fc6b..84502bb 100644
--- a/utils/fwparam_ibft/fwparam_ibft.c
+++ b/utils/fwparam_ibft/fwparam_ibft.c
@@ -502,18 +502,24 @@ char *search_ibft(unsigned char *start, int start_addr, int length)
{
unsigned char *cur_ptr, *rom_end;
struct ibft_table_hdr *ibft_hdr;
- unsigned char check_sum, rom_size;
+ unsigned char check_sum;
+ short rom_size = -1;
uint32_t i;
cur_ptr = (unsigned char *)start;
while (cur_ptr < (start + length)) {
- if (memcmp(cur_ptr, ID_ROMEXT, strlen(ID_ROMEXT)) != 0) {
- /* Skip this block */
- cur_ptr += 512;
- continue;
+ if (rom_size < 0) {
+ /* Scan the upper memory area */
+ rom_size = 256;
+ } else {
+ /* Scan extenions in the ROM area */
+ if (memcmp(cur_ptr, ID_ROMEXT, strlen(ID_ROMEXT)) != 0) {
+ /* Skip this block */
+ cur_ptr += 512;
+ continue;
+ }
+ memcpy(&rom_size, cur_ptr + 2, 1);
}
- memcpy(&rom_size, cur_ptr + 2, 1);
-
if (debug > 1)
fprintf(stderr, "Found rom at %x of size %d\n",
((int)(cur_ptr - start) + start_addr),

View File

@ -1,61 +0,0 @@
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 6d4cbd8..ce9fa70 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -77,6 +77,39 @@ iscsi_logout_all_nodes()
return ${RETVAL:-0}
}
+iscsi_umount_all_luns()
+{
+ local d m dev p s
+
+ cat /proc/mounts | sed -ne '/^\/dev\/.*/p' | while read d m t o x; do
+ if [ "$m" = "/" ] ; then
+ continue;
+ fi
+ if [ -L "$d" ] ; then
+ d=$(readlink -f $d)
+ fi
+ dev=${d##/dev}
+
+ if [ "${dev##/sd}" = "$dev" ] ; then
+ continue;
+ fi
+ p="/sys/block${dev%%[0-9]*}"
+
+ if [ ! -d ${p} ] && [ ! -d ${p}/device ] ; then
+ continue;
+ fi
+
+ s=$(cd -P ${p}/device && echo $PWD)
+
+ case "$s" in
+ */session[0-9]*/*)
+ # This is an iSCSI device
+ umount "$m"
+ ;;
+ esac
+ done
+}
+
iscsi_list_all_nodes()
{
TARGETS=$($ISCSIADM -m session | sed 's@\[[^:]*:\(.*\)\] .*@\1@g')
@@ -110,6 +143,7 @@ case "$1" in
fi
;;
stop)
+ iscsi_umount_all_luns
if iscsi_logout_all_nodes ; then
killproc -KILL $DAEMON
RETVAL=$?
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
diff --git a/kernel/iscsi_tcp.c b/kernel/iscsi_tcp.c
diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c
diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h
diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c
diff --git a/usr/discovery.c b/usr/discovery.c
diff --git a/usr/initiator.c b/usr/initiator.c
diff --git a/usr/initiator.h b/usr/initiator.h
diff --git a/usr/iscsid.c b/usr/iscsid.c

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Apr 29 09:06:07 CEST 2008 - hare@suse.de
- Pull in fixes from upstream git repository
-------------------------------------------------------------------
Mon Apr 21 11:30:28 CEST 2008 - hare@suse.de
- Scan memory area for iBFT correctly (bnc#378837)
-------------------------------------------------------------------
Tue Apr 15 13:47:21 CEST 2008 - hare@suse.de

View File

@ -1,5 +1,5 @@
#
# spec file for package open-iscsi (Version 2.0.865)
# spec file for package open-iscsi (Version 2.0.869)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@ -18,7 +18,7 @@ License: GPL v2 or later
Group: Productivity/Networking/Other
PreReq: %fillup_prereq %insserv_prereq
AutoReqProv: on
Version: 2.0.865
Version: 2.0.869
Release: 1
Provides: linux-iscsi
Obsoletes: linux-iscsi
@ -28,25 +28,17 @@ Source: %{name}-2.0-865.tar.bz2
Source11: iscsi-gen-initiatorname.sh
Patch1: %{name}-866.diff
Patch2: %{name}-git-update
Patch3: %{name}-add-discovery-ops
Patch4: %{name}-add-suse-boot-script
Patch5: %{name}-format-luns
Patch22: %{name}-fwparam-scan-in-blocks
Patch23: %{name}-umount-all-luns
Patch24: %{name}-update-nodes
Patch25: %{name}-fixup-init-script
Patch26: %{name}-discover-all-targets
Patch28: %{name}-fixup-debug-option
Patch30: %{name}-backport-fwparam_ibft
Patch31: %{name}-fix-suse-build
Patch32: %{name}-ibft-fill-initiator-values
Patch33: %{name}-ibft-print-ifspec
Patch34: %{name}-dont-fail-init-script-on-stop
Patch35: %{name}-check-logmsg-length
Patch36: %{name}-cleanup-IPC
Patch37: %{name}-print-ibft-error-to-stderr
Patch38: %{name}-teardown-device-stack
Patch39: %{name}-fwparam_ppc-string-overflow
Patch40: %{name}-ibft-scan-memory-area
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -78,25 +70,17 @@ Authors:
%setup -n %{name}-2.0-865
%patch1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch28 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
cp etc/iface.example .
%build
@ -137,6 +121,10 @@ fi
%doc %{_mandir}/man8/*
%changelog
* Tue Apr 29 2008 hare@suse.de
- Pull in fixes from upstream git repository
* Mon Apr 21 2008 hare@suse.de
- Scan memory area for iBFT correctly (bnc#378837)
* Tue Apr 15 2008 hare@suse.de
- Synchronize with SLES10 SP2
* Thu Apr 10 2008 hare@suse.de