diff --git a/iscsi-gen-initiatorname.sh b/iscsi-gen-initiatorname.sh index 0de9ed2..33b55ee 100644 --- a/iscsi-gen-initiatorname.sh +++ b/iscsi-gen-initiatorname.sh @@ -18,10 +18,11 @@ if [ "$1" ] ; then fi fi +if [ -d /sys/firmware/ibft/initiator ] ; then + read iSCSI_INITIATOR_NAME < /sys/firmware/ibft/initiator/initiator-name +fi + if [ -f /etc/iscsi/initiatorname.iscsi -a -z "$FORCE" ] ; then - if [ -x /sbin/fwparam_ibft ] ; then - eval $(/sbin/fwparam_ibft -b 2> /dev/null | grep iSCSI_INITIATOR_NAME) - fi if [ "$iSCSI_INITIATOR_NAME" ] ; then eval $(cat /etc/iscsi/initiatorname.iscsi | sed -e '/^#/d') if [ "$iSCSI_INITIATOR_NAME" != "$InitiatorName" ] ; then @@ -30,14 +31,10 @@ if [ -f /etc/iscsi/initiatorname.iscsi -a -z "$FORCE" ] ; then exit 1 fi fi - exit 0 fi -if [ -x /sbin/fwparam_ibft ] ; then - eval $(/sbin/fwparam_ibft -b 2> /dev/null | sed -ne '/iSCSI_INITIATOR_NAME/p') - - if [ "$iSCSI_INITIATOR_NAME" ] ; then - cat << EOF >> /etc/iscsi/initiatorname.iscsi +if [ "$iSCSI_INITIATOR_NAME" ] ; then + cat << EOF >> /etc/iscsi/initiatorname.iscsi ## ## /etc/iscsi/iscsi.initiatorname ## @@ -53,7 +50,6 @@ if [ -x /sbin/fwparam_ibft ] ; then ## InitiatorName=$iSCSI_INITIATOR_NAME EOF - fi fi if [ ! -f /etc/iscsi/initiatorname.iscsi ] ; then diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh deleted file mode 100644 index 8d97db6..0000000 --- a/mkinitrd-boot.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash -#%stage: device -#%depends: network -#%programs: /sbin/iscsid /sbin/iscsiadm /sbin/fwparam_ibft usleep -#%modules: iscsi_tcp crc32c scsi_transport_iscsi -#%if: "$root_iscsi" -o "$TargetAddress" -# -##### iSCSI initialization -## -## This script initializes iSCSI (SCSI over IP). -## To be able to use this script, the network has to be setup. -## When everything worked as expected, the iSCSI devices will show -## up as real SCSI devices. -## -## Command line parameters -## ----------------------- -## -## TargetAddress the address of the iscsi server -## TargetPort the port of the iscsi server (defaults to 3260) -## TargetName the iscsi target name (connect to all if empty) -## iSCSI_ignoreNodes if set all stored nodes will be ignored (only -## iBFT and commandline nodes get parsed) -## - -### iSCSI_warning_InitiatorName -# shows a warning about iSCSI InitiatorName differences -# Origin should be something like "commandline" or "iBFT" -iSCSI_warning_InitiatorName() { - echo "iSCSI: WARNING" - echo "iSCSI: =======================" - echo "iSCSI: " - echo "iSCSI: InitiatorName given on $2 and internally stored Initiator are different." - echo "iSCSI: New: $tmp_InitiatorName" - echo "iSCSI: Stored: $InitiatorName" - echo "iSCSI: " - echo "iSCSI: using the $2 version" -} - -if [ "$iSCSI_ignoreNodes" ]; then - # make us forget we have to initialize stored nodes - echo "iSCSI: removing node information..." - iscsi_sessions= - rm -rf /etc/iscsi/nodes - mkdir /etc/iscsi/nodes -fi - -# get the command line InitiatorName -tmp_InitiatorName="$(get_param InitiatorName)" -# reads the InitiatorName variable -. /etc/iscsi/initiatorname.iscsi - -# Check of iBFT settings -if [ -x /sbin/fwparam_ibft ] ; then - eval $(/sbin/fwparam_ibft -b 2> /dev/null ) - # only use the iBFT InitiatorName if the commandline argument is not "default" - if [ "$iSCSI_INITIATOR_NAME" -a "$tmp_InitiatorName" != "default" ] ; then - iSCSI_warning_InitiatorName "$iSCSI_INITIATOR_NAME" "iBFT" - InitiatorName=$iSCSI_INITIATOR_NAME - fi - - TargetNameiBFT=$iSCSI_TARGET_NAME - TargetAddressiBFT=$iSCSI_TARGET_IPADDR - TargetPortiBFT=$iSCSI_TARGET_PORT -fi - -if [ "$tmp_InitiatorName" != "$InitiatorName" -a "$tmp_InitiatorName" != "default" -a "$tmp_InitiatorName" ]; then - iSCSI_warning_InitiatorName "$tmp_InitiatorName" "cmdline" - InitiatorName=$tmp_InitiatorName -fi - -# store the detected InitiatorName permanently -echo "InitiatorName=$InitiatorName" > /etc/iscsi/initiatorname.iscsi - -unset iSCSI_warning_InitiatorName - -# ... hier wuerde viel s390-init zeug kommen - -iscsi_mark_root_nodes() -{ - local iscsi_tgts - - if [ -z "$iscsitarget" ] ; then - iscsi_tgts=$(/sbin/iscsiadm -m node | sed -n "s/.*$iscsiserver:$iscsiport,.* \(iqn.*\)/\1/p") - else - iscsi_tgts="$iscsitarget" - fi - - for tgt in $iscsi_tgts ; do - /sbin/iscsiadm -m node -p $iscsiserver:$iscsiport -T $tgt -o update -n node.conn[0].startup -v automatic - done -} - -load_modules - -echo "Starting iSCSI daemon" -/sbin/iscsid -usleep 5000000 - -# loop through all stored iscsi sessions, the command line and iBFT settings -for session in iscsi_sessions "" iBFT; do - # get the current config - iscsiserver=$(eval echo \$TargetAddress$session) - iscsiport=$(eval echo \$TargetPort$session) - iscsitarget=$(eval echo \$TargetName$session) - - # try to detect and connect to the iscsi server - if [ "$iscsiserver" -a "$iscsiport" ] ; then - echo -n "Starting discovery on ${iscsiserver},${iscsiport}: " - if /sbin/iscsiadm -m discovery -t st -p ${iscsiserver}:${iscsiport} 2> /dev/null ; then - echo "ok." - else - echo "failed." - fi - iscsi_mark_root_nodes - fi -done - -/sbin/iscsiadm -m node -L automatic - -unset iscsi_mark_root_nodes diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh deleted file mode 100644 index 7ffff67..0000000 --- a/mkinitrd-setup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -#%stage: device -# -check_iscsi_root() { - local devname=$1 - local sysfs_path - - sysfs_path=$(/sbin/udevadm info -q path -n $rootdev 2> /dev/null) - if [ -z "$sysfs_path" ] || [ ! -d /sys$sysfs_path ] ; then - return; - fi - - pushd /sys$sysfs_path > /dev/null - if [ ! -d device ] ; then - cd .. - fi - - if [ ! -d device ] ; then - # no device link; return - popd > /dev/null - return; - fi - - cd -P device - cd ../.. - - if [ -d connection* ]; then - cd -P connection* - cid=${PWD#*connection} - sid=${cid%%:*} - if [ -d /sys/class/iscsi_session/session$sid ]; then - cd -P /sys/class/iscsi_session/session$sid - echo $(basename $PWD) - fi - fi - popd > /dev/null -} - -for bd in $blockdev; do - update_blockdev $bd - sid=$(check_iscsi_root $bd) - if [ "$sid" ]; then - root_iscsi=1 - iscsi_sessions="$iscsi_sessions ${sid#session}" - fi -done - -save_var root_iscsi -save_var iscsi_sessions - -if [ "${root_iscsi}" ]; then - for session in $iscsi_sessions; do - eval TargetName${session}=$(cat /sys/class/iscsi_session/session${session}/targetname) - eval TargetAddress${session}=$(cat /sys/class/iscsi_connection/connection${session}:0/address) - eval TargetPort${session}=$(cat /sys/class/iscsi_connection/connection${session}:0/port) - - save_var TargetName${session} - save_var TargetAddress${session} - save_var TargetPort${session} - - # copy the iscsi configuration - cp -rp /etc/iscsi etc/ - mkdir -p $tmp_mnt/var/run - mkdir -p $tmp_mnt/var/lock/iscsi - if [ -z "$interface" ] ; then - interface="default" - fi - done -fi - -save_var TargetPort 3260 # in case the port was not defined via command line we assign a default port - diff --git a/mkinitrd-stop.sh b/mkinitrd-stop.sh deleted file mode 100644 index 2b1c895..0000000 --- a/mkinitrd-stop.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -#%stage: setup -#%provides: killprogs -# -#%if: "$iscsi_root" -#%dontshow -# -##### kill iscsi -## -## Because we will run and use the iSCSI daemon from the new root -## the old one has to be killed. During that time no iSCSI -## exceptions should occur! -## -## Command line parameters -## ----------------------- -## - -# kill iscsid, will be restarted from the real root -iscsi_pid=$(pidof iscsid) -[ "$iscsi_pid" ] && kill -KILL $iscsi_pid diff --git a/open-iscsi-add-error-msg-to-log.c b/open-iscsi-add-error-msg-to-log.c new file mode 100644 index 0000000..0f00522 --- /dev/null +++ b/open-iscsi-add-error-msg-to-log.c @@ -0,0 +1,86 @@ +commit 71257059d29236aab14135774dde88c769b0b7ce +Author: Doron Shoham +Date: Tue Sep 9 14:09:47 2008 +0300 + + log.c: add error messages when allocation shared memory + + add error messages when trying to allocate shared memory + for the log area. + + Signed-off-by: Doron Shoham + +diff --git a/usr/log.c b/usr/log.c +index 013caed..4351456 100644 +--- a/usr/log.c ++++ b/usr/log.c +@@ -71,11 +71,14 @@ static int logarea_init (int size) + logdbg(stderr,"enter logarea_init\n"); + + if ((shmid = shmget(IPC_PRIVATE, sizeof(struct logarea), +- 0644 | IPC_CREAT | IPC_EXCL)) == -1) ++ 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ syslog(LOG_ERR, "shmget logarea failed %d", errno); + return 1; ++ } + + la = shmat(shmid, NULL, 0); + if (!la) { ++ syslog(LOG_ERR, "shmat logarea failed %d", errno); + shmctl(shmid, IPC_RMID, NULL); + return 1; + } +@@ -89,6 +92,7 @@ static int logarea_init (int size) + + if ((shmid = shmget(IPC_PRIVATE, size, + 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ syslog(LOG_ERR, "shmget msg failed %d", errno); + free_logarea(); + return 1; + } +@@ -96,6 +100,7 @@ static int logarea_init (int size) + + la->start = shmat(la->shmid_msg, NULL, 0); + if (!la->start) { ++ syslog(LOG_ERR, "shmat msg failed %d", errno); + free_logarea(); + return 1; + } +@@ -108,22 +113,26 @@ static int logarea_init (int size) + + if ((shmid = shmget(IPC_PRIVATE, MAX_MSG_SIZE + sizeof(struct logmsg), + 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ syslog(LOG_ERR, "shmget logmsg failed %d", errno); + free_logarea(); + return 1; + } + la->buff = shmat(shmid, NULL, 0); + if (!la->buff) { ++ syslog(LOG_ERR, "shmat logmsgfailed %d", errno); + free_logarea(); + return 1; + } + + if ((la->semid = semget(SEMKEY, 1, 0600 | IPC_CREAT)) < 0) { ++ syslog(LOG_ERR, "semget failed %d", errno); + free_logarea(); + return 1; + } + + la->semarg.val=1; + if (semctl(la->semid, 0, SETVAL, la->semarg) < 0) { ++ syslog(LOG_ERR, "semctl failed %d", errno); + free_logarea(); + return 1; + } +@@ -390,8 +399,10 @@ int log_init(char *program_name, int size) + openlog(log_name, 0, LOG_DAEMON); + setlogmask (LOG_UPTO (LOG_DEBUG)); + +- if (logarea_init(size)) ++ if (logarea_init(size)) { ++ syslog(LOG_ERR, "logarea init failed"); + return -1; ++ } + + pid = fork(); + if (pid < 0) { diff --git a/open-iscsi-add-mkinitrd-scriptlets b/open-iscsi-add-mkinitrd-scriptlets new file mode 100644 index 0000000..b1fe452 --- /dev/null +++ b/open-iscsi-add-mkinitrd-scriptlets @@ -0,0 +1,204 @@ +diff --git a/etc/mkinitrd/mkinitrd-boot.sh b/etc/mkinitrd/mkinitrd-boot.sh +new file mode 100644 +index 0000000..9bd22ff +--- /dev/null ++++ b/etc/mkinitrd/mkinitrd-boot.sh +@@ -0,0 +1,95 @@ ++#!/bin/bash ++#%stage: device ++#%depends: network ++#%programs: /sbin/iscsid /sbin/iscsiadm ++#%modules: iscsi_tcp crc32c scsi_transport_iscsi iscsi_ibft ++#%if: "$root_iscsi" -o "$TargetAddress" ++# ++##### iSCSI initialization ++## ++## This script initializes iSCSI (SCSI over IP). ++## To be able to use this script, the network has to be setup. ++## When everything worked as expected, the iSCSI devices will show ++## up as real SCSI devices. ++## ++## Command line parameters ++## ----------------------- ++## ++## TargetAddress the address of the iscsi server ++## TargetPort the port of the iscsi server (defaults to 3260) ++## TargetName the iscsi target name (connect to all if empty) ++## iSCSI_ignoreNodes if set all stored nodes will be ignored (only ++## iBFT and commandline nodes get parsed) ++## ++ ++### iSCSI_warning_InitiatorName ++# shows a warning about iSCSI InitiatorName differences ++# Origin should be something like "commandline" or "iBFT" ++iSCSI_warning_InitiatorName() { ++ echo "iSCSI: WARNING" ++ echo "iSCSI: =======================" ++ echo "iSCSI: " ++ echo "iSCSI: InitiatorName given on $2 and internally stored Initiator are different." ++ echo "iSCSI: New: $tmp_InitiatorName" ++ echo "iSCSI: Stored: $InitiatorName" ++ echo "iSCSI: " ++ echo "iSCSI: using the $2 version" ++} ++ ++if [ "$iSCSI_ignoreNodes" ]; then ++ # make us forget we have to initialize stored nodes ++ echo "iSCSI: removing node information..." ++ iscsi_sessions= ++ rm -rf /etc/iscsi/nodes ++ mkdir /etc/iscsi/nodes ++fi ++ ++# get the command line InitiatorName ++tmp_InitiatorName="$(get_param InitiatorName)" ++# reads the InitiatorName variable ++. /etc/iscsi/initiatorname.iscsi ++ ++# Check of iBFT settings ++if [ -d /sys/firmware/ibft/initiator ] ; then ++ # only use the iBFT InitiatorName if the commandline argument is not "default" ++ read iSCSI_INITIATOR_NAME < /sys/firmware/ibft/initiator ++ if [ "$iSCSI_INITIATOR_NAME" -a "$tmp_InitiatorName" != "default" ] ; then ++ iSCSI_warning_InitiatorName "$iSCSI_INITIATOR_NAME" "iBFT" ++ InitiatorName=$iSCSI_INITIATOR_NAME ++ fi ++fi ++ ++if [ "$tmp_InitiatorName" != "$InitiatorName" -a "$tmp_InitiatorName" != "default" -a "$tmp_InitiatorName" ]; then ++ iSCSI_warning_InitiatorName "$tmp_InitiatorName" "cmdline" ++ InitiatorName=$tmp_InitiatorName ++fi ++ ++# store the detected InitiatorName permanently ++echo "InitiatorName=$InitiatorName" > /etc/iscsi/initiatorname.iscsi ++ ++unset iSCSI_warning_InitiatorName ++ ++load_modules ++ ++echo "Starting iSCSI daemon" ++/sbin/iscsid -n ++ ++# log into iBFT nodes ++/sbin/iscsiadm -m fw -l ++ ++# Check for command line sessions ++if [ -n "$TargetAddress" -a -n "$TargetName" ] ; then ++ ++ # try to detect and connect to the iscsi server ++ echo -n "Starting discovery on ${TargetAddress},${TargetName}: " ++ if /sbin/iscsiadm -m discovery -t st -p ${TargetAddress}:${TargetPort} 2> /dev/null ; then ++ echo "ok." ++ else ++ echo "failed." ++ fi ++ # Mark this node as 'onboot' ++ /sbin/iscsiadm -m node -p $TargetAddress:$TargetPort -T $TargetName -o update -n node.conn[0].startup -v onboot ++fi ++ ++# Activate all 'onboot' sessions ++/sbin/iscsiadm -m node -L onboot +diff --git a/etc/mkinitrd/mkinitrd-setup.sh b/etc/mkinitrd/mkinitrd-setup.sh +new file mode 100644 +index 0000000..51a22d3 +--- /dev/null ++++ b/etc/mkinitrd/mkinitrd-setup.sh +@@ -0,0 +1,70 @@ ++#!/bin/bash ++# ++#%stage: device ++# ++check_iscsi_root() { ++ local devname=$1 ++ local sysfs_path ++ ++ sysfs_path=$(/sbin/udevadm info -q path -n $devname 2> /dev/null) ++ if [ -z "$sysfs_path" ] || [ ! -d /sys$sysfs_path ] ; then ++ return; ++ fi ++ ++ pushd /sys$sysfs_path > /dev/null ++ if [ ! -d device ] ; then ++ cd .. ++ fi ++ ++ if [ ! -d device ] ; then ++ # no device link; return ++ popd > /dev/null ++ return; ++ fi ++ ++ cd -P device ++ cd ../.. ++ ++ if [ -d connection* ]; then ++ cd -P connection* ++ cid=${PWD#*connection} ++ sid=${cid%%:*} ++ if [ -d /sys/class/iscsi_session/session$sid ]; then ++ cd -P /sys/class/iscsi_session/session$sid ++ echo $(basename $PWD) ++ fi ++ fi ++ popd > /dev/null ++} ++ ++for bd in $blockdev; do ++ update_blockdev $bd ++ sid=$(check_iscsi_root $bd) ++ if [ "$sid" ]; then ++ root_iscsi=1 ++ iscsi_sessions="$iscsi_sessions ${sid#session}" ++ fi ++done ++ ++save_var root_iscsi ++save_var iscsi_sessions ++ ++if [ "${root_iscsi}" ]; then ++ for session in $iscsi_sessions; do ++ eval TargetName${session}=$(cat /sys/class/iscsi_session/session${session}/targetname) ++ eval TargetAddress${session}=$(cat /sys/class/iscsi_connection/connection${session}:0/address) ++ eval TargetPort${session}=$(cat /sys/class/iscsi_connection/connection${session}:0/port) ++ ++ save_var TargetName${session} ++ save_var TargetAddress${session} ++ save_var TargetPort${session} ++ done ++ # copy the iscsi configuration ++ cp -rp /etc/iscsi etc/ ++ if [ -z "$interface" ] ; then ++ interface="default" ++ fi ++fi ++ ++save_var TargetPort 3260 # in case the port was not defined via command line we assign a default port ++ +diff --git a/etc/mkinitrd/mkinitrd-stop.sh b/etc/mkinitrd/mkinitrd-stop.sh +new file mode 100644 +index 0000000..c87073f +--- /dev/null ++++ b/etc/mkinitrd/mkinitrd-stop.sh +@@ -0,0 +1,21 @@ ++#!/bin/bash ++# ++#%stage: setup ++#%provides: killprogs ++# ++#%if: "$root_iscsi" ++#%dontshow ++# ++##### kill iscsi ++## ++## Because we will run and use the iSCSI daemon from the new root ++## the old one has to be killed. During that time no iSCSI ++## exceptions should occur! ++## ++## Command line parameters ++## ----------------------- ++## ++ ++# kill iscsid, will be restarted from the real root ++iscsi_pid=$(pidof iscsid) ++[ "$iscsi_pid" ] && kill -TERM $iscsi_pid diff --git a/open-iscsi-allow-onboot-for-loginall b/open-iscsi-allow-onboot-for-loginall new file mode 100644 index 0000000..e3a6572 --- /dev/null +++ b/open-iscsi-allow-onboot-for-loginall @@ -0,0 +1,42 @@ +From 33af14665a070c99fb1b8c1e049211550a883f04 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Wed, 12 Nov 2008 10:11:19 +0100 +Subject: [PATCH] iscsiadm: Allow 'onboot' option for loginall + +There is no reason to not allow onboot for iscsiadm -L. In fact, +it's required for SUSE startup :-) + +Signed-off-by: Hannes Reinecke +--- + usr/iscsiadm.c | 8 +------- + 1 files changed, 1 insertions(+), 7 deletions(-) + +diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c +index 4b276e9..bac9a5a 100644 +--- a/usr/iscsiadm.c ++++ b/usr/iscsiadm.c +@@ -690,12 +690,6 @@ static int + __login_by_startup(void *data, struct list_head *list, struct node_rec *rec) + { + char *mode = data; +- /* +- * we always skip onboot because this should be handled by +- * something else +- */ +- if (rec->startup == ISCSI_STARTUP_ONBOOT) +- return -1; + + if (match_startup_mode(rec, mode)) + return -1; +@@ -711,7 +705,7 @@ login_by_startup(char *mode) + struct list_head rec_list; + + if (!mode || !(!strcmp(mode, "automatic") || !strcmp(mode, "all") || +- !strcmp(mode,"manual"))) { ++ !strcmp(mode,"manual") || !strcmp(mode, "onboot"))) { + log_error("Invalid loginall option %s.", mode); + usage(0); + return EINVAL; +-- +1.6.0.2 + diff --git a/open-iscsi-beta5-kernel-patch-update b/open-iscsi-beta5-kernel-patch-update new file mode 100644 index 0000000..acdf77c --- /dev/null +++ b/open-iscsi-beta5-kernel-patch-update @@ -0,0 +1,1591 @@ +diff --git a/include/iscsi_if.h b/include/iscsi_if.h +index 8e399b6..afa86e8 100644 +--- a/include/iscsi_if.h ++++ b/include/iscsi_if.h +@@ -213,6 +213,8 @@ enum iscsi_err { + ISCSI_ERR_DATA_DGST = ISCSI_ERR_BASE + 15, + ISCSI_ERR_PARAM_NOT_FOUND = ISCSI_ERR_BASE + 16, + ISCSI_ERR_NO_SCSI_CMD = ISCSI_ERR_BASE + 17, ++ ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, ++ ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, + }; + + /* +diff --git a/kernel/2.6.14-19_compat.patch b/kernel/2.6.14-19_compat.patch +index 2835b35..39b4869 100644 +--- a/kernel/2.6.14-19_compat.patch ++++ b/kernel/2.6.14-19_compat.patch +@@ -1,5 +1,5 @@ + diff --git a/iscsi_tcp.c b/iscsi_tcp.c +-index 908b541..dfd8e31 100644 ++index d074146..4a01066 100644 + --- a/iscsi_tcp.c + +++ b/iscsi_tcp.c + @@ -426,6 +426,17 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment, +@@ -20,25 +20,16 @@ index 908b541..dfd8e31 100644 + __iscsi_segment_init(segment, size, done, hash); + for_each_sg(sg_list, sg, sg_count, i) { + debug_scsi("sg %d, len %u offset %u\n", i, sg->length, +-@@ -536,7 +547,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- struct iscsi_session *session = conn->session; +- struct scsi_cmnd *sc = task->sc; ++@@ -534,7 +545,7 @@ iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task) ++ struct iscsi_tcp_task *tcp_task = task->dd_data; ++ struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; + int datasn = be32_to_cpu(rhdr->datasn); +-- unsigned total_in_length = scsi_in(sc)->length; +-+ unsigned total_in_length = scsi_bufflen(sc); ++- unsigned total_in_length = scsi_in(task->sc)->length; +++ unsigned total_in_length = scsi_bufflen(task->sc); + +- iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); ++ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); + if (tcp_conn->in.datalen == 0) +-@@ -568,7 +579,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- if (res_count > 0 && +- (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || +- res_count <= total_in_length)) +-- scsi_in(sc)->resid = res_count; +-+ scsi_set_resid(sc, res_count); +- else +- sc->result = (DID_BAD_TARGET << 16) | +- rhdr->cmd_status; +-@@ -679,11 +690,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) ++@@ -660,11 +671,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) + r2t->data_length, session->max_burst); + + r2t->data_offset = be32_to_cpu(rhdr->data_offset); +@@ -52,7 +43,7 @@ index 908b541..dfd8e31 100644 + __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, + sizeof(void*)); + return ISCSI_ERR_DATALEN; +-@@ -783,7 +794,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -764,7 +775,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + if (tcp_conn->in.datalen) { + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct hash_desc *rx_hash = NULL; +@@ -60,7 +51,7 @@ index 908b541..dfd8e31 100644 + + /* + * Setup copy of Data-In into the Scsi_Cmnd +-@@ -801,8 +811,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -782,8 +792,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + tcp_task->data_offset, + tcp_conn->in.datalen); + rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, +@@ -71,7 +62,7 @@ index 908b541..dfd8e31 100644 + tcp_task->data_offset, + tcp_conn->in.datalen, + iscsi_tcp_process_data_in, +-@@ -1369,8 +1379,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) ++@@ -1352,8 +1362,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) + return 0; + + /* If we have immediate data, attach a payload */ +@@ -82,7 +73,7 @@ index 908b541..dfd8e31 100644 + 0, task->imm_count); + if (err) + return err; +-@@ -1393,7 +1403,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) ++@@ -1376,7 +1386,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) + struct iscsi_conn *conn = task->conn; + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct scsi_cmnd *sc = task->sc; +@@ -90,7 +81,7 @@ index 908b541..dfd8e31 100644 + int rc = 0; + + flush: +-@@ -1413,7 +1422,6 @@ flush: ++@@ -1396,7 +1405,6 @@ flush: + if (sc->sc_data_direction != DMA_TO_DEVICE) + return 0; + +@@ -98,7 +89,7 @@ index 908b541..dfd8e31 100644 + if (task->unsol_count != 0) { + struct iscsi_data *hdr = &tcp_task->unsol_dtask.hdr; + +-@@ -1428,8 +1436,8 @@ flush: ++@@ -1411,8 +1419,8 @@ flush: + task->itt, tcp_task->sent, task->data_count); + + iscsi_tcp_send_hdr_prep(conn, hdr, sizeof(*hdr)); +@@ -109,7 +100,7 @@ index 908b541..dfd8e31 100644 + task->data_count); + if (rc) + goto fail; +-@@ -1475,8 +1483,8 @@ flush: ++@@ -1458,8 +1466,8 @@ flush: + iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr, + sizeof(struct iscsi_hdr)); + +@@ -120,7 +111,7 @@ index 908b541..dfd8e31 100644 + r2t->data_offset + r2t->sent, + r2t->data_count); + if (rc) +-@@ -1864,7 +1872,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, ++@@ -1847,7 +1855,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, + shost->max_lun = iscsi_max_lun; + shost->max_id = 0; + shost->max_channel = 0; +@@ -132,7 +123,7 @@ index 908b541..dfd8e31 100644 + + if (iscsi_host_add(shost, NULL)) + goto free_host; +-@@ -1917,6 +1929,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) ++@@ -1900,6 +1912,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) + } + + static struct scsi_host_template iscsi_sht = { +@@ -156,7 +147,7 @@ index 68423e8..1796c96 100644 + struct socket; + struct iscsi_tcp_conn; + diff --git a/libiscsi.c b/libiscsi.c +-index e45476b..d7613eb 100644 ++index f3b845f..cfafb60 100644 + --- a/libiscsi.c + +++ b/libiscsi.c + @@ -24,7 +24,10 @@ +@@ -206,8 +197,8 @@ index e45476b..d7613eb 100644 + session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); + return 0; + } +-@@ -412,12 +415,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, +- return; ++@@ -407,12 +410,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, ++ conn->session->tt->cleanup_task(conn, task); + + sc->result = err; + - if (!scsi_bidi_cmnd(sc)) +@@ -220,7 +211,7 @@ index e45476b..d7613eb 100644 + + if (conn->task == task) + conn->task = NULL; +-@@ -592,7 +590,7 @@ invalid_datalen: ++@@ -587,7 +585,7 @@ invalid_datalen: + goto out; + } + +@@ -229,7 +220,7 @@ index e45476b..d7613eb 100644 + if (datalen < senselen) + goto invalid_datalen; + +-@@ -608,8 +606,8 @@ invalid_datalen: ++@@ -603,8 +601,8 @@ invalid_datalen: + + if (scsi_bidi_cmnd(sc) && res_count > 0 && + (rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW || +@@ -240,7 +231,18 @@ index e45476b..d7613eb 100644 + else + sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; + } +-@@ -1127,10 +1125,9 @@ again: ++@@ -653,8 +651,8 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ++ ++ if (res_count > 0 && ++ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || ++- res_count <= scsi_in(sc)->length)) ++- scsi_in(sc)->resid = res_count; +++ res_count <= scsi_bufflen(sc))) +++ scsi_set_resid(sc, res_count); ++ else ++ sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; ++ } ++@@ -1151,10 +1149,9 @@ again: + return rc; + } + +@@ -253,7 +255,7 @@ index e45476b..d7613eb 100644 + int rc; + /* + * serialize Xmit worker on a per-connection basis. +-@@ -1273,12 +1270,7 @@ reject: ++@@ -1297,12 +1294,7 @@ reject: + fault: + spin_unlock(&session->lock); + debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); +@@ -267,7 +269,7 @@ index e45476b..d7613eb 100644 + done(sc); + spin_lock(host->host_lock); + return 0; +-@@ -1882,8 +1874,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, ++@@ -1906,8 +1898,9 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, + shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size); + if (!shost) + return NULL; +@@ -278,7 +280,7 @@ index e45476b..d7613eb 100644 + if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) { + if (qdepth != 0) + printk(KERN_ERR "iscsi: invalid queue depth of %d. " +-@@ -2096,7 +2089,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, ++@@ -2123,7 +2116,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, + INIT_LIST_HEAD(&conn->mgmtqueue); + INIT_LIST_HEAD(&conn->xmitqueue); + INIT_LIST_HEAD(&conn->requeue); +@@ -619,7 +621,7 @@ index 0000000..ecd48df + + + +#endif + diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c +-index 535e461..319599a 100644 ++index 852b016..8aa9888 100644 + --- a/scsi_transport_iscsi.c + +++ b/scsi_transport_iscsi.c + @@ -21,7 +21,10 @@ +@@ -719,8 +721,8 @@ index 535e461..319599a 100644 + /* + * iSCSI endpoint attrs + */ +-@@ -229,9 +231,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) +- return iscsi_dev_to_endpoint(dev); ++@@ -237,9 +239,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) ++ return ep; + } + EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); + +#endif +@@ -731,7 +733,7 @@ index 535e461..319599a 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -250,7 +253,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, ++@@ -258,7 +261,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, + } + + static int iscsi_remove_host(struct transport_container *tc, struct device *dev, +@@ -740,7 +742,7 @@ index 535e461..319599a 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -490,10 +493,9 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel, ++@@ -498,10 +501,9 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel, + iscsi_user_scan_session); + } + +@@ -753,7 +755,7 @@ index 535e461..319599a 100644 + struct Scsi_Host *shost = iscsi_session_to_shost(session); + struct iscsi_cls_host *ihost = shost->shost_data; + struct iscsi_scan_data scan_data; +-@@ -506,11 +508,9 @@ static void iscsi_scan_session(struct work_struct *work) ++@@ -514,11 +516,9 @@ static void iscsi_scan_session(struct work_struct *work) + atomic_dec(&ihost->nr_scans); + } + +@@ -767,7 +769,7 @@ index 535e461..319599a 100644 + unsigned long flags; + + iscsi_cls_session_printk(KERN_INFO, session, +-@@ -536,11 +536,9 @@ static void session_recovery_timedout(struct work_struct *work) ++@@ -544,11 +544,9 @@ static void session_recovery_timedout(struct work_struct *work) + scsi_target_unblock(&session->dev); + } + +@@ -781,7 +783,7 @@ index 535e461..319599a 100644 + struct Scsi_Host *shost = iscsi_session_to_shost(session); + struct iscsi_cls_host *ihost = shost->shost_data; + unsigned long flags; +-@@ -560,10 +558,12 @@ static void __iscsi_unblock_session(struct work_struct *work) ++@@ -568,10 +566,12 @@ static void __iscsi_unblock_session(struct work_struct *work) + * the async scanning code (drivers like iscsi_tcp do login and + * scanning from userspace). + */ +@@ -794,7 +796,7 @@ index 535e461..319599a 100644 + } + + /** +-@@ -583,11 +583,9 @@ void iscsi_unblock_session(struct iscsi_cls_session *session) ++@@ -591,11 +591,9 @@ void iscsi_unblock_session(struct iscsi_cls_session *session) + } + EXPORT_SYMBOL_GPL(iscsi_unblock_session); + +@@ -808,7 +810,7 @@ index 535e461..319599a 100644 + unsigned long flags; + + spin_lock_irqsave(&session->lock, flags); +-@@ -604,11 +602,9 @@ void iscsi_block_session(struct iscsi_cls_session *session) ++@@ -612,11 +610,9 @@ void iscsi_block_session(struct iscsi_cls_session *session) + } + EXPORT_SYMBOL_GPL(iscsi_block_session); + +@@ -822,7 +824,7 @@ index 535e461..319599a 100644 + struct Scsi_Host *shost = iscsi_session_to_shost(session); + struct iscsi_cls_host *ihost = shost->shost_data; + unsigned long flags; +-@@ -651,12 +647,12 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport, ++@@ -659,12 +655,12 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport, + session->transport = transport; + session->recovery_tmo = 120; + session->state = ISCSI_SESSION_FREE; +@@ -840,7 +842,7 @@ index 535e461..319599a 100644 + spin_lock_init(&session->lock); + + /* this is released in the dev's release function */ +-@@ -816,7 +812,7 @@ void iscsi_remove_session(struct iscsi_cls_session *session) ++@@ -824,7 +820,7 @@ void iscsi_remove_session(struct iscsi_cls_session *session) + scsi_target_unblock(&session->dev); + /* flush running scans then delete devices */ + flush_workqueue(ihost->scan_workq); +@@ -849,7 +851,7 @@ index 535e461..319599a 100644 + + /* hw iscsi may not have removed all connections from session */ + err = device_for_each_child(&session->dev, NULL, +-@@ -1300,6 +1296,8 @@ static int ++@@ -1308,6 +1304,8 @@ static int + iscsi_if_transport_ep(struct iscsi_transport *transport, + struct iscsi_uevent *ev, int msg_type) + { +@@ -858,7 +860,7 @@ index 535e461..319599a 100644 + struct iscsi_endpoint *ep; + struct sockaddr *dst_addr; + int rc = 0; +-@@ -1340,6 +1338,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ++@@ -1348,6 +1346,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, + break; + } + return rc; +@@ -867,7 +869,7 @@ index 535e461..319599a 100644 + } + + static int +-@@ -1421,6 +1421,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1429,6 +1429,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_session.queue_depth); + break; + case ISCSI_UEVENT_CREATE_BOUND_SESSION: +@@ -877,7 +879,7 @@ index 535e461..319599a 100644 + ep = iscsi_lookup_endpoint(ev->u.c_bound_session.ep_handle); + if (!ep) { + err = -EINVAL; +-@@ -1432,6 +1435,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1440,6 +1443,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_bound_session.cmds_max, + ev->u.c_bound_session.queue_depth); + break; +@@ -885,7 +887,7 @@ index 535e461..319599a 100644 + case ISCSI_UEVENT_DESTROY_SESSION: + session = iscsi_session_lookup(ev->u.d_session.sid); + if (session) +-@@ -1514,55 +1518,70 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1522,55 +1526,70 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + } + + /* +@@ -992,7 +994,7 @@ index 535e461..319599a 100644 + __ATTR(_name,_mode,_show,_store) + + /* +-@@ -1570,10 +1589,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ ++@@ -1578,10 +1597,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ + */ + #define iscsi_conn_attr_show(param) \ + static ssize_t \ +@@ -1005,7 +1007,7 @@ index 535e461..319599a 100644 + struct iscsi_transport *t = conn->transport; \ + return t->get_conn_param(conn, param, buf); \ + } +-@@ -1597,16 +1615,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); ++@@ -1605,16 +1623,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); + iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); + iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); + +@@ -1027,7 +1029,7 @@ index 535e461..319599a 100644 + struct iscsi_transport *t = session->transport; \ + \ + if (perm && !capable(CAP_SYS_ADMIN)) \ +-@@ -1640,10 +1659,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); ++@@ -1648,10 +1667,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); + iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0) + + static ssize_t +@@ -1040,7 +1042,7 @@ index 535e461..319599a 100644 + return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); + } + static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, +-@@ -1651,11 +1669,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, ++@@ -1659,11 +1677,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, + + #define iscsi_priv_session_attr_show(field, format) \ + static ssize_t \ +@@ -1054,7 +1056,7 @@ index 535e461..319599a 100644 + return sprintf(buf, format"\n", session->field); \ + } + +-@@ -1670,10 +1686,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); ++@@ -1678,10 +1694,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); + */ + #define iscsi_host_attr_show(param) \ + static ssize_t \ +@@ -1067,7 +1069,7 @@ index 535e461..319599a 100644 + struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ + return priv->iscsi_transport->get_host_param(shost, param, buf); \ + } +-@@ -1690,7 +1705,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); ++@@ -1698,7 +1713,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); + + #define SETUP_PRIV_SESSION_RD_ATTR(field) \ + do { \ +@@ -1076,7 +1078,7 @@ index 535e461..319599a 100644 + count++; \ + } while (0) + +-@@ -1698,7 +1713,7 @@ do { \ ++@@ -1706,7 +1721,7 @@ do { \ + #define SETUP_SESSION_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -1085,7 +1087,7 @@ index 535e461..319599a 100644 + count++; \ + } \ + } while (0) +-@@ -1706,7 +1721,7 @@ do { \ ++@@ -1714,7 +1729,7 @@ do { \ + #define SETUP_CONN_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -1094,7 +1096,7 @@ index 535e461..319599a 100644 + count++; \ + } \ + } while (0) +-@@ -1714,7 +1729,7 @@ do { \ ++@@ -1722,7 +1737,7 @@ do { \ + #define SETUP_HOST_RD_ATTR(field, param_flag) \ + do { \ + if (tt->host_param_mask & param_flag) { \ +@@ -1103,7 +1105,7 @@ index 535e461..319599a 100644 + count++; \ + } \ + } while (0) +-@@ -1803,19 +1818,21 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1811,19 +1826,21 @@ iscsi_register_transport(struct iscsi_transport *tt) + INIT_LIST_HEAD(&priv->list); + priv->daemon_pid = -1; + priv->iscsi_transport = tt; +@@ -1130,7 +1132,7 @@ index 535e461..319599a 100644 + + /* host parameters */ + priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; +-@@ -1894,9 +1911,8 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1902,9 +1919,8 @@ iscsi_register_transport(struct iscsi_transport *tt) + printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); + return &priv->t; + +@@ -1142,7 +1144,7 @@ index 535e461..319599a 100644 + free_priv: + kfree(priv); + return NULL; +-@@ -1923,8 +1939,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) ++@@ -1931,8 +1947,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) + transport_container_unregister(&priv->session_cont); + transport_container_unregister(&priv->t.host_attrs); + +@@ -1153,7 +1155,7 @@ index 535e461..319599a 100644 + mutex_unlock(&rx_queue_mutex); + + return 0; +-@@ -1944,13 +1960,14 @@ static __init int iscsi_transport_init(void) ++@@ -1952,13 +1968,14 @@ static __init int iscsi_transport_init(void) + if (err) + return err; + +@@ -1170,7 +1172,7 @@ index 535e461..319599a 100644 + + err = transport_class_register(&iscsi_connection_class); + if (err) +-@@ -1981,8 +1998,10 @@ unregister_conn_class: ++@@ -1989,8 +2006,10 @@ unregister_conn_class: + transport_class_unregister(&iscsi_connection_class); + unregister_host_class: + transport_class_unregister(&iscsi_host_class); +@@ -1181,7 +1183,7 @@ index 535e461..319599a 100644 + unregister_transport_class: + class_unregister(&iscsi_transport_class); + return err; +-@@ -1995,7 +2014,9 @@ static void __exit iscsi_transport_exit(void) ++@@ -2003,7 +2022,9 @@ static void __exit iscsi_transport_exit(void) + transport_class_unregister(&iscsi_connection_class); + transport_class_unregister(&iscsi_session_class); + transport_class_unregister(&iscsi_host_class); +@@ -1192,9 +1194,9 @@ index 535e461..319599a 100644 + } + + diff --git a/scsi_transport_iscsi.h b/scsi_transport_iscsi.h +-index b7652e3..03a8a2b 100644 ++index b65c96a..15b1f0e 100644 + --- a/scsi_transport_iscsi.h +-+++ b//scsi_transport_iscsi.h +++++ b/scsi_transport_iscsi.h + @@ -25,9 +25,14 @@ + + #include +diff --git a/kernel/2.6.20-21_compat.patch b/kernel/2.6.20-21_compat.patch +index 2006bf8..366206e 100644 +--- a/kernel/2.6.20-21_compat.patch ++++ b/kernel/2.6.20-21_compat.patch +@@ -1,5 +1,5 @@ + diff --git a/iscsi_tcp.c b/iscsi_tcp.c +-index 908b541..dfd8e31 100644 ++index d074146..4a01066 100644 + --- a/iscsi_tcp.c + +++ b/iscsi_tcp.c + @@ -426,6 +426,17 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment, +@@ -20,25 +20,16 @@ index 908b541..dfd8e31 100644 + __iscsi_segment_init(segment, size, done, hash); + for_each_sg(sg_list, sg, sg_count, i) { + debug_scsi("sg %d, len %u offset %u\n", i, sg->length, +-@@ -536,7 +547,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- struct iscsi_session *session = conn->session; +- struct scsi_cmnd *sc = task->sc; ++@@ -534,7 +545,7 @@ iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task) ++ struct iscsi_tcp_task *tcp_task = task->dd_data; ++ struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; + int datasn = be32_to_cpu(rhdr->datasn); +-- unsigned total_in_length = scsi_in(sc)->length; +-+ unsigned total_in_length = scsi_bufflen(sc); ++- unsigned total_in_length = scsi_in(task->sc)->length; +++ unsigned total_in_length = scsi_bufflen(task->sc); + +- iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); ++ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); + if (tcp_conn->in.datalen == 0) +-@@ -568,7 +579,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- if (res_count > 0 && +- (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || +- res_count <= total_in_length)) +-- scsi_in(sc)->resid = res_count; +-+ scsi_set_resid(sc, res_count); +- else +- sc->result = (DID_BAD_TARGET << 16) | +- rhdr->cmd_status; +-@@ -679,11 +690,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) ++@@ -660,11 +671,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) + r2t->data_length, session->max_burst); + + r2t->data_offset = be32_to_cpu(rhdr->data_offset); +@@ -52,7 +43,7 @@ index 908b541..dfd8e31 100644 + __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, + sizeof(void*)); + return ISCSI_ERR_DATALEN; +-@@ -783,7 +794,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -764,7 +775,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + if (tcp_conn->in.datalen) { + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct hash_desc *rx_hash = NULL; +@@ -60,7 +51,7 @@ index 908b541..dfd8e31 100644 + + /* + * Setup copy of Data-In into the Scsi_Cmnd +-@@ -801,8 +811,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -782,8 +792,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + tcp_task->data_offset, + tcp_conn->in.datalen); + rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, +@@ -71,7 +62,7 @@ index 908b541..dfd8e31 100644 + tcp_task->data_offset, + tcp_conn->in.datalen, + iscsi_tcp_process_data_in, +-@@ -1369,8 +1379,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) ++@@ -1352,8 +1362,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) + return 0; + + /* If we have immediate data, attach a payload */ +@@ -82,7 +73,7 @@ index 908b541..dfd8e31 100644 + 0, task->imm_count); + if (err) + return err; +-@@ -1393,7 +1403,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) ++@@ -1376,7 +1386,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) + struct iscsi_conn *conn = task->conn; + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct scsi_cmnd *sc = task->sc; +@@ -90,7 +81,7 @@ index 908b541..dfd8e31 100644 + int rc = 0; + + flush: +-@@ -1413,7 +1422,6 @@ flush: ++@@ -1396,7 +1405,6 @@ flush: + if (sc->sc_data_direction != DMA_TO_DEVICE) + return 0; + +@@ -98,7 +89,7 @@ index 908b541..dfd8e31 100644 + if (task->unsol_count != 0) { + struct iscsi_data *hdr = &tcp_task->unsol_dtask.hdr; + +-@@ -1428,8 +1436,8 @@ flush: ++@@ -1411,8 +1419,8 @@ flush: + task->itt, tcp_task->sent, task->data_count); + + iscsi_tcp_send_hdr_prep(conn, hdr, sizeof(*hdr)); +@@ -109,7 +100,7 @@ index 908b541..dfd8e31 100644 + task->data_count); + if (rc) + goto fail; +-@@ -1475,8 +1483,8 @@ flush: ++@@ -1458,8 +1466,8 @@ flush: + iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr, + sizeof(struct iscsi_hdr)); + +@@ -120,7 +111,7 @@ index 908b541..dfd8e31 100644 + r2t->data_offset + r2t->sent, + r2t->data_count); + if (rc) +-@@ -1864,7 +1872,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, ++@@ -1847,7 +1855,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, + shost->max_lun = iscsi_max_lun; + shost->max_id = 0; + shost->max_channel = 0; +@@ -132,7 +123,7 @@ index 908b541..dfd8e31 100644 + + if (iscsi_host_add(shost, NULL)) + goto free_host; +-@@ -1917,6 +1929,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) ++@@ -1900,6 +1912,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) + } + + static struct scsi_host_template iscsi_sht = { +@@ -156,7 +147,7 @@ index 68423e8..1796c96 100644 + struct socket; + struct iscsi_tcp_conn; + diff --git a/libiscsi.c b/libiscsi.c +-index e45476b..60f7a5e 100644 ++index f3b845f..80da87f 100644 + --- a/libiscsi.c + +++ b/libiscsi.c + @@ -187,7 +187,7 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task) +@@ -195,8 +186,8 @@ index e45476b..60f7a5e 100644 + session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); + return 0; + } +-@@ -412,12 +412,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, +- return; ++@@ -407,12 +407,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, ++ conn->session->tt->cleanup_task(conn, task); + + sc->result = err; + - if (!scsi_bidi_cmnd(sc)) +@@ -209,7 +200,7 @@ index e45476b..60f7a5e 100644 + + if (conn->task == task) + conn->task = NULL; +-@@ -592,7 +587,7 @@ invalid_datalen: ++@@ -587,7 +582,7 @@ invalid_datalen: + goto out; + } + +@@ -218,7 +209,7 @@ index e45476b..60f7a5e 100644 + if (datalen < senselen) + goto invalid_datalen; + +-@@ -608,8 +603,8 @@ invalid_datalen: ++@@ -603,8 +598,8 @@ invalid_datalen: + + if (scsi_bidi_cmnd(sc) && res_count > 0 && + (rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW || +@@ -229,7 +220,18 @@ index e45476b..60f7a5e 100644 + else + sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; + } +-@@ -1273,12 +1268,7 @@ reject: ++@@ -653,8 +648,8 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ++ ++ if (res_count > 0 && ++ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || ++- res_count <= scsi_in(sc)->length)) ++- scsi_in(sc)->resid = res_count; +++ res_count <= scsi_bufflen(sc))) +++ scsi_set_resid(sc, res_count); ++ else ++ sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; ++ } ++@@ -1297,12 +1292,7 @@ reject: + fault: + spin_unlock(&session->lock); + debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); +@@ -509,7 +511,7 @@ index 0000000..8bd48d1 + + + +#endif + diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c +-index 535e461..65f36a3 100644 ++index 852b016..f4270b2 100644 + --- a/scsi_transport_iscsi.c + +++ b/scsi_transport_iscsi.c + @@ -41,13 +41,13 @@ struct iscsi_internal { +@@ -598,8 +600,8 @@ index 535e461..65f36a3 100644 + /* + * iSCSI endpoint attrs + */ +-@@ -229,9 +228,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) +- return iscsi_dev_to_endpoint(dev); ++@@ -237,9 +236,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) ++ return ep; + } + EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); + +#endif +@@ -610,7 +612,7 @@ index 535e461..65f36a3 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -250,7 +250,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, ++@@ -258,7 +258,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, + } + + static int iscsi_remove_host(struct transport_container *tc, struct device *dev, +@@ -619,7 +621,7 @@ index 535e461..65f36a3 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -1300,6 +1300,8 @@ static int ++@@ -1308,6 +1308,8 @@ static int + iscsi_if_transport_ep(struct iscsi_transport *transport, + struct iscsi_uevent *ev, int msg_type) + { +@@ -628,7 +630,7 @@ index 535e461..65f36a3 100644 + struct iscsi_endpoint *ep; + struct sockaddr *dst_addr; + int rc = 0; +-@@ -1340,6 +1342,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ++@@ -1348,6 +1350,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, + break; + } + return rc; +@@ -637,7 +639,7 @@ index 535e461..65f36a3 100644 + } + + static int +-@@ -1421,6 +1425,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1429,6 +1433,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_session.queue_depth); + break; + case ISCSI_UEVENT_CREATE_BOUND_SESSION: +@@ -647,7 +649,7 @@ index 535e461..65f36a3 100644 + ep = iscsi_lookup_endpoint(ev->u.c_bound_session.ep_handle); + if (!ep) { + err = -EINVAL; +-@@ -1432,6 +1439,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1440,6 +1447,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_bound_session.cmds_max, + ev->u.c_bound_session.queue_depth); + break; +@@ -655,7 +657,7 @@ index 535e461..65f36a3 100644 + case ISCSI_UEVENT_DESTROY_SESSION: + session = iscsi_session_lookup(ev->u.d_session.sid); + if (session) +-@@ -1514,55 +1522,70 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1522,55 +1530,70 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + } + + /* +@@ -762,7 +764,7 @@ index 535e461..65f36a3 100644 + __ATTR(_name,_mode,_show,_store) + + /* +-@@ -1570,10 +1593,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ ++@@ -1578,10 +1601,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ + */ + #define iscsi_conn_attr_show(param) \ + static ssize_t \ +@@ -775,7 +777,7 @@ index 535e461..65f36a3 100644 + struct iscsi_transport *t = conn->transport; \ + return t->get_conn_param(conn, param, buf); \ + } +-@@ -1597,16 +1619,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); ++@@ -1605,16 +1627,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); + iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); + iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); + +@@ -797,7 +799,7 @@ index 535e461..65f36a3 100644 + struct iscsi_transport *t = session->transport; \ + \ + if (perm && !capable(CAP_SYS_ADMIN)) \ +-@@ -1640,10 +1663,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); ++@@ -1648,10 +1671,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); + iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0) + + static ssize_t +@@ -810,7 +812,7 @@ index 535e461..65f36a3 100644 + return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); + } + static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, +-@@ -1651,11 +1673,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, ++@@ -1659,11 +1681,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, + + #define iscsi_priv_session_attr_show(field, format) \ + static ssize_t \ +@@ -824,7 +826,7 @@ index 535e461..65f36a3 100644 + return sprintf(buf, format"\n", session->field); \ + } + +-@@ -1670,10 +1690,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); ++@@ -1678,10 +1698,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); + */ + #define iscsi_host_attr_show(param) \ + static ssize_t \ +@@ -837,7 +839,7 @@ index 535e461..65f36a3 100644 + struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ + return priv->iscsi_transport->get_host_param(shost, param, buf); \ + } +-@@ -1690,7 +1709,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); ++@@ -1698,7 +1717,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); + + #define SETUP_PRIV_SESSION_RD_ATTR(field) \ + do { \ +@@ -846,7 +848,7 @@ index 535e461..65f36a3 100644 + count++; \ + } while (0) + +-@@ -1698,7 +1717,7 @@ do { \ ++@@ -1706,7 +1725,7 @@ do { \ + #define SETUP_SESSION_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -855,7 +857,7 @@ index 535e461..65f36a3 100644 + count++; \ + } \ + } while (0) +-@@ -1706,7 +1725,7 @@ do { \ ++@@ -1714,7 +1733,7 @@ do { \ + #define SETUP_CONN_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -864,7 +866,7 @@ index 535e461..65f36a3 100644 + count++; \ + } \ + } while (0) +-@@ -1714,7 +1733,7 @@ do { \ ++@@ -1722,7 +1741,7 @@ do { \ + #define SETUP_HOST_RD_ATTR(field, param_flag) \ + do { \ + if (tt->host_param_mask & param_flag) { \ +@@ -873,7 +875,7 @@ index 535e461..65f36a3 100644 + count++; \ + } \ + } while (0) +-@@ -1807,15 +1826,15 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1815,15 +1834,15 @@ iscsi_register_transport(struct iscsi_transport *tt) + if (!(tt->caps & CAP_DATA_PATH_OFFLOAD)) + priv->t.create_work_queue = 1; + +@@ -894,7 +896,7 @@ index 535e461..65f36a3 100644 + + /* host parameters */ + priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; +-@@ -1894,9 +1913,8 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1902,9 +1921,8 @@ iscsi_register_transport(struct iscsi_transport *tt) + printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); + return &priv->t; + +@@ -906,7 +908,7 @@ index 535e461..65f36a3 100644 + free_priv: + kfree(priv); + return NULL; +-@@ -1923,8 +1941,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) ++@@ -1931,8 +1949,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) + transport_container_unregister(&priv->session_cont); + transport_container_unregister(&priv->t.host_attrs); + +@@ -917,7 +919,7 @@ index 535e461..65f36a3 100644 + mutex_unlock(&rx_queue_mutex); + + return 0; +-@@ -1944,13 +1962,14 @@ static __init int iscsi_transport_init(void) ++@@ -1952,13 +1970,14 @@ static __init int iscsi_transport_init(void) + if (err) + return err; + +@@ -934,7 +936,7 @@ index 535e461..65f36a3 100644 + + err = transport_class_register(&iscsi_connection_class); + if (err) +-@@ -1981,8 +2000,10 @@ unregister_conn_class: ++@@ -1989,8 +2008,10 @@ unregister_conn_class: + transport_class_unregister(&iscsi_connection_class); + unregister_host_class: + transport_class_unregister(&iscsi_host_class); +@@ -945,7 +947,7 @@ index 535e461..65f36a3 100644 + unregister_transport_class: + class_unregister(&iscsi_transport_class); + return err; +-@@ -1995,7 +2016,9 @@ static void __exit iscsi_transport_exit(void) ++@@ -2003,7 +2024,9 @@ static void __exit iscsi_transport_exit(void) + transport_class_unregister(&iscsi_connection_class); + transport_class_unregister(&iscsi_session_class); + transport_class_unregister(&iscsi_host_class); +@@ -956,7 +958,7 @@ index 535e461..65f36a3 100644 + } + + diff --git a/scsi_transport_iscsi.h b/scsi_transport_iscsi.h +-index b7652e3..4b6dc5c 100644 ++index b65c96a..9919c0d 100644 + --- a/scsi_transport_iscsi.h + +++ b/scsi_transport_iscsi.h + @@ -28,6 +28,8 @@ +diff --git a/kernel/2.6.24_compat.patch b/kernel/2.6.24_compat.patch +index 909ea56..f1b7cae 100644 +--- a/kernel/2.6.24_compat.patch ++++ b/kernel/2.6.24_compat.patch +@@ -1,5 +1,5 @@ + diff --git a/iscsi_tcp.c b/iscsi_tcp.c +-index 908b541..dfd8e31 100644 ++index d074146..4a01066 100644 + --- a/iscsi_tcp.c + +++ b/iscsi_tcp.c + @@ -426,6 +426,17 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment, +@@ -20,25 +20,16 @@ index 908b541..dfd8e31 100644 + __iscsi_segment_init(segment, size, done, hash); + for_each_sg(sg_list, sg, sg_count, i) { + debug_scsi("sg %d, len %u offset %u\n", i, sg->length, +-@@ -536,7 +547,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- struct iscsi_session *session = conn->session; +- struct scsi_cmnd *sc = task->sc; ++@@ -534,7 +545,7 @@ iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task) ++ struct iscsi_tcp_task *tcp_task = task->dd_data; ++ struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; + int datasn = be32_to_cpu(rhdr->datasn); +-- unsigned total_in_length = scsi_in(sc)->length; +-+ unsigned total_in_length = scsi_bufflen(sc); ++- unsigned total_in_length = scsi_in(task->sc)->length; +++ unsigned total_in_length = scsi_bufflen(task->sc); + +- iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); ++ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); + if (tcp_conn->in.datalen == 0) +-@@ -568,7 +579,7 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +- if (res_count > 0 && +- (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || +- res_count <= total_in_length)) +-- scsi_in(sc)->resid = res_count; +-+ scsi_set_resid(sc, res_count); +- else +- sc->result = (DID_BAD_TARGET << 16) | +- rhdr->cmd_status; +-@@ -679,11 +690,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) ++@@ -660,11 +671,11 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) + r2t->data_length, session->max_burst); + + r2t->data_offset = be32_to_cpu(rhdr->data_offset); +@@ -52,7 +43,7 @@ index 908b541..dfd8e31 100644 + __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t, + sizeof(void*)); + return ISCSI_ERR_DATALEN; +-@@ -783,7 +794,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -764,7 +775,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + if (tcp_conn->in.datalen) { + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct hash_desc *rx_hash = NULL; +@@ -60,7 +51,7 @@ index 908b541..dfd8e31 100644 + + /* + * Setup copy of Data-In into the Scsi_Cmnd +-@@ -801,8 +811,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) ++@@ -782,8 +792,8 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + tcp_task->data_offset, + tcp_conn->in.datalen); + rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, +@@ -71,7 +62,7 @@ index 908b541..dfd8e31 100644 + tcp_task->data_offset, + tcp_conn->in.datalen, + iscsi_tcp_process_data_in, +-@@ -1369,8 +1379,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) ++@@ -1352,8 +1362,8 @@ iscsi_tcp_task_init(struct iscsi_task *task) + return 0; + + /* If we have immediate data, attach a payload */ +@@ -82,7 +73,7 @@ index 908b541..dfd8e31 100644 + 0, task->imm_count); + if (err) + return err; +-@@ -1393,7 +1403,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) ++@@ -1376,7 +1386,6 @@ iscsi_tcp_task_xmit(struct iscsi_task *task) + struct iscsi_conn *conn = task->conn; + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct scsi_cmnd *sc = task->sc; +@@ -90,7 +81,7 @@ index 908b541..dfd8e31 100644 + int rc = 0; + + flush: +-@@ -1413,7 +1422,6 @@ flush: ++@@ -1396,7 +1405,6 @@ flush: + if (sc->sc_data_direction != DMA_TO_DEVICE) + return 0; + +@@ -98,7 +89,7 @@ index 908b541..dfd8e31 100644 + if (task->unsol_count != 0) { + struct iscsi_data *hdr = &tcp_task->unsol_dtask.hdr; + +-@@ -1428,8 +1436,8 @@ flush: ++@@ -1411,8 +1419,8 @@ flush: + task->itt, tcp_task->sent, task->data_count); + + iscsi_tcp_send_hdr_prep(conn, hdr, sizeof(*hdr)); +@@ -109,7 +100,7 @@ index 908b541..dfd8e31 100644 + task->data_count); + if (rc) + goto fail; +-@@ -1475,8 +1483,8 @@ flush: ++@@ -1458,8 +1466,8 @@ flush: + iscsi_tcp_send_hdr_prep(conn, &r2t->dtask.hdr, + sizeof(struct iscsi_hdr)); + +@@ -120,7 +111,7 @@ index 908b541..dfd8e31 100644 + r2t->data_offset + r2t->sent, + r2t->data_count); + if (rc) +-@@ -1864,7 +1872,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, ++@@ -1847,7 +1855,11 @@ iscsi_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, + shost->max_lun = iscsi_max_lun; + shost->max_id = 0; + shost->max_channel = 0; +@@ -132,7 +123,7 @@ index 908b541..dfd8e31 100644 + + if (iscsi_host_add(shost, NULL)) + goto free_host; +-@@ -1917,6 +1929,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) ++@@ -1900,6 +1912,9 @@ static int iscsi_tcp_slave_configure(struct scsi_device *sdev) + } + + static struct scsi_host_template iscsi_sht = { +@@ -142,7 +133,7 @@ index 908b541..dfd8e31 100644 + .module = THIS_MODULE, + .name = "iSCSI Initiator over TCP/IP", + .queuecommand = iscsi_queuecommand, +-diff --git a/iscsi_tcp.h b//iscsi_tcp.h ++diff --git a/iscsi_tcp.h b/iscsi_tcp.h + index 68423e8..1796c96 100644 + --- a/iscsi_tcp.h + +++ b/iscsi_tcp.h +@@ -156,7 +147,7 @@ index 68423e8..1796c96 100644 + struct socket; + struct iscsi_tcp_conn; + diff --git a/libiscsi.c b/libiscsi.c +-index e45476b..60f7a5e 100644 ++index f3b845f..80da87f 100644 + --- a/libiscsi.c + +++ b/libiscsi.c + @@ -187,7 +187,7 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task) +@@ -195,8 +186,8 @@ index e45476b..60f7a5e 100644 + session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); + return 0; + } +-@@ -412,12 +412,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, +- return; ++@@ -407,12 +407,7 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, ++ conn->session->tt->cleanup_task(conn, task); + + sc->result = err; + - if (!scsi_bidi_cmnd(sc)) +@@ -209,7 +200,7 @@ index e45476b..60f7a5e 100644 + + if (conn->task == task) + conn->task = NULL; +-@@ -592,7 +587,7 @@ invalid_datalen: ++@@ -587,7 +582,7 @@ invalid_datalen: + goto out; + } + +@@ -218,7 +209,7 @@ index e45476b..60f7a5e 100644 + if (datalen < senselen) + goto invalid_datalen; + +-@@ -608,8 +603,8 @@ invalid_datalen: ++@@ -603,8 +598,8 @@ invalid_datalen: + + if (scsi_bidi_cmnd(sc) && res_count > 0 && + (rhdr->flags & ISCSI_FLAG_CMD_BIDI_OVERFLOW || +@@ -229,7 +220,18 @@ index e45476b..60f7a5e 100644 + else + sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; + } +-@@ -1273,12 +1268,7 @@ reject: ++@@ -653,8 +648,8 @@ iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ++ ++ if (res_count > 0 && ++ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || ++- res_count <= scsi_in(sc)->length)) ++- scsi_in(sc)->resid = res_count; +++ res_count <= scsi_bufflen(sc))) +++ scsi_set_resid(sc, res_count); ++ else ++ sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; ++ } ++@@ -1297,12 +1292,7 @@ reject: + fault: + spin_unlock(&session->lock); + debug_scsi("iscsi: cmd 0x%x is not queued (%d)\n", sc->cmnd[0], reason); +@@ -509,7 +511,7 @@ index 0000000..8bd48d1 + + + +#endif + diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c +-index 535e461..ce81324 100644 ++index 852b016..28c4d9f 100644 + --- a/scsi_transport_iscsi.c + +++ b/scsi_transport_iscsi.c + @@ -41,13 +41,13 @@ struct iscsi_internal { +@@ -598,8 +600,8 @@ index 535e461..ce81324 100644 + /* + * iSCSI endpoint attrs + */ +-@@ -229,9 +228,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) +- return iscsi_dev_to_endpoint(dev); ++@@ -237,9 +236,10 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) ++ return ep; + } + EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); + +#endif +@@ -610,7 +612,7 @@ index 535e461..ce81324 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -250,7 +250,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, ++@@ -258,7 +258,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, + } + + static int iscsi_remove_host(struct transport_container *tc, struct device *dev, +@@ -619,7 +621,7 @@ index 535e461..ce81324 100644 + { + struct Scsi_Host *shost = dev_to_shost(dev); + struct iscsi_cls_host *ihost = shost->shost_data; +-@@ -1300,6 +1300,8 @@ static int ++@@ -1308,6 +1308,8 @@ static int + iscsi_if_transport_ep(struct iscsi_transport *transport, + struct iscsi_uevent *ev, int msg_type) + { +@@ -628,7 +630,7 @@ index 535e461..ce81324 100644 + struct iscsi_endpoint *ep; + struct sockaddr *dst_addr; + int rc = 0; +-@@ -1340,6 +1342,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ++@@ -1348,6 +1350,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, + break; + } + return rc; +@@ -637,7 +639,7 @@ index 535e461..ce81324 100644 + } + + static int +-@@ -1421,6 +1425,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1429,6 +1433,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_session.queue_depth); + break; + case ISCSI_UEVENT_CREATE_BOUND_SESSION: +@@ -647,7 +649,7 @@ index 535e461..ce81324 100644 + ep = iscsi_lookup_endpoint(ev->u.c_bound_session.ep_handle); + if (!ep) { + err = -EINVAL; +-@@ -1432,6 +1439,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ++@@ -1440,6 +1447,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + ev->u.c_bound_session.cmds_max, + ev->u.c_bound_session.queue_depth); + break; +@@ -655,7 +657,7 @@ index 535e461..ce81324 100644 + case ISCSI_UEVENT_DESTROY_SESSION: + session = iscsi_session_lookup(ev->u.d_session.sid); + if (session) +-@@ -1561,8 +1569,11 @@ iscsi_if_rx(struct sk_buff *skb) ++@@ -1569,8 +1577,11 @@ iscsi_if_rx(struct sk_buff *skb) + mutex_unlock(&rx_queue_mutex); + } + +@@ -668,7 +670,7 @@ index 535e461..ce81324 100644 + __ATTR(_name,_mode,_show,_store) + + /* +-@@ -1570,10 +1581,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ ++@@ -1578,10 +1589,9 @@ struct device_attribute dev_attr_##_prefix##_##_name = \ + */ + #define iscsi_conn_attr_show(param) \ + static ssize_t \ +@@ -681,7 +683,7 @@ index 535e461..ce81324 100644 + struct iscsi_transport *t = conn->transport; \ + return t->get_conn_param(conn, param, buf); \ + } +-@@ -1597,16 +1607,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); ++@@ -1605,16 +1615,17 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); + iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); + iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); + +@@ -703,7 +705,7 @@ index 535e461..ce81324 100644 + struct iscsi_transport *t = session->transport; \ + \ + if (perm && !capable(CAP_SYS_ADMIN)) \ +-@@ -1640,10 +1651,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); ++@@ -1648,10 +1659,9 @@ iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); + iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0) + + static ssize_t +@@ -716,7 +718,7 @@ index 535e461..ce81324 100644 + return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); + } + static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, +-@@ -1651,11 +1661,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, ++@@ -1659,11 +1669,9 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, + + #define iscsi_priv_session_attr_show(field, format) \ + static ssize_t \ +@@ -730,7 +732,7 @@ index 535e461..ce81324 100644 + return sprintf(buf, format"\n", session->field); \ + } + +-@@ -1670,10 +1678,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); ++@@ -1678,10 +1686,9 @@ iscsi_priv_session_attr(recovery_tmo, "%d"); + */ + #define iscsi_host_attr_show(param) \ + static ssize_t \ +@@ -743,7 +745,7 @@ index 535e461..ce81324 100644 + struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ + return priv->iscsi_transport->get_host_param(shost, param, buf); \ + } +-@@ -1690,7 +1697,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); ++@@ -1698,7 +1705,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); + + #define SETUP_PRIV_SESSION_RD_ATTR(field) \ + do { \ +@@ -752,7 +754,7 @@ index 535e461..ce81324 100644 + count++; \ + } while (0) + +-@@ -1698,7 +1705,7 @@ do { \ ++@@ -1706,7 +1713,7 @@ do { \ + #define SETUP_SESSION_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -761,7 +763,7 @@ index 535e461..ce81324 100644 + count++; \ + } \ + } while (0) +-@@ -1706,7 +1713,7 @@ do { \ ++@@ -1714,7 +1721,7 @@ do { \ + #define SETUP_CONN_RD_ATTR(field, param_flag) \ + do { \ + if (tt->param_mask & param_flag) { \ +@@ -770,7 +772,7 @@ index 535e461..ce81324 100644 + count++; \ + } \ + } while (0) +-@@ -1714,7 +1721,7 @@ do { \ ++@@ -1722,7 +1729,7 @@ do { \ + #define SETUP_HOST_RD_ATTR(field, param_flag) \ + do { \ + if (tt->host_param_mask & param_flag) { \ +@@ -779,7 +781,7 @@ index 535e461..ce81324 100644 + count++; \ + } \ + } while (0) +-@@ -1807,15 +1814,15 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1815,15 +1822,15 @@ iscsi_register_transport(struct iscsi_transport *tt) + if (!(tt->caps & CAP_DATA_PATH_OFFLOAD)) + priv->t.create_work_queue = 1; + +@@ -800,7 +802,7 @@ index 535e461..ce81324 100644 + + /* host parameters */ + priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; +-@@ -1894,9 +1901,8 @@ iscsi_register_transport(struct iscsi_transport *tt) ++@@ -1902,9 +1909,8 @@ iscsi_register_transport(struct iscsi_transport *tt) + printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); + return &priv->t; + +@@ -812,7 +814,7 @@ index 535e461..ce81324 100644 + free_priv: + kfree(priv); + return NULL; +-@@ -1923,8 +1929,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) ++@@ -1931,8 +1937,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt) + transport_container_unregister(&priv->session_cont); + transport_container_unregister(&priv->t.host_attrs); + +@@ -823,7 +825,7 @@ index 535e461..ce81324 100644 + mutex_unlock(&rx_queue_mutex); + + return 0; +-@@ -1944,13 +1950,14 @@ static __init int iscsi_transport_init(void) ++@@ -1952,13 +1958,14 @@ static __init int iscsi_transport_init(void) + if (err) + return err; + +@@ -840,7 +842,7 @@ index 535e461..ce81324 100644 + + err = transport_class_register(&iscsi_connection_class); + if (err) +-@@ -1981,8 +1988,10 @@ unregister_conn_class: ++@@ -1989,8 +1996,10 @@ unregister_conn_class: + transport_class_unregister(&iscsi_connection_class); + unregister_host_class: + transport_class_unregister(&iscsi_host_class); +@@ -851,7 +853,7 @@ index 535e461..ce81324 100644 + unregister_transport_class: + class_unregister(&iscsi_transport_class); + return err; +-@@ -1995,7 +2004,9 @@ static void __exit iscsi_transport_exit(void) ++@@ -2003,7 +2012,9 @@ static void __exit iscsi_transport_exit(void) + transport_class_unregister(&iscsi_connection_class); + transport_class_unregister(&iscsi_session_class); + transport_class_unregister(&iscsi_host_class); +@@ -862,7 +864,7 @@ index 535e461..ce81324 100644 + } + + diff --git a/scsi_transport_iscsi.h b/scsi_transport_iscsi.h +-index b7652e3..4b6dc5c 100644 ++index b65c96a..9919c0d 100644 + --- a/scsi_transport_iscsi.h + +++ b/scsi_transport_iscsi.h + @@ -28,6 +28,8 @@ +diff --git a/kernel/iscsi_tcp.c b/kernel/iscsi_tcp.c +index 908b541..d074146 100644 +--- a/kernel/iscsi_tcp.c ++++ b/kernel/iscsi_tcp.c +@@ -523,22 +523,20 @@ iscsi_tcp_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task) + } + + /** +- * iscsi_data_rsp - SCSI Data-In Response processing ++ * iscsi_data_in - SCSI Data-In Response processing + * @conn: iscsi connection + * @task: scsi command task + **/ + static int +-iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) ++iscsi_data_in(struct iscsi_conn *conn, struct iscsi_task *task) + { + struct iscsi_tcp_conn *tcp_conn = conn->dd_data; + struct iscsi_tcp_task *tcp_task = task->dd_data; + struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)tcp_conn->in.hdr; +- struct iscsi_session *session = conn->session; +- struct scsi_cmnd *sc = task->sc; + int datasn = be32_to_cpu(rhdr->datasn); +- unsigned total_in_length = scsi_in(sc)->length; ++ unsigned total_in_length = scsi_in(task->sc)->length; + +- iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); ++ iscsi_update_cmdsn(conn->session, (struct iscsi_nopin*)rhdr); + if (tcp_conn->in.datalen == 0) + return 0; + +@@ -558,23 +556,6 @@ iscsi_data_rsp(struct iscsi_conn *conn, struct iscsi_task *task) + return ISCSI_ERR_DATA_OFFSET; + } + +- if (rhdr->flags & ISCSI_FLAG_DATA_STATUS) { +- sc->result = (DID_OK << 16) | rhdr->cmd_status; +- conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; +- if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW | +- ISCSI_FLAG_DATA_OVERFLOW)) { +- int res_count = be32_to_cpu(rhdr->residual_count); +- +- if (res_count > 0 && +- (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || +- res_count <= total_in_length)) +- scsi_in(sc)->resid = res_count; +- else +- sc->result = (DID_BAD_TARGET << 16) | +- rhdr->cmd_status; +- } +- } +- + conn->datain_pdus_cnt++; + return 0; + } +@@ -774,7 +755,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + if (!task) + rc = ISCSI_ERR_BAD_ITT; + else +- rc = iscsi_data_rsp(conn, task); ++ rc = iscsi_data_in(conn, task); + if (rc) { + spin_unlock(&conn->session->lock); + break; +@@ -998,7 +979,7 @@ iscsi_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, + + error: + debug_tcp("Error receiving PDU, errno=%d\n", rc); +- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); ++ iscsi_conn_failure(conn, rc); + return 0; + } + +@@ -1117,8 +1098,10 @@ iscsi_xmit(struct iscsi_conn *conn) + + while (1) { + rc = iscsi_tcp_xmit_segment(tcp_conn, segment); +- if (rc < 0) ++ if (rc < 0) { ++ rc = ISCSI_ERR_XMIT_FAILED; + goto error; ++ } + if (rc == 0) + break; + +@@ -1127,7 +1110,7 @@ iscsi_xmit(struct iscsi_conn *conn) + if (segment->total_copied >= segment->total_size) { + if (segment->done != NULL) { + rc = segment->done(tcp_conn, segment); +- if (rc < 0) ++ if (rc != 0) + goto error; + } + } +@@ -1142,8 +1125,8 @@ error: + /* Transmit error. We could initiate error recovery + * here. */ + debug_tcp("Error sending PDU, errno=%d\n", rc); +- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); +- return rc; ++ iscsi_conn_failure(conn, rc); ++ return -EIO; + } + + /** +diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c +index dfeaed3..f3b845f 100644 +--- a/kernel/libiscsi.c ++++ b/kernel/libiscsi.c +@@ -405,11 +405,6 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, + conn->session->queued_cmdsn--; + else + conn->session->tt->cleanup_task(conn, task); +- /* +- * Check if cleanup_task dropped the lock and the command completed, +- */ +- if (!task->sc) +- return; + + sc->result = err; + if (!scsi_bidi_cmnd(sc)) +@@ -634,6 +629,40 @@ out: + __iscsi_put_task(task); + } + ++/** ++ * iscsi_data_in_rsp - SCSI Data-In Response processing ++ * @conn: iscsi connection ++ * @hdr: iscsi pdu ++ * @task: scsi command task ++ **/ ++static void ++iscsi_data_in_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ++ struct iscsi_task *task) ++{ ++ struct iscsi_data_rsp *rhdr = (struct iscsi_data_rsp *)hdr; ++ struct scsi_cmnd *sc = task->sc; ++ ++ if (!(rhdr->flags & ISCSI_FLAG_DATA_STATUS)) ++ return; ++ ++ sc->result = (DID_OK << 16) | rhdr->cmd_status; ++ conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; ++ if (rhdr->flags & (ISCSI_FLAG_DATA_UNDERFLOW | ++ ISCSI_FLAG_DATA_OVERFLOW)) { ++ int res_count = be32_to_cpu(rhdr->residual_count); ++ ++ if (res_count > 0 && ++ (rhdr->flags & ISCSI_FLAG_CMD_OVERFLOW || ++ res_count <= scsi_in(sc)->length)) ++ scsi_in(sc)->resid = res_count; ++ else ++ sc->result = (DID_BAD_TARGET << 16) | rhdr->cmd_status; ++ } ++ ++ conn->scsirsp_pdus_cnt++; ++ __iscsi_put_task(task); ++} ++ + static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) + { + struct iscsi_tm_rsp *tmf = (struct iscsi_tm_rsp *)hdr; +@@ -819,12 +848,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, + iscsi_scsi_cmd_rsp(conn, hdr, task, data, datalen); + break; + case ISCSI_OP_SCSI_DATA_IN: +- if (hdr->flags & ISCSI_FLAG_DATA_STATUS) { +- conn->scsirsp_pdus_cnt++; +- iscsi_update_cmdsn(session, +- (struct iscsi_nopin*) hdr); +- __iscsi_put_task(task); +- } ++ iscsi_data_in_rsp(conn, hdr, task); + break; + case ISCSI_OP_LOGOUT_RSP: + iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); +@@ -1769,10 +1793,10 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) + + iscsi_suspend_tx(conn); + +- spin_lock(&session->lock); ++ spin_lock_bh(&session->lock); + fail_all_commands(conn, sc->device->lun, DID_ERROR); + conn->tmf_state = TMF_INITIAL; +- spin_unlock(&session->lock); ++ spin_unlock_bh(&session->lock); + + iscsi_start_tx(conn); + goto done; +diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c +index 7dfb7da..852b016 100644 +--- a/kernel/scsi_transport_iscsi.c ++++ b/kernel/scsi_transport_iscsi.c +@@ -138,7 +138,7 @@ static ssize_t + show_ep_handle(struct device *dev, struct device_attribute *attr, char *buf) + { + struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev); +- return sprintf(buf, "%u\n", ep->id); ++ return sprintf(buf, "%llu\n", (unsigned long long) ep->id); + } + static ISCSI_ATTR(ep, handle, S_IRUGO, show_ep_handle, NULL); + +@@ -156,7 +156,7 @@ static struct attribute_group iscsi_endpoint_group = { + static int iscsi_match_epid(struct device *dev, void *data) + { + struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev); +- unsigned int *epid = (unsigned int *) data; ++ uint64_t *epid = (uint64_t *) data; + + return *epid == ep->id; + } +@@ -166,7 +166,7 @@ iscsi_create_endpoint(int dd_size) + { + struct device *dev; + struct iscsi_endpoint *ep; +- unsigned int id; ++ uint64_t id; + int err; + + for (id = 1; id < ISCSI_MAX_EPID; id++) { +@@ -187,7 +187,8 @@ iscsi_create_endpoint(int dd_size) + + ep->id = id; + ep->dev.class = &iscsi_endpoint_class; +- snprintf(ep->dev.bus_id, BUS_ID_SIZE, "ep-%u", id); ++ snprintf(ep->dev.bus_id, BUS_ID_SIZE, "ep-%llu", ++ (unsigned long long) id); + err = device_register(&ep->dev); + if (err) + goto free_ep; +diff --git a/kernel/scsi_transport_iscsi.h b/kernel/scsi_transport_iscsi.h +index 7013828..b65c96a 100644 +--- a/kernel/scsi_transport_iscsi.h ++++ b/kernel/scsi_transport_iscsi.h +@@ -207,7 +207,7 @@ extern void iscsi_host_for_each_session(struct Scsi_Host *shost, + struct iscsi_endpoint { + void *dd_data; /* LLD private data */ + struct device dev; +- unsigned int id; ++ uint64_t id; + }; + + /* +diff --git a/usr/initiator.c b/usr/initiator.c +index b85416e..8bd7a90 100644 +--- a/usr/initiator.c ++++ b/usr/initiator.c +@@ -995,7 +995,15 @@ static void session_conn_error(void *data) + "state (%d)", session->id, conn->id, error, + conn->state); + iscsi_conn_context_put(conn_context); +- __conn_error_handle(session, conn); ++ ++ switch (error) { ++ case ISCSI_ERR_INVALID_HOST: ++ if (session_conn_shutdown(conn, NULL, MGMT_IPC_OK)) ++ log_error("BUG: Could not shutdown session."); ++ break; ++ default: ++ __conn_error_handle(session, conn); ++ } + } + + static void iscsi_login_timedout(void *data) diff --git a/open-iscsi-error-check-in-db-lock-creation b/open-iscsi-error-check-in-db-lock-creation new file mode 100644 index 0000000..5a280be --- /dev/null +++ b/open-iscsi-error-check-in-db-lock-creation @@ -0,0 +1,43 @@ +commit 37f18edf5c61193434651fc61f5cfe5107f43c6d +Author: Hans de Goede +Date: Mon Sep 29 13:11:58 2008 +0200 + + PATCH: add error checking to iscsi discovery db lock creation + + Hi Make, + + I've been bitten numerous times now by iscsiadm hanging when run as normal user + (it spins trying to create the lock, which will never succeed as it simple + misses the rights todo so). + + I plan on including the attached patch in the new rawhide / F-10 package with + the new initscripts I'm working on. Please scream loudly if you object against + this patch. + + Regards, + + Hans + + p.s. + + If we go ahead with this patch I assume you will take care of getting it upstream. + +diff --git a/usr/idbm.c b/usr/idbm.c +index 0cb3c44..a7a1072 100644 +--- a/usr/idbm.c ++++ b/usr/idbm.c +@@ -850,6 +850,14 @@ int idbm_lock(void) + if (ret == 0) + break; + ++ if (errno != EEXIST) { ++ log_error("Could not lock discovery DB: %s: %s", ++ LOCK_WRITE_FILE, strerror(errno)); ++ log_error("Maybe you are not root?"); ++ exit(-1); ++ } else if (i == 0) ++ log_debug(2, "Waiting for discovery DB lock"); ++ + usleep(10000); + } + diff --git a/open-iscsi-initiator-compile-warning b/open-iscsi-initiator-compile-warning new file mode 100644 index 0000000..5420209 --- /dev/null +++ b/open-iscsi-initiator-compile-warning @@ -0,0 +1,22 @@ +commit 32a4c65219dbbe87d8b8bdd878b94c4baa0a91ea +Author: Mike Christie +Date: Tue Sep 30 11:28:01 2008 -0500 + + Fix initiator.c compile warning + + A log_error message had a extra "," which was causing compile + warnings. + +diff --git a/usr/initiator.c b/usr/initiator.c +index 8bd7a90..10cf050 100644 +--- a/usr/initiator.c ++++ b/usr/initiator.c +@@ -2009,7 +2009,7 @@ session_login_task(node_rec_t *rec, queue_task_t *qtask) + + if (!(t->caps & CAP_MARKERS) && + rec->conn[0].iscsi.OFMarker) { +- log_error("Transport '%s' does not support OFMarker.", ++ log_error("Transport '%s' does not support OFMarker." + "Disabling OFMarkers.\n", t->name); + rec->conn[0].iscsi.OFMarker = 0; + } diff --git a/open-iscsi-install-mkinitrd-scriptlets b/open-iscsi-install-mkinitrd-scriptlets new file mode 100644 index 0000000..0b2c886 --- /dev/null +++ b/open-iscsi-install-mkinitrd-scriptlets @@ -0,0 +1,26 @@ +diff --git a/Makefile b/Makefile +index e405c9c..de66ae1 100644 +--- a/Makefile ++++ b/Makefile +@@ -13,6 +13,7 @@ bindir = $(exec_prefix)/bin + mandir = $(prefix)/share/man + etcdir = /etc + initddir = $(etcdir)/init.d ++mkinitrd = $(exec_prefix)/lib/mkinitrd/scripts + + MANPAGES = doc/iscsid.8 doc/iscsiadm.8 doc/iscsi_discovery.8 + PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi_discovery utils/iscsi-iname +@@ -81,6 +82,13 @@ install_initd_suse: + $(DESTDIR)$(initddir)/open-iscsi + $(INSTALL) -m 755 etc/initd/boot.suse \ + $(DESTDIR)$(initddir)/boot.open-iscsi ++ $(INSTALL) -d $(DESTDIR)$(mkinitrd) ++ $(INSTALL) -m 755 etc/mkinitrd/mkinitrd-boot.sh \ ++ $(DESTDIR)$(mkinitrd)/boot-iscsi.sh ++ $(INSTALL) -m 755 etc/mkinitrd/mkinitrd-setup.sh \ ++ $(DESTDIR)$(mkinitrd)/setup-iscsi.sh ++ $(INSTALL) -m 755 etc/mkinitrd/mkinitrd-stop.sh \ ++ $(DESTDIR)$(mkinitrd)/boot-killiscsi.sh + + install_initd_redhat: + $(INSTALL) -d $(DESTDIR)$(initddir) diff --git a/open-iscsi-iscsi_discovery-doc-fixes b/open-iscsi-iscsi_discovery-doc-fixes new file mode 100644 index 0000000..b1b89ef --- /dev/null +++ b/open-iscsi-iscsi_discovery-doc-fixes @@ -0,0 +1,72 @@ +commit 8d903115f9227a3922ec8172a0faa57b95c8a57f +Author: Erez Zilber +Date: Wed Oct 22 11:45:24 2008 +0200 + + Minor fixes in iscsi_discovery documentation + + Some changes that were made in iscsi_discovery were + not reflected in the docs. + + Signed-off-by: Erez Zilber + +diff --git a/doc/iscsi_discovery.8 b/doc/iscsi_discovery.8 +index c46223b..13484e7 100644 +--- a/doc/iscsi_discovery.8 ++++ b/doc/iscsi_discovery.8 +@@ -6,19 +6,19 @@ + + .TH "iscsi_discovery" 8 + .SH NAME +-iscsi_discovery \- discover iscsi devices ++iscsi_discovery \- discover iSCSI targets + .SH SYNOPSIS + .B iscsi_discovery [-p ] [-d] [-t [-f]] [-m] [-l] + + .SH DESCRIPTION + Perform send-targets discovery to the specified IP. If a discovery record +-is generated, try to login to the portal using iSER and TCP transports ++is generated, try to login to the portal using the preferred transport + (-t flag specifies the requested transport type, TCP is the default). + If login using a certain transport succeeds, mark the portal for automatic + login (unless -m flag is used), and disconnect (unless -l flag is used). + +-For iscsi discovery to work, open-iscsi services must be running. e.g. iscsid +-should be up, and the iscsi modules loaded. This is best accomplished by the ++For iSCSI discovery to work, open-iscsi services must be running. i.e. iscsid ++should be up, and the iSCSI modules loaded. This is best accomplished by the + init.d startup script. + + .\" .SH OPTIONS +@@ -47,6 +47,6 @@ login - login to the new discovered nodes (defualt is false). + .SH AUTHOR + Written by Dan Bar Dov + .SH "REPORTING BUGS" +-Report bugs to . ++Report bugs to . + .SH COPYRIGHT + Copyright \(co Voltaire Ltd. 2006. +diff --git a/utils/iscsi_discovery b/utils/iscsi_discovery +index 9f1e7cf..3c6edf3 100755 +--- a/utils/iscsi_discovery ++++ b/utils/iscsi_discovery +@@ -20,17 +20,17 @@ + + # iscsi_discovery: + # * does a send-targets discovery to the given IP +-# * set the transport type to ISER ++# * set the transport type to the preferred transport (or tcp is -t flag is not used) + # * tries to login + # * if succeeds, + # o logout, +-# o mark record autmatic ++# o mark record autmatic (unless -m flag is used) + # * else + # o reset transport type to TCP + # o try to login + # o if succeeded + # + logout +-# + mark record automatic ++# + mark record automatic (unless -m flag is used) + # + + usage() diff --git a/open-iscsi-login-retry-update b/open-iscsi-login-retry-update new file mode 100644 index 0000000..95efbc9 --- /dev/null +++ b/open-iscsi-login-retry-update @@ -0,0 +1,184 @@ +diff --git a/etc/iscsid.conf b/etc/iscsid.conf +index f2691ee..4f6e08a 100644 +--- a/etc/iscsid.conf ++++ b/etc/iscsid.conf +@@ -107,14 +107,31 @@ node.session.err_timeo.lu_reset_timeout = 20 + # Retry + #****** + +-# To speficy the number of times iscsiadm should retry a login +-# to the target when we first login, modify the following line. +-# The default is 4. Valid values are any integer value. This only ++# To specify the number of times iscsid should retry a login ++# if the login attempt fails due to the node.conn[0].timeo.login_timeout ++# expiring modify the following line. Note that if the login fails ++# quickly (before node.conn[0].timeo.login_timeout fires) because the network ++# layer or the target returns an error, iscsid may retry the login more than ++# node.session.initial_login_retry_max times. ++# ++# This retry count along with node.conn[0].timeo.login_timeout ++# determines the maximum amount of time iscsid will try to ++# establish the initial login. node.session.initial_login_retry_max is ++# multiplied by the node.conn[0].timeo.login_timeout to determine the ++# maximum amount. ++# ++# The default node.session.initial_login_retry_max is 8 and ++# node.conn[0].timeo.login_timeout is 15 so we have: ++# ++# node.conn[0].timeo.login_timeout * node.session.initial_login_retry_max = ++# 120 seconds ++# ++# Valid values are any integer value. This only + # affects the initial login. Setting it to a high value can slow + # down the iscsi service startup. Setting it to a low value can + # cause a session to not get logged into, if there are distuptions + # during startup or if the network is not ready at that time. +-node.session.initial_login_retry_max = 4 ++node.session.initial_login_retry_max = 8 + + ################################ + # session and device queue depth +diff --git a/usr/initiator.c b/usr/initiator.c +index 2f29ffc..b85416e 100644 +--- a/usr/initiator.c ++++ b/usr/initiator.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include "initiator.h" + #include "transport.h" +@@ -773,13 +774,45 @@ session_conn_reopen(iscsi_conn_t *conn, queue_task_t *qtask, int do_stop) + __session_conn_reopen(conn, qtask, do_stop, 0); + } + ++static int iscsi_retry_initial_login(struct iscsi_conn *conn) ++{ ++ int initial_login_retry_max; ++ struct timeval now, timeout, fail_time; ++ ++ initial_login_retry_max = ++ conn->session->nrec.session.initial_login_retry_max; ++ ++ memset(&now, 0, sizeof(now)); ++ memset(&timeout, 0, sizeof(timeout)); ++ memset(&fail_time, 0, sizeof(fail_time)); ++ ++ timeout.tv_sec = initial_login_retry_max * conn->login_timeout; ++ if (gettimeofday(&now, NULL)) { ++ log_error("Could not get time of day. Dropping down to " ++ "max retry check.\n"); ++ return initial_login_retry_max > conn->session->reopen_cnt; ++ } ++ timeradd(&conn->initial_connect_time, &timeout, &fail_time); ++ ++ /* ++ * if we have been trying for login_retry_max * login_timeout ++ * then it is time to give up ++ */ ++ if (timercmp(&now, &fail_time, >)) { ++ log_debug(1, "Giving up on initial login attempt after " ++ "%u seconds.\n", ++ initial_login_retry_max * conn->login_timeout); ++ return 0; ++ } ++ ++ return 1; ++} ++ + static void iscsi_login_eh(struct iscsi_conn *conn, struct queue_task *qtask, + mgmt_ipc_err_e err) + { + struct iscsi_session *session = conn->session; +- int initial_login_retry_max; + +- initial_login_retry_max = session->nrec.session.initial_login_retry_max; + log_debug(3, "iscsi_login_eh"); + /* + * Flush polls and other events +@@ -791,12 +824,10 @@ static void iscsi_login_eh(struct iscsi_conn *conn, struct queue_task *qtask, + switch (session->r_stage) { + case R_STAGE_NO_CHANGE: + log_debug(6, "login failed STATE_XPT_WAIT/" +- "R_STAGE_NO_CHANGE (%d/%d)", +- session->reopen_cnt, +- initial_login_retry_max); ++ "R_STAGE_NO_CHANGE"); + /* timeout during initial connect. + * clean connection. write ipc rsp or retry */ +- if (initial_login_retry_max < session->reopen_cnt + 1) ++ if (!iscsi_retry_initial_login(conn)) + session_conn_shutdown(conn, qtask, err); + else { + session->reopen_cnt++; +@@ -808,12 +839,10 @@ static void iscsi_login_eh(struct iscsi_conn *conn, struct queue_task *qtask, + break; + case R_STAGE_SESSION_REDIRECT: + log_debug(6, "login failed STATE_XPT_WAIT/" +- "R_STAGE_SESSION_REDIRECT (%d/%d)", +- session->reopen_cnt, +- initial_login_retry_max); ++ "R_STAGE_SESSION_REDIRECT"); + /* timeout during initial redirect connect + * clean connection. write ipc rsp or retry */ +- if (initial_login_retry_max < session->reopen_cnt + 1) ++ if (!iscsi_retry_initial_login(conn)) + session_conn_shutdown(conn, qtask, err); + else + session_conn_reopen(conn, qtask, 0); +@@ -845,7 +874,7 @@ static void iscsi_login_eh(struct iscsi_conn *conn, struct queue_task *qtask, + * initial redirected connect. Clean connection + * and write rsp or retry. + */ +- if (initial_login_retry_max < session->reopen_cnt + 1) ++ if (!iscsi_retry_initial_login(conn)) + session_conn_shutdown(conn, qtask, err); + else + session_conn_reopen(conn, qtask, +@@ -1997,6 +2026,11 @@ session_login_task(node_rec_t *rec, queue_task_t *qtask) + return MGMT_IPC_ERR_TRANS_FAILURE; + } + ++ if (gettimeofday(&conn->initial_connect_time, NULL)) ++ log_error("Could not get initial connect time. If " ++ "login errors iscsid may give up the initial " ++ "login early. You should manually login."); ++ + qtask->rsp.command = MGMT_IPC_SESSION_LOGIN; + qtask->rsp.err = MGMT_IPC_OK; + return MGMT_IPC_OK; +diff --git a/usr/initiator.h b/usr/initiator.h +index 594e8f8..682ebfc 100644 +--- a/usr/initiator.h ++++ b/usr/initiator.h +@@ -22,6 +22,7 @@ + + #include + #include ++#include + + #include "types.h" + #include "iscsi_proto.h" +@@ -125,6 +126,7 @@ typedef struct iscsi_conn { + iscsi_conn_state_e state; + int userspace_nop; + ++ struct timeval initial_connect_time; + actor_t login_timer; + actor_t nop_out_timer; + +diff --git a/usr/iscsistart.c b/usr/iscsistart.c +index eb11bcc..cc57f1c 100644 +--- a/usr/iscsistart.c ++++ b/usr/iscsistart.c +@@ -130,7 +130,7 @@ static int setup_session(void) + * For root boot we cannot change this so increase to account + * for boot using static setup. + */ +- config_rec.session.initial_login_retry_max = 120; ++ config_rec.session.initial_login_retry_max = 30; + /* we cannot answer so turn off */ + config_rec.conn[0].timeo.noop_out_interval = 0; + config_rec.conn[0].timeo.noop_out_timeout = 0; diff --git a/open-iscsi-option-no-pid-file b/open-iscsi-option-no-pid-file new file mode 100644 index 0000000..d85601c --- /dev/null +++ b/open-iscsi-option-no-pid-file @@ -0,0 +1,119 @@ +From 5ebb5dbca96a0854bd0c3306a42fac7c4ebefe61 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Wed, 12 Nov 2008 15:24:21 +0100 +Subject: [PATCH] iscsid: Implement --no-pid-file + +For root on iSCSI scenarios the /var directory might not exist. +And we don't need the pid file anyway as the daemon is synchronized +via the IPC connection. + +Signed-off-by: Hannes Reinecke +--- + doc/iscsid.8 | 3 +++ + usr/iscsid.c | 40 ++++++++++++++++++++++++---------------- + 2 files changed, 27 insertions(+), 16 deletions(-) + +diff --git a/doc/iscsid.8 b/doc/iscsid.8 +index 1dfa1e5..92b7f81 100644 +--- a/doc/iscsid.8 ++++ b/doc/iscsid.8 +@@ -35,6 +35,9 @@ run under user ID \fIuid\fR (default is the current user ID) + .BI [-g|--gid=]\fIgid\fP + run under user group ID \fIgid\fR (default is the current user group ID). + .TP ++.BI [-n|--no-pid-file]\fP ++do not write a process ID file. ++.TP + .BI [-p|--pid=]\fIpid\-file\fP + write process ID to \fIpid\-file\fR rather than the default + \fI/var/run/iscsid.pid\fR +diff --git a/usr/iscsid.c b/usr/iscsid.c +index 578a206..3da235b 100644 +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -59,6 +59,7 @@ static struct option const long_options[] = { + {"debug", required_argument, NULL, 'd'}, + {"uid", required_argument, NULL, 'u'}, + {"gid", required_argument, NULL, 'g'}, ++ {"no-pid-file", no_argument, NULL, 'n'}, + {"pid", required_argument, NULL, 'p'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, +@@ -80,6 +81,7 @@ Open-iSCSI initiator daemon.\n\ + -d, --debug debuglevel print debugging information\n\ + -u, --uid=uid run as uid, default is current user\n\ + -g, --gid=gid run as gid, default is current user group\n\ ++ -n, --no-pid-file do not use a pid file\n\ + -p, --pid=pidfile use pid file (default " PID_FILE ").\n\ + -h, --help display this help and exit\n\ + -v, --version display version and exit\n\ +@@ -332,7 +334,7 @@ int main(int argc, char *argv[]) + sigaction(SIGPIPE, &sa_new, &sa_old ); + sigaction(SIGTERM, &sa_new, &sa_old ); + +- while ((ch = getopt_long(argc, argv, "c:i:fd:u:g:p:vh", long_options, ++ while ((ch = getopt_long(argc, argv, "c:i:fd:nu:g:p:vh", long_options, + &longindex)) >= 0) { + switch (ch) { + case 'c': +@@ -353,6 +355,9 @@ int main(int argc, char *argv[]) + case 'g': + gid = strtoul(optarg, NULL, 10); + break; ++ case 'n': ++ pid_file = NULL; ++ break; + case 'p': + pid_file = optarg; + break; +@@ -404,13 +409,15 @@ int main(int argc, char *argv[]) + + if (log_daemon) { + char buf[64]; +- int fd; +- +- fd = open(pid_file, O_WRONLY|O_CREAT, 0644); +- if (fd < 0) { +- log_error("Unable to create pid file"); +- log_close(log_pid); +- exit(1); ++ int fd = -1; ++ ++ if (pid_file) { ++ fd = open(pid_file, O_WRONLY|O_CREAT, 0644); ++ if (fd < 0) { ++ log_error("Unable to create pid file"); ++ log_close(log_pid); ++ exit(1); ++ } + } + pid = fork(); + if (pid < 0) { +@@ -428,15 +435,16 @@ int main(int argc, char *argv[]) + } + + chdir("/"); +- if (lockf(fd, F_TLOCK, 0) < 0) { +- log_error("Unable to lock pid file"); +- log_close(log_pid); +- exit(1); ++ if (fd > 0) { ++ if (lockf(fd, F_TLOCK, 0) < 0) { ++ log_error("Unable to lock pid file"); ++ log_close(log_pid); ++ exit(1); ++ } ++ ftruncate(fd, 0); ++ sprintf(buf, "%d\n", getpid()); ++ write(fd, buf, strlen(buf)); + } +- ftruncate(fd, 0); +- sprintf(buf, "%d\n", getpid()); +- write(fd, buf, strlen(buf)); +- + daemon_init(); + } else { + if ((control_fd = ipc->ctldev_open()) < 0) { +-- +1.6.0.2 + diff --git a/open-iscsi-rm-unused-variable b/open-iscsi-rm-unused-variable new file mode 100644 index 0000000..9e2036b --- /dev/null +++ b/open-iscsi-rm-unused-variable @@ -0,0 +1,21 @@ +commit de8a96fe313aecaf73e94810b571f342f627e288 +Author: Erez Zilber +Date: Wed Oct 22 12:00:00 2008 +0200 + + rm unused variable in fw_entry.c + + Signed-off-by: Erez Zilber + +diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c +index 915bbb7..fbfa3dd 100644 +--- a/utils/fwparam_ibft/fw_entry.c ++++ b/utils/fwparam_ibft/fw_entry.c +@@ -38,8 +38,6 @@ int fw_get_entry(struct boot_context *context, const char *filepath) + */ + static void dump_mac(struct boot_context *context) + { +- int i; +- + if (!strlen(context->mac)) + return; + diff --git a/open-iscsi-set-LOCK_DIR-during-compilation b/open-iscsi-set-LOCK_DIR-during-compilation new file mode 100644 index 0000000..8b747f5 --- /dev/null +++ b/open-iscsi-set-LOCK_DIR-during-compilation @@ -0,0 +1,35 @@ +From 96de3656d3eb10dedcee1d9b31156f35bf519d17 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Wed, 12 Nov 2008 15:28:46 +0100 +Subject: [PATCH] Allow LOCK_DIR to be set via CFLAGS + +For root on iSCSI we have to move idbm's LOCK_DIR to eg /etc/iscsi, +as the /var directory might not be available. So make it configurable +during compile-time. + +Signed-off-by: Hannes Reinecke +--- + usr/initiator.h | 6 ++++-- + 1 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/usr/initiator.h b/usr/initiator.h +index 682ebfc..033cce9 100644 +--- a/usr/initiator.h ++++ b/usr/initiator.h +@@ -39,9 +39,11 @@ + #define INITIATOR_NAME_FILE ISCSI_CONFIG_ROOT"initiatorname.iscsi" + + #define PID_FILE "/var/run/iscsid.pid" ++#ifndef LOCK_DIR + #define LOCK_DIR "/var/lock/iscsi" +-#define LOCK_FILE "/var/lock/iscsi/lock" +-#define LOCK_WRITE_FILE "/var/lock/iscsi/lock.write" ++#endif ++#define LOCK_FILE LOCK_DIR"/lock" ++#define LOCK_WRITE_FILE LOCK_DIR"/lock.write" + + typedef enum iscsi_conn_state_e { + STATE_FREE, +-- +1.6.0.2 + diff --git a/open-iscsi-sync-modules-with-2.6.27 b/open-iscsi-sync-modules-with-2.6.27 new file mode 100644 index 0000000..d3fc9a9 --- /dev/null +++ b/open-iscsi-sync-modules-with-2.6.27 @@ -0,0 +1,82 @@ +commit 23a7691b724548cc096996ab8f1cb5823c573880 +Author: Mike Christie +Date: Sat Sep 13 19:35:33 2008 -0500 + + Sync kernel modules with 2.6.27 + + Update kernel modules for 2.6.27 kernel API changes. + +diff --git a/kernel/Makefile b/kernel/Makefile +index 139fd7b..7c5b5ac 100644 +--- a/kernel/Makefile ++++ b/kernel/Makefile +@@ -101,6 +101,8 @@ linux_2_6_25: has_24_patch + + linux_2_6_26: $(unpatch_code) + ++linux_2_6_27: $(unpatch_code) ++ + do_unpatch_code: + echo "Un-patching source code for use with linux-2.6.14 and up ..." + patch -R -E -p1 < $(cur_patched) +diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c +index 535e461..7dfb7da 100644 +--- a/kernel/scsi_transport_iscsi.c ++++ b/kernel/scsi_transport_iscsi.c +@@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size) + int err; + + for (id = 1; id < ISCSI_MAX_EPID; id++) { +- dev = class_find_device(&iscsi_endpoint_class, &id, ++ dev = class_find_device(&iscsi_endpoint_class, NULL, &id, + iscsi_match_epid); + if (!dev) + break; +@@ -219,14 +219,21 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint); + + struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) + { ++ struct iscsi_endpoint *ep; + struct device *dev; + +- dev = class_find_device(&iscsi_endpoint_class, &handle, ++ dev = class_find_device(&iscsi_endpoint_class, NULL, &handle, + iscsi_match_epid); + if (!dev) + return NULL; + +- return iscsi_dev_to_endpoint(dev); ++ ep = iscsi_dev_to_endpoint(dev); ++ /* ++ * we can drop this now because the interface will prevent ++ * removals and lookups from racing. ++ */ ++ put_device(dev); ++ return ep; + } + EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); + +@@ -240,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev, + atomic_set(&ihost->nr_scans, 0); + mutex_init(&ihost->mutex); + +- snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d", +- shost->host_no); ++ snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name), ++ "iscsi_scan_%d", shost->host_no); + ihost->scan_workq = create_singlethread_workqueue( + ihost->scan_workq_name); + if (!ihost->scan_workq) +diff --git a/kernel/scsi_transport_iscsi.h b/kernel/scsi_transport_iscsi.h +index b7652e3..7013828 100644 +--- a/kernel/scsi_transport_iscsi.h ++++ b/kernel/scsi_transport_iscsi.h +@@ -198,7 +198,7 @@ struct iscsi_cls_host { + atomic_t nr_scans; + struct mutex mutex; + struct workqueue_struct *scan_workq; +- char scan_workq_name[KOBJ_NAME_LEN]; ++ char scan_workq_name[20]; + }; + + extern void iscsi_host_for_each_session(struct Scsi_Host *shost, diff --git a/open-iscsi-update-suse-init-scripts b/open-iscsi-update-suse-init-scripts new file mode 100644 index 0000000..9bcb14d --- /dev/null +++ b/open-iscsi-update-suse-init-scripts @@ -0,0 +1,113 @@ +From e734d56e6a45eb85cbd8d728310a793970e90757 Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Wed, 12 Nov 2008 15:25:55 +0100 +Subject: [PATCH] Update SUSE init scripts + +Update SUSE init scripts to work properly for root-on-iSCSI. + +Signed-off-by: Hannes Reinecke +--- + etc/initd/boot.suse | 15 +++++++-------- + etc/initd/initd.suse | 36 ------------------------------------ + 2 files changed, 7 insertions(+), 44 deletions(-) + +diff --git a/etc/initd/boot.suse b/etc/initd/boot.suse +index e4a54a6..3e93cad 100644 +--- a/etc/initd/boot.suse ++++ b/etc/initd/boot.suse +@@ -4,7 +4,7 @@ + # + ### BEGIN INIT INFO + # Provides: iscsiboot +-# Required-Start: boot.proc ++# Required-Start: + # Should-Start: + # Required-Stop: $null + # Should-Stop: +@@ -26,16 +26,16 @@ ARGS="-c $CONFIG_FILE -p $PID_FILE" + . /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. ++# This service is run right after booting. So all targets activated ++# during mkinitrd run 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 ++ STARTUP=`$ISCSIADM -m node -p $ip -T $target 2> /dev/null | grep "node.conn\[0\].startup" | cut -d' ' -f3` ++ if [ "$STARTUP" -a "$STARTUP" != "onboot" ] ; then + $ISCSIADM -m node -p $ip -T $target -o update -n node.conn[0].startup -v onboot + fi + done +@@ -52,7 +52,6 @@ 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 +diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse +index 5c42b88..69b681b 100644 +--- a/etc/initd/initd.suse ++++ b/etc/initd/initd.suse +@@ -103,38 +103,6 @@ iscsi_list_all_nodes() + 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 +@@ -149,10 +117,6 @@ case "$1" in + rc_status -v + fi + if [ "$RETVAL" == "0" ]; then +- iscsi_discover_all_targets +- RETVAL=$? +- fi +- if [ "$RETVAL" == "0" ]; then + iscsi_login_all_nodes + fi + ;; +-- +1.6.0.2 + diff --git a/open-iscsi.changes b/open-iscsi.changes index 7c38cb4..d00f8ff 100644 --- a/open-iscsi.changes +++ b/open-iscsi.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Thu Nov 13 11:38:30 CET 2008 - hare@suse.de + +- Update iscsi-gen-initiatorname to work with newer kernels + (bnc#443509) + +------------------------------------------------------------------- +Wed Nov 12 15:54:21 CET 2008 - hare@suse.de + +- Update SUSE init scripts to work with newer kernels +- Move mkinitrd scriptlets to git repository +- Fixes for root-on-iSCSI: + * Update mkinitrd scripts to work with newer kernels (bnc#435215) + * Allow 'onboot' for iscsiadm -L + * Add option to not write a pid file +- Update login retry mechanism to work around the spanning-tree + issue (bnc#433363) + ------------------------------------------------------------------- Wed Sep 3 11:06:21 CEST 2008 - hare@suse.de diff --git a/open-iscsi.spec b/open-iscsi.spec index 5bb7ae3..25b995a 100644 --- a/open-iscsi.spec +++ b/open-iscsi.spec @@ -26,15 +26,12 @@ Group: Productivity/Networking/Other PreReq: %fillup_prereq %insserv_prereq AutoReqProv: on Version: 2.0.870 -Release: 13 +Release: 19 Provides: linux-iscsi Obsoletes: linux-iscsi %define iscsi_release 865 Summary: Linux* Open-iSCSI Software Initiator Source: %{name}-2.0-870-rc1.tar.bz2 -Source5: mkinitrd-setup.sh -Source6: mkinitrd-boot.sh -Source7: mkinitrd-stop.sh Source11: iscsi-gen-initiatorname.sh Patch1: %{name}-start-target-before-initiator Patch2: %{name}-suse-build-fixes @@ -43,6 +40,20 @@ Patch4: %{name}-update-init-script Patch5: %{name}-add-rhel5-compat Patch6: %{name}-add-sles10-compat Patch7: %{name}-iscsid-adjust-settings +Patch8: %{name}-login-retry-update +Patch9: %{name}-beta5-kernel-patch-update +Patch10: %{name}-error-check-in-db-lock-creation +Patch11: %{name}-initiator-compile-warning +Patch12: %{name}-iscsi_discovery-doc-fixes +Patch13: %{name}-rm-unused-variable +Patch14: %{name}-add-error-msg-to-log.c +Patch15: %{name}-sync-modules-with-2.6.27 +Patch16: %{name}-allow-onboot-for-loginall +Patch17: %{name}-option-no-pid-file +Patch18: %{name}-update-suse-init-scripts +Patch19: %{name}-set-LOCK_DIR-during-compilation +Patch20: %{name}-add-mkinitrd-scriptlets +Patch21: %{name}-install-mkinitrd-scriptlets BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -79,18 +90,28 @@ Authors: %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 +%patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 %build -%{__make} OPTFLAGS="${RPM_OPT_FLAGS}" +%{__make} OPTFLAGS="${RPM_OPT_FLAGS} -DLOCK_DIR=\\\"/etc/iscsi\\\"" %install make DESTDIR=${RPM_BUILD_ROOT} install make DESTDIR=${RPM_BUILD_ROOT} install_initd_suse install -D -m 755 %{S:11} ${RPM_BUILD_ROOT}/sbin/iscsi-gen-initiatorname -install -d $RPM_BUILD_ROOT/lib/mkinitrd/scripts -install -m 755 %{S:5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/setup-iscsi.sh -install -m 755 %{S:6} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-iscsi.sh -install -m 755 %{S:7} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-killiscsi.sh (cd ${RPM_BUILD_ROOT}/sbin; ln -sf /etc/init.d/open-iscsi rcopen-iscsi) (cd ${RPM_BUILD_ROOT}/etc; ln -sf iscsi/iscsid.conf iscsid.conf) @@ -130,10 +151,22 @@ fi %doc %{_mandir}/man8/* %changelog +* Thu Nov 13 2008 hare@suse.de +- Update iscsi-gen-initiatorname to work with newer kernels + (bnc#443509) +* Wed Nov 12 2008 hare@suse.de +- Update SUSE init scripts to work with newer kernels +- Move mkinitrd scriptlets to git repository +- Fixes for root-on-iSCSI: + * Update mkinitrd scripts to work with newer kernels (bnc#435215) + * Allow 'onboot' for iscsiadm -L + * Add option to not write a pid file +- Update login retry mechanism to work around the spanning-tree + issue (bnc#433363) * Wed Sep 03 2008 hare@suse.de - Pull in fixes from upstream git repository - Call mkinitrd_setup during %%post and %%postun (bnc#413709) -* Fri Aug 29 2008 cthiel@suse.de +* Thu Aug 28 2008 cthiel@suse.de - fix init script * Thu Jul 24 2008 hare@suse.de - Update to 2.0-870-rc1