Skip to content

Commit

Permalink
Commit sys-block/iscsitarget
Browse files Browse the repository at this point in the history
Package-Manager: portage-2.1.11.31
  • Loading branch information
ryao committed Jan 3, 2013
1 parent c23fab2 commit 916fd5e
Show file tree
Hide file tree
Showing 9 changed files with 570 additions and 0 deletions.
1 change: 1 addition & 0 deletions sys-block/iscsitarget/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST iscsitarget-1.4.20.2_p20130103.tar.gz 147073 SHA256 ff86e0fc18e8a33b299c8438729613345a50b91f988383fc9cad240cd3f7c1c1 SHA512 7ed706c38a63b696ff344725308a5d476f8fc4ebee71456615274470afed4d9cb2985d0960a9e77d185e267771e6c7ece8707232d42affd11f7de76e0eaf7371 WHIRLPOOL d13a869e14d716558bf15b7291b0987c5561067faafc3af5e0fd0db0126add7fbc0621e53394ca912c55fb6a3aa9ff6d402aca52d18d7087b5c3d594e15021f4
30 changes: 30 additions & 0 deletions sys-block/iscsitarget/files/ietd-conf.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 1999-2006 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/sys-block/iscsitarget/files/ietd-conf.d,v 1.1 2006/02/20 08:33:40 robbat2 Exp $

# Address and port to listen on for connections.
#ADDRESS="" # set this to non-empty to listen somewhere specific
PORT=3260

# Address of your SNS server
# if available
#ISNS=""

# User and group to run as
# You must ensure that the UID/GID have access to the files/devices you
# have provided in your configuration.
USER="root"
GROUP="root"

# Debug level - see ietd(8) for the levels
#DEBUGLEVEL=

# This setting disables the memory configuration warnings.
# Upstream takes the general policy of forcing all of the memory settings that
# they want, but that doesn't mesh with users that have it set higher.
# Gentoo by default ignores the settings that are higher, but issues warnings
# on those that are lower.
# Uncomment the next line to disable those warnings.
#DISABLE_MEMORY_WARNINGS=1

# vim: filetype=gentoo-conf-d tw=72:
106 changes: 106 additions & 0 deletions sys-block/iscsitarget/files/ietd-init.d-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/sys-block/iscsitarget/files/ietd-init.d-2,v 1.2 2010/12/15 11:50:05 fauli Exp $

MEM_SIZE=1048576
DAEMON=/usr/sbin/ietd
CONFIG_FILE=/etc/ietd.conf
PID_FILE=/var/run/ietd.pid
NAME="iSCSI Enterprise Target"

ARGS=""
[ -n "$USER" ] && ARGS="${ARGS} --uid=${USER}"
[ -n "$GROUP" ] && ARGS="${ARGS} --gid=${GROUP}"
[ -n "$ISNS" ] && ARGS="${ARGS} --isns=${ISNS}"
[ -n "$PORT" ] && ARGS="${ARGS} --port=${PORT}"
[ -n "$ADDRESS" ] && ARGS="${ARGS} --address=${ADDRESS}"
[ -n "$DEBUGLEVEL" ] && ARGS="${ARGS} --debug=${DEBUGLEVEL}"

depend() {
use net
after modules
}
checkconfig() {
if [ ! -f $CONFIG_FILE ]; then
eerror "Config file $CONFIG_FILE does not exist!"
return 1
fi
if [ -z "$DISABLE_MEMORY_WARNINGS" ]; then
check_memsize
fi
}

check_memsize() {
local wr md sysctl_key v k
for wr in r w; do
for md in max default; do
sysctl_key="net.core.${wr}mem_${md}"
v="$(sysctl -n ${sysctl_key})"
if [ "${v}" -lt "${MEM_SIZE}" ]; then
ewarn "$sysctl_key ($v) is lower than recommended ${MEM_SIZE}"
fi
done
done
for wr in "" r w; do
sysctl_key="net.ipv4.tcp_${wr}mem"
set -- $(sysctl -n ${sysctl_key})
for k in min default max ; do
if [ "${1}" -lt "${MEM_SIZE}" ]; then
ewarn "$sysctl_key:$k (${1}) is lower than recommended ${MEM_SIZE}"
fi
shift
done
done
}

