File iscsitarget-svn-138.diff of Package iscsitarget

Index: kernel/block-io.c
===================================================================
--- kernel/block-io.c	(revision 116)
+++ kernel/block-io.c	(revision 138)
@@ -169,8 +169,8 @@
 
 	bdev = open_bdev_excl(path, flags, THIS_MODULE);
 	if (IS_ERR(bdev)) {
-		err = PTR_ERR (bdev);
-		eprintk("Can't open device %s \n", path);
+		err = PTR_ERR(bdev);
+		eprintk("Can't open device %s, error %d\n", path, err);
 		bio_data->bdev = NULL;
 	} else {
 		bio_data->bdev = bdev;
@@ -217,7 +217,7 @@
 	p = (u32 *) (volume->scsi_id + VENDOR_ID_LEN);
 	*(p + 0) = volume->target->trgt_param.target_type;
 	*(p + 1) = volume->target->tid;
-	*(p + 2) = (unsigned int) inode->i_ino;
+	*(p + 2) = volume->lun;
 	*(p + 3) = (unsigned int) inode->i_sb->s_dev;
 }
 
Index: kernel/iotype.c
===================================================================
--- kernel/iotype.c	(revision 116)
+++ kernel/iotype.c	(revision 138)
@@ -89,9 +89,11 @@
 
 	for (i = 0; i < ARRAY_SIZE(iotype_array); i++) {
 		if (!(err = register_iotype(iotype_array[i])))
-			eprintk("register %s\n", iotype_array[i]->name);
+			iprintk("Registered io type %s\n",
+						iotype_array[i]->name);
 		else {
-			eprintk("failed to register %s\n", iotype_array[i]->name);
+			eprintk("Failed to register io type %s\n",
+						iotype_array[i]->name);
 			break;
 		}
 	}
Index: kernel/iscsi.c
===================================================================
--- kernel/iscsi.c	(revision 116)
+++ kernel/iscsi.c	(revision 138)
@@ -1191,10 +1191,56 @@
 	}
 }
 
+static inline char *tmf_desc(int fun)
+{
+	static char *tmf_desc[] = {
+		"Unknown Function",
+		"Abort Task",
+		"Abort Task Set",
+		"Clear ACA",
+		"Clear Task Set",
+		"Logical Unit Reset",
+		"Target Warm Reset",
+		"Target Cold Reset",
+		"Task Reassign",
+        };
+
+	if ((fun < ISCSI_FUNCTION_ABORT_TASK) || 
+				(fun > ISCSI_FUNCTION_TASK_REASSIGN))
+		fun = 0;
+
+	return tmf_desc[fun];
+}
+
+static inline char *rsp_desc(int rsp)
+{
+	static char *rsp_desc[] = {
+		"Function Complete",
+		"Unknown Task",
+		"Unknown LUN",
+		"Task Allegiant",
+		"Failover Unsupported",
+		"Function Unsupported",
+		"No Authorization",
+		"Function Rejected",
+		"Unknown Response",
+	};
+
+	if (((rsp < ISCSI_RESPONSE_FUNCTION_COMPLETE) ||
+			(rsp > ISCSI_RESPONSE_NO_AUTHORIZATION)) &&
+			(rsp != ISCSI_RESPONSE_FUNCTION_REJECTED))
+		rsp = 8;
+	else if (rsp == ISCSI_RESPONSE_FUNCTION_REJECTED)
+		rsp = 7;
+
+	return rsp_desc[rsp];
+}
+
 static void execute_task_management(struct iscsi_cmnd *req)
 {
 	struct iscsi_conn *conn = req->conn;
-	struct iscsi_target *target = conn->session->target;
+	struct iscsi_session *session = conn->session;
+	struct iscsi_target *target = session->target;
 	struct iscsi_cmnd *rsp;
 	struct iscsi_task_mgt_hdr *req_hdr = (struct iscsi_task_mgt_hdr *)&req->pdu.bhs;
 	struct iscsi_task_rsp_hdr *rsp_hdr;
@@ -1209,8 +1255,6 @@
 	rsp_hdr->itt = req_hdr->itt;
 	rsp_hdr->response = ISCSI_RESPONSE_FUNCTION_COMPLETE;
 
-	eprintk("%x %d %x\n", cmnd_itt(req), function, req_hdr->rtt);
-
 	switch (function) {
 	case ISCSI_FUNCTION_ABORT_TASK:
 	case ISCSI_FUNCTION_ABORT_TASK_SET:
@@ -1255,6 +1299,11 @@
 		break;
 	}
 out:
+	iprintk("%s (%02x) issued on tid:%d lun:%d by sid:%llu (%s)\n",
+				tmf_desc(function), function, target->tid,
+				translate_lun(req_hdr->lun), session->sid,
+				rsp_desc(rsp_hdr->response));
+
 	iscsi_cmnd_init_write(rsp);
 }
 
