>From 65aac58debea6370e0b68bf76e72e99695afe879 Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader@canonical.com>
Date: Tue, 18 Nov 2008 10:03:56 +0100
Subject: [PATCH] UBUNTU: iscsitarget: Update to official 0.4.16 driver

Bug: #278625

The iscsitarget code imported to Intrepid is missing some important fixes
from the upstream project. One of the bugs prevents the creation of required
sysfs entries, which makes it impossible to stop the target.
This patch updates the iscsitarget to the current official version 0.4.16.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 ubuntu/iscsitarget/BOM        |    6 ++++--
 ubuntu/iscsitarget/block-io.c |    8 +-------
 ubuntu/iscsitarget/config.c   |    2 +-
 ubuntu/iscsitarget/digest.c   |    3 +++
 ubuntu/iscsitarget/event.c    |   18 +-----------------
 ubuntu/iscsitarget/iet_u.h    |    2 +-
 6 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/ubuntu/iscsitarget/BOM b/ubuntu/iscsitarget/BOM
index 2bfa6ab..9df3b05 100644
--- a/ubuntu/iscsitarget/BOM
+++ b/ubuntu/iscsitarget/BOM
@@ -1,2 +1,4 @@
-Downloaded from:	http://www.amherst.edu/~swplotner/iscsitarget/download/iscsitarget/
-Current Version:	0.4.15.145
+Main web page:	http://iscsitarget.sourceforge.net/
+Mailing list:	http://dir.gmane.org/gmane.linux.iscsi.iscsi-target.devel
+Download:	http://sourceforge.net/project/showfiles.php?group_id=108475
+Cur. version:	0.4.16
diff --git a/ubuntu/iscsitarget/block-io.c b/ubuntu/iscsitarget/block-io.c
index e5923c9..492cc20 100644
--- a/ubuntu/iscsitarget/block-io.c
+++ b/ubuntu/iscsitarget/block-io.c
@@ -9,7 +9,6 @@
  * This code is licenced under the GPL.
  */
 
-#include <linux/types.h>
 #include <linux/parser.h>
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
@@ -29,15 +28,10 @@ struct tio_work {
 	struct completion tio_complete;
 };
 
-static void
-blockio_bio_endio(struct bio *bio, int error)
+static void blockio_bio_endio(struct bio *bio, int error)
 {
 	struct tio_work *tio_work = bio->bi_private;
 
-	/* Ignore partials */
-	if (bio->bi_size)
-		return;
-
 	error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;
 
 	if (error)
diff --git a/ubuntu/iscsitarget/config.c b/ubuntu/iscsitarget/config.c
index 17664c4..d6c4b5e 100644
--- a/ubuntu/iscsitarget/config.c
+++ b/ubuntu/iscsitarget/config.c
@@ -40,7 +40,7 @@ int iet_procfs_init(void)
 	int i;
 	struct proc_dir_entry *ent;
 
-	if (!(proc_iet_dir = proc_mkdir("net/iet", 0)))
+	if (!(proc_iet_dir = proc_mkdir("iet", init_net.proc_net)))
 		goto err;
 
 	proc_iet_dir->owner = THIS_MODULE;
diff --git a/ubuntu/iscsitarget/digest.c b/ubuntu/iscsitarget/digest.c
index 9ffa2bd..969ef17 100644
--- a/ubuntu/iscsitarget/digest.c
+++ b/ubuntu/iscsitarget/digest.c
@@ -215,6 +215,7 @@ static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
 
 	assert(count <= ISCSI_CONN_IOV_MAX);
 
+	sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
 	crypto_hash_init(hash);
 
 	for (i = 0; size; i++) {
@@ -228,6 +229,8 @@ static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
 		offset = 0;
 	}
 
+	sg_mark_end(&sg[i - 1]);
+
 	crypto_hash_update(hash, sg, nbytes);
 	crypto_hash_final(hash, crc);
 }
diff --git a/ubuntu/iscsitarget/event.c b/ubuntu/iscsitarget/event.c
index 8cdd7f6..e45ed67 100644
--- a/ubuntu/iscsitarget/event.c
+++ b/ubuntu/iscsitarget/event.c
@@ -37,7 +37,7 @@ static void event_recv_skb(struct sk_buff *skb)
 	while (skb->len >= NLMSG_SPACE(0)) {
 		nlh = (struct nlmsghdr *)skb->data;
 		if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
-			return;
+			break;
 		rlen = NLMSG_ALIGN(nlh->nlmsg_len);
 		if (rlen > skb->len)
 			rlen = skb->len;
@@ -47,23 +47,8 @@ static void event_recv_skb(struct sk_buff *skb)
 			netlink_ack(skb, nlh, 0);
 		skb_pull(skb, rlen);
 	}
-	return;
 }
 
-#if 0
-static void event_recv(struct sock *sk, int length)
-{
-	struct sk_buff *skb;
-
-	while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
-		if (event_recv_skb(skb) && skb->len)
-			skb_queue_head(&sk->sk_receive_queue, skb);
-		else
-			kfree_skb(skb);
-	}
-}
-#endif
-
 static int notify(void *data, int len, int gfp_mask)
 {
 	struct sk_buff *skb;
@@ -99,7 +84,6 @@ int event_init(void)
 {
 	nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb,
 				   NULL, THIS_MODULE);
-
 	if (!nl)
 		return -ENOMEM;
 	else
diff --git a/ubuntu/iscsitarget/iet_u.h b/ubuntu/iscsitarget/iet_u.h
index 0672819..7418eff 100644
--- a/ubuntu/iscsitarget/iet_u.h
+++ b/ubuntu/iscsitarget/iet_u.h
@@ -1,7 +1,7 @@
 #ifndef _IET_U_H
 #define _IET_U_H
 
-#define IET_VERSION_STRING	"0.4.15"
+#define IET_VERSION_STRING	"0.4.16"
 
 /* The maximum length of 223 bytes in the RFC. */
 #define ISCSI_NAME_LEN	256
-- 
1.5.4.3