do_modules() {
msg="$1"
shift
modules="$1"
shift
opts="$@"
for m in ${modules}; do
ebegin "${msg} - ${m}"
modprobe ${opts} $m
ret=$?
eend $ret
[ $ret -ne 0 ] && return $ret
done
return 0
}

start() {
checkconfig || return 1
do_modules 'Loading iSCSI-Target modules' 'iscsi_trgt'
ebegin "Starting ${NAME}"
start-stop-daemon --start --exec $DAEMON --quiet -- ${ARGS}
eend $?
}

stop() {
ebegin "Removing ${NAME} devices"
# ugly, but ietadm does not allways provides correct exit values
RETURN="$(ietadm --op delete 2>&1)"
RETVAL=$?
if [ $RETVAL -eq 0 ] && [ "$RETURN" != "something wrong" ] ; then
eend 0
else
eend 1
eerror "ietadm failed - $RETURN"
return 1
fi

ebegin "Stopping ${NAME}"
start-stop-daemon --stop --quiet --exec $DAEMON --pidfile $PID_FILE
ret=$?
eend $ret
[ $ret -ne 0 ] && return 1

# ugly, but pid file is not removed by ietd
rm -f $PID_FILE
do_modules 'Removing iSCSI-Target modules' 'iscsi_trgt' '-r'
return $?
}