@@ -1708,8 +1757,7 @@
 	if ((err = event_init()) < 0)
 		goto err;
 
-	iscsi_cmnd_cache = kmem_cache_create("iscsi_cmnd", sizeof(struct iscsi_cmnd),
-					     0, 0, NULL, NULL);
+	iscsi_cmnd_cache = KMEM_CACHE(iscsi_cmnd, 0);
 	if (!iscsi_cmnd_cache)
 		goto err;
 
Index: kernel/null-io.c
===================================================================
--- kernel/null-io.c	(revision 116)
+++ kernel/null-io.c	(revision 138)
@@ -16,7 +16,7 @@
 #include "iotype.h"
 
 struct nullio_data {
-	u32 sectors;
+	u64 sectors;
 };
 
 enum {
@@ -32,7 +32,7 @@
 static int parse_nullio_params(struct iet_volume *volume, char *params)
 {
 	int err = 0;
-	char *p;
+	char *p, *q;
 	struct nullio_data *data = volume->private;
 
 	while ((p = strsep(&params, ",")) != NULL) {
@@ -43,7 +43,11 @@
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_sectors:
-			match_int(&args[0], &data->sectors);
+			q = match_strdup(&args[0]);
+			if (!q)
+				return -ENOMEM;
+			data->sectors = simple_strtoull(q, NULL, 10);
+			kfree(q);
 			break;
 		case Opt_ignore:
 			break;
@@ -97,7 +101,7 @@
 void nullio_show(struct iet_volume *lu, struct seq_file *seq)
 {
 	struct nullio_data *p = lu->private;
-	seq_printf(seq, " sectors:%u\n", p->sectors);
+	seq_printf(seq, " sectors:%llu\n", p->sectors);
 }
 
 struct iotype nullio =
Index: kernel/iscsi.h
===================================================================
--- kernel/iscsi.h	(revision 116)
+++ kernel/iscsi.h	(revision 138)
@@ -116,9 +116,6 @@
 	struct worker_thread_info wthread_info;
 
 	struct semaphore target_sem;
-
-	struct list_head initiator_list;
-	u32 initiator_iid_count;
 };
 
 struct iscsi_queue {
@@ -189,8 +186,6 @@
 	struct list_head cmnd_hash[1 << IET_HASH_ORDER];
 
 	u32 next_ttt;
-
-	struct iscsi_initiator *rinitiator;
 };
 
 enum connection_state_bit {
Index: kernel/digest.c
===================================================================
--- kernel/digest.c	(revision 116)
+++ kernel/digest.c	(revision 138)
@@ -218,7 +218,7 @@
 	count = get_pgcnt(size, offset);
 	assert(idx + count <= tio->pg_cnt);
 
-	assert(count < ISCSI_CONN_IOV_MAX);
+	assert(count <= ISCSI_CONN_IOV_MAX);
 
 	crypto_hash_init(hash);
 
Index: kernel/event.c
===================================================================
--- kernel/event.c	(revision 116)
+++ kernel/event.c	(revision 138)
@@ -95,7 +95,8 @@
 
 int event_init(void)
 {
-	nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);
+	nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, NULL,
+				   THIS_MODULE);
 	if (!nl)
 		return -ENOMEM;
 	else
Index: kernel/nthread.c
===================================================================
--- kernel/nthread.c	(revision 116)
+++ kernel/nthread.c	(revision 138)
@@ -13,8 +13,6 @@
 #include "iscsi_dbg.h"
 #include "digest.h"
 
-DECLARE_WAIT_QUEUE_HEAD(iscsi_ctl_wait);
-
 enum daemon_state_bit {
 	D_ACTIVE,
 	D_DATA_READY,
Index: kernel/target.c
===================================================================
--- kernel/target.c	(revision 116)
+++ kernel/target.c	(revision 138)
@@ -148,7 +148,6 @@
 
 	INIT_LIST_HEAD(&target->session_list);
 	INIT_LIST_HEAD(&target->volumes);
-	INIT_LIST_HEAD(&target->initiator_list);
 
 	atomic_set(&target->nr_volumes, 0);
 
Index: kernel/iscsi_dbg.h
===================================================================
--- kernel/iscsi_dbg.h	(revision 116)
+++ kernel/iscsi_dbg.h	(revision 138)
@@ -15,21 +15,25 @@
 
 extern unsigned long debug_enable_flags;
 
-#define dprintk(debug, fmt, args...)					\
-do {									\
-	if ((debug) & debug_enable_flags) {				\
-		printk("%s(%d) " fmt, __FUNCTION__, __LINE__, args);	\
-	}								\
+#define PFX "iscsi_trgt: "
+
+#define dprintk(debug, fmt, args...) do {			\
+	if ((debug) & debug_enable_flags) {			\
+		printk(KERN_DEBUG PFX "%s(%d) " fmt, __FUNCTION__,\
+						__LINE__, args);\
+	}							\
 } while (0)
 
-#define eprintk(fmt, args...)					\
-do {								\
-	printk("%s(%d) " fmt, __FUNCTION__, __LINE__, args);	\
+#define eprintk(fmt, args...) do {				\
+	printk(KERN_ERR PFX "%s(%d) " fmt, __FUNCTION__,	\
+						__LINE__, args);\
 } while (0)
 
+#define iprintk(X...) printk(KERN_INFO PFX X)
+
 #define assert(p) do {						\
 	if (!(p)) {						\
-		printk(KERN_CRIT "BUG at %s:%d assert(%s)\n",	\
+		printk(KERN_CRIT PFX "BUG at %s:%d assert(%s)\n",\
 		       __FILE__, __LINE__, #p);			\
 		dump_stack();					\
 		BUG();						\
@@ -40,9 +44,10 @@
 static inline void iscsi_dump_iov(struct msghdr *msg)
 {
 	int i;
-	printk("%p, %d\n", msg->msg_iov, msg->msg_iovlen);
+	printk(PFX "%p, %d\n", msg->msg_iov, msg->msg_iovlen);
 	for (i = 0; i < min_t(size_t, msg->msg_iovlen, ISCSI_CONN_IOV_MAX); i++)
-		printk("%d: %p,%d\n", i, msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
+		printk(PFX "%d: %p,%d\n", i, msg->msg_iov[i].iov_base,
+						msg->msg_iov[i].iov_len);
 }
 #else
 #define iscsi_dump_iov(x) do {} while (0)
@@ -84,18 +89,18 @@
 	int i;
 
 	buf = (void *)&pdu->bhs;
-	printk("BHS: (%p,%d)\n", buf, sizeof(pdu->bhs));
+	printk(PFX "BHS: (%p,%d)\n", buf, sizeof(pdu->bhs));
 	for (i = 0; i < sizeof(pdu->bhs); i++)
 		iscsi_dump_char(*buf++);
 	iscsi_dump_char(-1);
 
 	buf = (void *)pdu->ahs;
-	printk("AHS: (%p,%d)\n", buf, pdu->ahssize);
+	printk(PFX "AHS: (%p,%d)\n", buf, pdu->ahssize);
 	for (i = 0; i < pdu->ahssize; i++)
 		iscsi_dump_char(*buf++);
 	iscsi_dump_char(-1);
 
-	printk("Data: (%d)\n", pdu->datasize);
+	printk(PFX "Data: (%d)\n", pdu->datasize);
 }
 
 #else
Index: kernel/tio.c
===================================================================
--- kernel/tio.c	(revision 116)
+++ kernel/tio.c	(revision 138)
@@ -110,8 +110,7 @@
 
 int tio_init(void)
 {
-	tio_cache = kmem_cache_create("tio", sizeof(struct tio),
-				      0, 0, NULL, NULL);
+	tio_cache = KMEM_CACHE(tio, 0);
 	return  tio_cache ? 0 : -ENOMEM;
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 116)
+++ ChangeLog	(revision 138)
@@ -1,3 +1,14 @@
+Summary of changes from v0.4.14 to v0.4.15
+=================================
+
+Juhani Rautiainen
+ o Add RELEASE/RESERVE support
+
+Ross S. W. Walker
+ o Improve the build system to support several kernel versions
+ o Add block-io support
+
+
 Summary of changes from v0.4.13 to v0.4.14
 =================================
 
Index: patches/compat-2.6.19-2.6.21.patch
===================================================================
--- patches/compat-2.6.19-2.6.21.patch	(revision 0)
+++ patches/compat-2.6.19-2.6.21.patch	(revision 138)
@@ -0,0 +1,41 @@
+Index: kernel/event.c
+===================================================================
+--- kernel/event.c	(working copy)
++++ kernel/event.c	(revision 122)
+@@ -95,8 +95,7 @@ int event_send(u32 tid, u64 sid, u32 cid
+ 
+ int event_init(void)
+ {
+-	nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, NULL,
+-				   THIS_MODULE);
++	nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);
+ 	if (!nl)
+ 		return -ENOMEM;
+ 	else
+Index: kernel/iscsi.c
+===================================================================
+--- kernel/iscsi.c	(working copy)
++++ kernel/iscsi.c	(revision 137)
+@@ -1757,7 +1757,8 @@ static int iscsi_init(void)
+ 	if ((err = event_init()) < 0)
+ 		goto err;
+ 
+-	iscsi_cmnd_cache = KMEM_CACHE(iscsi_cmnd, 0);
++	iscsi_cmnd_cache = kmem_cache_create("iscsi_cmnd", sizeof(struct iscsi_cmnd),
++					     0, 0, NULL, NULL);
+ 	if (!iscsi_cmnd_cache)
+ 		goto err;
+ 
+Index: kernel/tio.c
+===================================================================
+--- kernel/tio.c	(working copy)
++++ kernel/tio.c	(revision 137)
+@@ -110,7 +110,8 @@ int tio_sync(struct iet_volume *lu, stru
+ 
+ int tio_init(void)
+ {
+-	tio_cache = KMEM_CACHE(tio, 0);
++	tio_cache = kmem_cache_create("tio", sizeof(struct tio),
++				      0, 0, NULL, NULL);
+ 	return  tio_cache ? 0 : -ENOMEM;
+ }
Index: patches/compat-2.6.14-2.6.18.patch
===================================================================
--- patches/compat-2.6.14-2.6.18.patch	(revision 116)
+++ patches/compat-2.6.14-2.6.18.patch	(revision 138)
@@ -2,7 +2,7 @@
 ===================================================================
 --- kernel/iscsi.h	(revision 105)
 +++ kernel/iscsi.h	(working copy)
-@@ -238,8 +238,8 @@ struct iscsi_conn {
+@@ -233,8 +233,8 @@ struct iscsi_conn {
  	u32 write_offset;
  	int write_state;
  
@@ -134,7 +134,7 @@
  	idx = offset >> PAGE_CACHE_SHIFT;
 @@ -220,7 +211,7 @@ static void digest_data(struct hash_desc
  
- 	assert(count < ISCSI_CONN_IOV_MAX);
+ 	assert(count <= ISCSI_CONN_IOV_MAX);
  
 -	crypto_hash_init(hash);
 +	crypto_digest_init(tfm);
Index: usr/isns.c
===================================================================
--- usr/isns.c	(revision 116)
+++ usr/isns.c	(revision 138)
@@ -256,7 +256,8 @@
 
 	scn_flags = ISNS_SCN_FLAG_INITIATOR | ISNS_SCN_FLAG_OBJECT_REMOVE |
 		ISNS_SCN_FLAG_OBJECT_ADDED | ISNS_SCN_FLAG_OBJECT_UPDATED;
-	scn_flags = htonl(set_scn_flag(scn_flags));
+	set_scn_flag(scn_flags);
+	scn_flags = htonl(scn_flags);
 
 	length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_SCN_BITMAP,
 			       sizeof(scn_flags), &scn_flags);
Index: usr/iscsid.c
===================================================================
--- usr/iscsid.c	(revision 116)
+++ usr/iscsid.c	(revision 138)
@@ -89,8 +89,13 @@
 	char *buffer;
 
 	if (!conn->rsp.datasize) {
-		if (!conn->rsp_buffer)
+		if (!conn->rsp_buffer) {
 			conn->rsp_buffer = malloc(INCOMING_BUFSIZE);
+			if (!conn->rsp_buffer) {
+				log_error("Failed to alloc send buffer");
+				return;
+			}
+		}
 		conn->rsp.data = conn->rsp_buffer;
 	}
 	if (conn->rwsize + len > INCOMING_BUFSIZE) {
@@ -385,7 +390,12 @@
 /* 			return; */
 /* 		} */
 
-		ki->param_get(conn->tid, 0, key_session, conn->session_param);
+		if (ki->param_get(conn->tid, 0, key_session,
+				  conn->session_param)) {
+			rsp->status_class = ISCSI_STATUS_TARGET_ERROR;
+			rsp->status_detail = ISCSI_STATUS_SVC_UNAVAILABLE;
+			conn->state = STATE_EXIT;
+		}
 	}
 	conn->exp_cmd_sn = be32_to_cpu(req->cmd_sn);
 	log_debug(1, "exp_cmd_sn: %d,%d", conn->exp_cmd_sn, req->cmd_sn);
Index: usr/ietd.c
===================================================================
--- usr/ietd.c	(revision 116)
+++ usr/ietd.c	(revision 138)
@@ -307,9 +307,24 @@
 							      (conn->req.bhs.datalength[1] << 8) +
 							      conn->req.bhs.datalength[2]);
 					conn->rwsize = (conn->req.ahssize + conn->req.datasize + 3) & -4;
+					if (conn->rwsize > INCOMING_BUFSIZE) {
+						log_warning("Recv PDU with "
+							    "invalid size %d "
+							    "(max: %d)",
+							    conn->rwsize,
+							    INCOMING_BUFSIZE);
+						conn->state = STATE_CLOSE;
+						goto conn_close;
+					}
 					if (conn->rwsize) {
-						if (!conn->req_buffer)
+						if (!conn->req_buffer) {
 							conn->req_buffer = malloc(INCOMING_BUFSIZE);
+							if (!conn->req_buffer) {
+								log_error("Failed to alloc recv buffer");
+								conn->state = STATE_CLOSE;
+								goto conn_close;
+							}
+						}
 						conn->buffer = conn->req_buffer;
 						conn->req.ahs = conn->buffer;
 						conn->req.data = conn->buffer + conn->req.ahssize;
@@ -396,6 +411,7 @@
 				exit(1);
 			}
 
+		conn_close:
 			if (conn->state == STATE_CLOSE) {
 				log_debug(0, "connection closed");
 				conn_free_pdu(conn);
Index: etc/initd/initd.gentoo
===================================================================
--- etc/initd/initd.gentoo	(revision 116)
+++ etc/initd/initd.gentoo	(revision 138)
@@ -4,47 +4,14 @@
 #
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
-MEM_SIZE=1048576
 
 depend()
 {
         use net
 }
 
-configure_memsize()
-{
-    if [ -e /proc/sys/net/core/wmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/wmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
-    fi
-
-    if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
-    fi
-}
-
 start_server()
 {
-        configure_memsize
         modprobe -q crc32c
         modprobe iscsi_trgt
         /usr/sbin/ietd
Index: etc/initd/initd
===================================================================
--- etc/initd/initd	(revision 116)
+++ etc/initd/initd	(revision 138)
@@ -4,47 +4,14 @@
 #
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
-MEM_SIZE=1048576
 
-configure_memsize()
-{
-    if [ -e /proc/sys/net/core/wmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/wmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
-    fi
-
-    if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
-    fi
-}
-
 start_server()
 {
-	configure_memsize
 	modprobe -q crc32c
 	modprobe iscsi_trgt
 	/usr/sbin/ietd
 }
-	
+
 stop_server()
 {
 	ietadm --op delete
Index: etc/initd/initd.debian
===================================================================
--- etc/initd/initd.debian	(revision 116)
+++ etc/initd/initd.debian	(revision 138)
@@ -10,65 +10,29 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
-# Don't touch this "memsize thingy" unless you are blessed
-# with knowledge about it.
-MEM_SIZE=1048576
-
-configure_memsize()
-{
-    if [ -e /proc/sys/net/core/wmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/wmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
-    fi
-
-    if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
-    fi
-}
-
 RETVAL=0
 
 ietd_start()
 {
 	echo -n "Starting iSCSI enterprise target service: "
-	configure_memsize
 	modprobe -q crc32c
 	modprobe iscsi_trgt
 	start-stop-daemon --start --exec $DAEMON --quiet
 	RETVAL=$?
-	if [ $RETVAL == "0" ]; then
+	if [ $RETVAL -eq 0 ]; then
 	    echo "succeeded."
 	else
 	    echo "failed."
-	fi	    
+	fi
 }
-	
+
 ietd_stop()
 {
 	echo -n "Removing iSCSI enterprise target devices: "
-	# ugly, but ietadm does not allways provides correct exit values
+	# ugly, but ietadm does not always provide correct exit values
 	RETURN=`ietadm --op delete 2>&1`
 	RETVAL=$?
-	if [ $RETVAL == "0" ] && [[ $RETURN != "something wrong" ]]; then
+	if [ $RETVAL -eq 0 ] && [ x$RETURN != x"something wrong" ]; then
 	    echo "succeeded."
 	else
 	    echo "failed with reason :$RETURN"
@@ -78,19 +42,19 @@
 	echo -n "Stopping iSCSI enterprise target service: "
 	start-stop-daemon --stop --quiet --exec $DAEMON --pidfile $PID_FILE
 	RETVAL=$?
-	if [ $RETVAL == "0" ]; then
+	if [ $RETVAL -eq 0 ]; then
 	    echo "succeeded."
 	else
 	    echo "failed."
 	fi
-	# ugly, but pid file is not removed ba ietd
+	# ugly, but pid file is not removed by ietd
 	rm -f $PID_FILE
 
 	echo -n "Removing iSCSI enterprise target modules: "
 	modprobe -r iscsi_trgt
 	RETVAL=$?
 	modprobe -r crc32c 2>/dev/null
-	if [ $RETVAL == "0" ]; then
+	if [ $RETVAL -eq 0 ]; then
 	    echo "succeeded."
 	else
 	    echo "failed."
@@ -117,18 +81,18 @@
 	else
 		echo "no iSCSI enterprise target found!"
 		exit 1
-	fi	
+	fi
         ;;
   dump)
 	DUMP=`tempfile -p ietd`
 	RETVAL=$?
-	if [ $RETVAL != "0" ]; then
+	if [ $RETVAL -ne 0 ]; then
 	    echo "Failed to create dump file $DUMP"
 	    exit 1
 	fi
         ietadm --mode dump --all >$DUMP
 	RETVAL=$?
-	if [ $RETVAL != "0" ]; then
+	if [ $RETVAL -ne 0 ]; then
 	    echo "Error dumping config from daemon"
 	    rm $DUMP
 	    exit 1
Index: etc/initd/initd.redhat
===================================================================
--- etc/initd/initd.redhat	(revision 116)
+++ etc/initd/initd.redhat	(revision 138)
@@ -16,45 +16,12 @@
 fi
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
-MEM_SIZE=1048576
 
-configure_memsize()
-{
-    if [ -e /proc/sys/net/core/wmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_max ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_max
-    fi
-
-    if [ -e /proc/sys/net/core/wmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/wmem_default
-    fi
-
-    if [ -e /proc/sys/net/core/rmem_default ]; then
-        echo ${MEM_SIZE} > /proc/sys/net/core/rmem_default
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_mem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_mem
-    fi
-
-    if [ -e  /proc/sys/net/ipv4/tcp_rmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_rmem
-    fi
-
-    if [ -e /proc/sys/net/ipv4/tcp_wmem ]; then
-        echo "${MEM_SIZE} ${MEM_SIZE} ${MEM_SIZE}" > /proc/sys/net/ipv4/tcp_wmem
-    fi
-}
-
 RETVAL=0
 
 start()
 {
 	echo -n "Starting iSCSI target service: "
-	configure_memsize
 	modprobe -q crc32c
 	modprobe iscsi_trgt
 	daemon /usr/sbin/ietd
@@ -62,7 +29,7 @@
 	echo
 	return $RETVAL
 }
-	
+
 stop()
 {
 	echo -n "Stopping iSCSI target service: "
@@ -71,7 +38,7 @@
 	modprobe -r iscsi_trgt 2>/dev/null
 	RETVAL=$?
 	modprobe -r crc32c 2>/dev/null
-	if [ $RETVAL == "0" ]; then
+	if [ $RETVAL -eq 0 ]; then
 		echo_success
 	else
 		echo_failure
@@ -102,7 +69,7 @@
 		exit 1
 	else
 		echo "ietd (pid $PID) is running..."
-	fi	
+	fi
 }
 
 case "$1" in
Index: Makefile
===================================================================
--- Makefile	(revision 116)
+++ Makefile	(revision 138)
@@ -51,6 +51,11 @@
 # base first the earlier patch sets will not need to be modified.
 #
 
+# Compatibility patch for kernels >= 2.6.19 and <= 2.6.21
+ifeq ($(call kver_le,2,6,21),1)
+	PATCHES := $(PATCHES) compat-2.6.19-2.6.21.patch
+endif
+
 # Compatibility patch for kernels >= 2.6.14 and <= 2.6.18
 ifeq ($(call kver_le,2,6,18),1)
 	PATCHES := $(PATCHES) compat-2.6.14-2.6.18.patch
@@ -140,27 +145,34 @@
 		rm -f .patched.*; \
 	fi
 
-install: install-kernel install-usr install-etc install-doc
+depmod:
+	@echo "Running depmod"
+	@if [ x$(DISTDIR) != x -o x$(INSTALL_MOD_PATH) != x ]; then \
+		depmod -aq -b $(DISTDIR)$(INSTALL_MOD_PATH) $(KVER); \
+	else \
+		depmod -aq $(KVER); \
+	fi
 
+install: install-usr install-etc install-doc install-kernel depmod
+
 install-kernel: kernel/iscsi_trgt.ko
 	@install -vD kernel/iscsi_trgt.ko \
 		$(DISTDIR)$(INSTALL_MOD_PATH)$(KMOD)/iscsi/iscsi_trgt.ko
-	-depmod -aq
 
 install-usr: usr/ietd usr/ietadm
 	@install -vD usr/ietd $(DISTDIR)/usr/sbin/ietd
 	@install -vD usr/ietadm $(DISTDIR)/usr/sbin/ietadm
 
 install-etc: install-initd
-	@if [ ! -e /etc/ietd.conf ]; then \
+	@if [ ! -e $(DISTDIR)/etc/ietd.conf ]; then \
 		install -vD -m 644 etc/ietd.conf \
 			$(DISTDIR)/etc/ietd.conf; \
 	fi
-	@if [ ! -e /etc/initiators.allow ]; then \
+	@if [ ! -e $(DISTDIR)/etc/initiators.allow ]; then \
 		install -vD -m 644 etc/initiators.allow \
 			$(DISTDIR)/etc/initiators.allow; \
 	fi
-	@if [ ! -e /etc/initiators.deny ]; then \
+	@if [ ! -e $(DISTDIR)/etc/initiators.deny ]; then \
 		install -vD -m 644 etc/initiators.deny \
 			$(DISTDIR)/etc/initiators.deny; \
 	fi
@@ -204,11 +216,10 @@
 			$(DISTDIR)$(MANDIR)/man$$s/$$f ; \
 	done
 
-uninstall: uninstall-kernel uninstall-usr uninstall-etc uninstall-doc
+uninstall: uninstall-kernel depmod uninstall-usr uninstall-etc uninstall-doc
 
 uninstall-kernel:
 	rm -f $(DISTDIR)$(INSTALL_MOD_PATH)$(KMOD)/iscsi/iscsi_trgt.ko
-	-depmod -aq
 
 uninstall-usr:
 	@rm -f $(DISTDIR)/usr/sbin/ietd