# vim: tw=72:
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Index: usr/Makefile
===================================================================
--- usr/Makefile (revision 446)
+++ usr/Makefile (working copy)
@@ -1,4 +1,4 @@
-CFLAGS += -O2 -fno-inline -Wall -Wstrict-prototypes -I../include
+CFLAGS += -fno-inline -Wall -Wstrict-prototypes -I../include
CFLAGS += -D_GNU_SOURCE # required for glibc >= 2.8
PROGRAMS = ietd ietadm
LIBS =
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
diff --git a/Makefile b/Makefile
index df41642..f2f17c8 100644
--- a/Makefile
+++ b/Makefile
@@ -46,18 +46,10 @@ kver_lt = $(shell [ $(KMAJ) -lt $(1) -o \
$(KMAJ) -eq $(1) -a $(KMIN) -lt $(2) -o \
$(KMAJ) -eq $(1) -a $(KMIN) -eq $(2) -a $(KREV) -lt $(3) ] && \
echo 1 || echo 0)
-kver_le = $(shell [ $(KMAJ) -lt $(1) -o \
- $(KMAJ) -eq $(1) -a $(KMIN) -lt $(2) -o \
- $(KMAJ) -eq $(1) -a $(KMIN) -eq $(2) -a $(KREV) -le $(3) ] && \
- echo 1 || echo 0)
-kver_gt = $(shell [ ( $(KMAJ) -gt $(1) ) -o \
+kver_gt = $(shell [ $(KMAJ) -gt $(1) -o \
$(KMAJ) -eq $(1) -a $(KMIN) -gt $(2) -o \
$(KMAJ) -eq $(1) -a $(KMIN) -eq $(2) -a $(KREV) -gt $(3) ] && \
echo 1 || echo 0)
-kver_ge = $(shell [ ( $(KMAJ) -gt $(1) ) -o \
- $(KMAJ) -eq $(1) -a $(KMIN) -gt $(2) -o \
- $(KMAJ) -eq $(1) -a $(KMIN) -eq $(2) -a $(KREV) -ge $(3) ] && \
- echo 1 || echo 0)
kver_lk = $(shell [ `echo $(KVER) | egrep $(1)` ] && echo 1 || echo 0)

#
@@ -66,85 +58,93 @@ kver_lk = $(shell [ `echo $(KVER) | egrep $(1)` ] && echo 1 || echo 0)
# base first the earlier patch sets will not need to be modified.
#

-ifeq ($(call kver_le,3,5,0),1)
+ifeq ($(call kver_lt,3,6,0),1)
PATCHES := $(PATCHES) compat-3.5.patch
endif

-ifeq ($(call kver_le,3,4,0),1)
+ifeq ($(call kver_lt,3,5,0),1)
PATCHES := $(PATCHES) compat-3.2-3.4.patch
endif

-ifeq ($(call kver_le,3,2,0),1)
+ifeq ($(call kver_lt,3,3,0),1)
PATCHES := $(PATCHES) compat-2.6.39-3.2.patch
endif

-ifeq ($(call kver_le,2,6,38),1)
+ifeq ($(call kver_lt,2,6,39),1)
PATCHES := $(PATCHES) compat-2.6.38.patch
endif

-ifeq ($(call kver_le,2,6,37),1)
+ifeq ($(call kver_lt,2,6,38),1)
PATCHES := $(PATCHES) compat-2.6.36-2.6.37.patch
endif

# Compatibility patch for kernels > 2.6.32 <= 2.6.35
-ifeq ($(call kver_le,2,6,35),1)
+ifeq ($(call kver_lt,2,6,36),1)
+ifeq ($(call kver_gt,2,6,32),1)
PATCHES := $(PATCHES) compat-2.6.33-2.6.35.patch
endif
+endif

# Compatibility patch for kernels <= 2.6.32
-ifeq ($(call kver_le,2,6,32),1)
+ifeq ($(call kver_lt,2,6,33),1)
PATCHES := $(PATCHES) compat-2.6.32.patch
endif

# Compatibility patch for kernels <= 2.6.31
-ifeq ($(call kver_le,2,6,31),1)
+ifeq ($(call kver_lt,2,6,32),1)
PATCHES := $(PATCHES) compat-2.6.31.patch
endif

# Compatibility patch for kernels <= 2.6.30
-ifeq ($(call kver_le,2,6,30),1)
+ifeq ($(call kver_lt,2,6,31),1)
PATCHES := $(PATCHES) compat-2.6.30.patch
endif

# Compatibility patch for kernels <= 2.6.29
-ifeq ($(call kver_le,2,6,29),1)
+ifeq ($(call kver_lt,2,6,30),1)
PATCHES := $(PATCHES) compat-2.6.29.patch
endif

# Compatibility patch for kernels <= 2.6.28
-ifeq ($(call kver_le,2,6,28),1)
+ifeq ($(call kver_lt,2,6,29),1)
PATCHES := $(PATCHES) compat-2.6.28.patch
endif

# Compatibility patch for kernels >= 2.6.25 and <= 2.6.27
-ifeq ($(call kver_le,2,6,27),1)
+ifeq ($(call kver_lt,2,6,28),1)
+ifeq ($(call kver_gt,2,6,24),1)
PATCHES := $(PATCHES) compat-2.6.25-2.6.27.patch
endif
+endif

# Compatibility patch for kernels <= 2.6.24
-ifeq ($(call kver_le,2,6,24),1)
+ifeq ($(call kver_lt,2,6,25),1)
PATCHES := $(PATCHES) compat-2.6.24.patch
endif

# Compatibility patch for kernels <= 2.6.23
-ifeq ($(call kver_le,2,6,23),1)
+ifeq ($(call kver_lt,2,6,24),1)
PATCHES := $(PATCHES) compat-2.6.23.patch
endif

# Compatibility patch for kernels <= 2.6.22
-ifeq ($(call kver_le,2,6,22),1)
+ifeq ($(call kver_lt,2,6,23),1)
PATCHES := $(PATCHES) compat-2.6.22.patch
endif

# Compatibility patch for kernels >= 2.6.19 and <= 2.6.21
-ifeq ($(call kver_le,2,6,21),1)
+ifeq ($(call kver_lt,2,6,22),1)
+ifeq ($(call kver_gt,2,6,18),1)
PATCHES := $(PATCHES) compat-2.6.19-2.6.21.patch
endif
+endif

# Compatibility patch for kernels >= 2.6.14 and <= 2.6.18
-ifeq ($(call kver_le,2,6,18),1)
+ifeq ($(call kver_lt,2,6,19),1)
+ifeq ($(call kver_gt,2,6,13),1)
PATCHES := $(PATCHES) compat-2.6.14-2.6.18.patch
endif
+endif

# We don't support kernels < 2.6.14 except for explicit distros
ifeq ($(call kver_lt,2,6,14),1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/kernel/iscsi.c b/kernel/iscsi.c
index 9ad3047..37d7753 100644
--- a/kernel/iscsi.c
+++ b/kernel/iscsi.c
@@ -773,6 +773,7 @@ static void set_offset_and_length(const struct iet_volume *lu,
break;
case READ_16:
case WRITE_16:
+#ifdef WRITE_SAME_16
case WRITE_SAME_16:
*off = (u64)cmd[2] << 56 | (u64)cmd[3] << 48 |
(u64)cmd[4] << 40 | (u64)cmd[5] << 32 |
@@ -781,6 +782,7 @@ static void set_offset_and_length(const struct iet_volume *lu,
*len = (u32)cmd[10] << 24 | (u32)cmd[11] << 16 |
(u32)cmd[12] << 8 | (u32)cmd[13];
break;
+#endif
case PERSISTENT_RESERVE_OUT:
{
const struct persistent_reserve_out *pr_out =
@@ -1036,6 +1038,7 @@ static void scsi_cmnd_start(struct iscsi_conn *conn, struct iscsi_cmnd *req)
case WRITE_10:
case WRITE_16:
case WRITE_VERIFY:
+#ifdef WRITE_SAME_16
case WRITE_SAME_16:
{
struct iscsi_sess_param *param = &conn->session->param;
@@ -1104,6 +1107,7 @@ static void scsi_cmnd_start(struct iscsi_conn *conn, struct iscsi_cmnd *req)
}
break;
}
+#endif
error:
default:
eprintk("Unsupported %x\n", req_hdr->scb[0]);
diff --git a/kernel/iscsi_dbg.h b/kernel/iscsi_dbg.h
index 8c9b928..ad5c6d4 100644
--- a/kernel/iscsi_dbg.h
+++ b/kernel/iscsi_dbg.h
@@ -12,7 +12,9 @@
#define D_IOMODE (1UL << 8)
#define D_UAC (1UL << 9)
#define D_PR (1UL << 10)
+#ifdef WRITE_SAME_16
#define D_VAAI (1UL << 11)
+#endif

#define D_DATA (D_READ | D_WRITE)

diff --git a/kernel/target_disk.c b/kernel/target_disk.c
index 6b1de2c..ca28e4e 100644
--- a/kernel/target_disk.c
+++ b/kernel/target_disk.c
@@ -408,6 +408,7 @@ static void build_write_response(struct iscsi_cmnd *cmnd)
iscsi_cmnd_set_sense(cmnd, MEDIUM_ERROR, 0x03, 0x0);
}

+#ifdef WRITE_SAME_16
static void build_write_same_response(struct iscsi_cmnd *cmnd) {
int err;
struct tio *target_tio;
@@ -475,6 +476,7 @@ static void build_write_same_response(struct iscsi_cmnd *cmnd) {

tio_put(target_tio);
}
+#endif

static void build_sync_cache_response(struct iscsi_cmnd *cmnd)
{
@@ -618,9 +620,11 @@ static int disk_execute_cmnd(struct iscsi_cmnd *cmnd)
case WRITE_VERIFY:
send_scsi_rsp(cmnd, build_write_response);
break;
+#ifdef WRITE_SAME_16
case WRITE_SAME_16:
send_scsi_rsp(cmnd, build_write_same_response);
break;
+#endif
case SYNCHRONIZE_CACHE:
send_scsi_rsp(cmnd, build_sync_cache_response);
break;
diff --git a/kernel/volume.c b/kernel/volume.c
index 8beeb1e..6ad2a3d 100644
--- a/kernel/volume.c
+++ b/kernel/volume.c
@@ -446,7 +446,9 @@ int is_volume_reserved(struct iet_volume *volume, u64 sid, u8 *scb)
case WRITE_10:
case WRITE_12:
case WRITE_16:
+#ifdef WRITE_SAME_16
case WRITE_SAME_16:
+#endif
case WRITE_VERIFY:
case SYNCHRONIZE_CACHE:
if (write_excl || excl_access)
Loading

0 comments on commit 916fd5e

Please sign in to comment.