summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/2.6.14-19_compat.patch163
1 files changed, 144 insertions, 19 deletions
diff --git a/kernel/2.6.14-19_compat.patch b/kernel/2.6.14-19_compat.patch
index f8c5d5b..51991c1 100644
--- a/kernel/2.6.14-19_compat.patch
+++ b/kernel/2.6.14-19_compat.patch
@@ -1,9 +1,9 @@
diff --git a/iscsi_compat.h b/iscsi_compat.h
new file mode 100644
-index 0000000..065c9dc
+index 0000000..22e7c44
--- /dev/null
+++ b/iscsi_compat.h
-@@ -0,0 +1,156 @@
+@@ -0,0 +1,181 @@
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <scsi/scsi.h>
@@ -56,7 +56,7 @@ index 0000000..065c9dc
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
+
-+#define netlink_kernel_create(uint, groups, input, cb_mutex, mod) \
++#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
+ netlink_kernel_create(uint, input)
+
+#define gfp_t unsigned
@@ -136,10 +136,35 @@ index 0000000..065c9dc
+#endif
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
-+#define netlink_kernel_create(uint, groups, input, cb_mutex, mod) \
++#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
+ netlink_kernel_create(uint, groups, input, mod)
++
+#endif
+
++static inline struct scatterlist *sg_next(struct scatterlist *sg)
++{
++ if (!sg) {
++ BUG();
++ return NULL;
++ }
++ return sg + 1;
++}
++
++#define sg_page(_sg) _sg->page
++
++static inline void sg_set_page(struct scatterlist *sg, struct page *page,
++ unsigned int len, unsigned int offset)
++{
++ sg->page = page;
++ sg->offset = offset;
++ sg->length = len;
++}
++
++static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
++{
++ memset(sgl, 0, sizeof(*sgl) * nents);
++}
++
+#define scsi_sg_count(cmd) ((cmd)->use_sg)
+#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer)
+#define scsi_bufflen(cmd) ((cmd)->request_bufflen)
@@ -161,7 +186,7 @@ index 0000000..065c9dc
+
+#endif
diff --git a/iscsi_tcp.c b/iscsi_tcp.c
-index 8296274..07de929 100644
+index cc075bc..af93a6c 100644
--- a/iscsi_tcp.c
+++ b/iscsi_tcp.c
@@ -43,6 +43,7 @@
@@ -172,7 +197,7 @@ index 8296274..07de929 100644
MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, "
"Alex Aizman <itn780@yahoo.com>");
-@@ -436,6 +437,17 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment,
+@@ -421,6 +422,17 @@ iscsi_segment_seek_sg(struct iscsi_segment *segment,
debug_scsi("iscsi_segment_seek_sg offset %u size %llu\n",
offset, size);
@@ -188,8 +213,18 @@ index 8296274..07de929 100644
+ }
+
__iscsi_segment_init(segment, size, done, hash);
- for (i = 0; i < sg_count; i++, sg = iscsi_sg_next(sg)) {
+ for (i = 0; i < sg_count; i++, sg = sg_next(sg)) {
debug_scsi("sg %d, len %u offset %u\n", i, sg->length,
+@@ -1934,7 +1946,9 @@ static struct scsi_host_template iscsi_sht = {
+ .eh_device_reset_handler= iscsi_eh_device_reset,
+ .eh_host_reset_handler = iscsi_eh_host_reset,
+ .use_clustering = DISABLE_CLUSTERING,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+ .use_sg_chaining = ENABLE_SG_CHAINING,
++#endif
+ .slave_configure = iscsi_tcp_slave_configure,
+ .proc_name = "iscsi_tcp",
+ .this_id = -1,
diff --git a/iscsi_tcp.h b/iscsi_tcp.h
index 57c2317..783e448 100644
--- a/iscsi_tcp.h
@@ -203,7 +238,7 @@ index 57c2317..783e448 100644
struct socket;
struct iscsi_tcp_conn;
diff --git a/libiscsi.c b/libiscsi.c
-index dce6b4e..f54a099 100644
+index d175f14..da0dd4e 100644
--- a/libiscsi.c
+++ b/libiscsi.c
@@ -24,6 +24,7 @@
@@ -214,7 +249,7 @@ index dce6b4e..f54a099 100644
#include <asm/unaligned.h>
#include <net/tcp.h>
#include <scsi/scsi_cmnd.h>
-@@ -977,10 +978,9 @@ again:
+@@ -976,10 +977,9 @@ again:
return rc;
}
@@ -227,7 +262,7 @@ index dce6b4e..f54a099 100644
int rc;
/*
* serialize Xmit worker on a per-connection basis.
-@@ -1728,7 +1728,9 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
+@@ -1727,7 +1727,9 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
shost->max_cmd_len = iscsit->max_cmd_len;
shost->transportt = scsit;
shost->transportt->create_work_queue = 1;
@@ -237,7 +272,7 @@ index dce6b4e..f54a099 100644
*hostno = shost->host_no;
session = iscsi_hostdata(shost->hostdata);
-@@ -1876,7 +1878,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
+@@ -1877,7 +1879,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
INIT_LIST_HEAD(&conn->mgmtqueue);
INIT_LIST_HEAD(&conn->xmitqueue);
INIT_LIST_HEAD(&conn->requeue);
@@ -268,7 +303,7 @@ index 8328bc7..028b5df 100644
struct scsi_device;
struct Scsi_Host;
diff --git a/scsi_transport_iscsi.c b/scsi_transport_iscsi.c
-index 0dbcedd..2e1ba67 100644
+index 7e5e168..65541bb 100644
--- a/scsi_transport_iscsi.c
+++ b/scsi_transport_iscsi.c
@@ -21,7 +21,10 @@
@@ -288,7 +323,7 @@ index 0dbcedd..2e1ba67 100644
#include "iscsi_if.h"
+#include "iscsi_compat.h"
- #define ISCSI_SESSION_ATTRS 16
+ #define ISCSI_SESSION_ATTRS 18
#define ISCSI_CONN_ATTRS 11
@@ -254,11 +258,9 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
return 0;
@@ -331,7 +366,97 @@ index 0dbcedd..2e1ba67 100644
/* this is released in the dev's release function */
scsi_host_get(shost);
-@@ -1406,7 +1406,10 @@ iscsi_register_transport(struct iscsi_transport *tt)
+@@ -1123,45 +1123,56 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
+ * Malformed skbs with wrong lengths or invalid creds are not processed.
+ */
+ static void
+-iscsi_if_rx(struct sk_buff *skb)
++iscsi_if_rx(struct sock *sk, int len)
+ {
++ struct sk_buff *skb;
++
+ mutex_lock(&rx_queue_mutex);
+- while (skb->len >= NLMSG_SPACE(0)) {
+- int err;
+- uint32_t rlen;
+- struct nlmsghdr *nlh;
+- struct iscsi_uevent *ev;
+-
+- nlh = nlmsg_hdr(skb);
+- if (nlh->nlmsg_len < sizeof(*nlh) ||
+- skb->len < nlh->nlmsg_len) {
+- break;
++ while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
++ if (NETLINK_CREDS(skb)->uid) {
++ skb_pull(skb, skb->len);
++ goto free_skb;
+ }
+
+- ev = NLMSG_DATA(nlh);
+- rlen = NLMSG_ALIGN(nlh->nlmsg_len);
+- if (rlen > skb->len)
+- rlen = skb->len;
++ while (skb->len >= NLMSG_SPACE(0)) {
++ int err;
++ uint32_t rlen;
++ struct nlmsghdr *nlh;
++ struct iscsi_uevent *ev;
+
+- err = iscsi_if_recv_msg(skb, nlh);
+- if (err) {
+- ev->type = ISCSI_KEVENT_IF_ERROR;
+- ev->iferror = err;
+- }
+- do {
+- /*
+- * special case for GET_STATS:
+- * on success - sending reply and stats from
+- * inside of if_recv_msg(),
+- * on error - fall through.
+- */
+- if (ev->type == ISCSI_UEVENT_GET_STATS && !err)
++ nlh = nlmsg_hdr(skb);
++ if (nlh->nlmsg_len < sizeof(*nlh) ||
++ skb->len < nlh->nlmsg_len) {
+ break;
+- err = iscsi_if_send_reply(
+- NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
+- nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
+- } while (err < 0 && err != -ECONNREFUSED);
+- skb_pull(skb, rlen);
++ }
++
++ ev = NLMSG_DATA(nlh);
++ rlen = NLMSG_ALIGN(nlh->nlmsg_len);
++ if (rlen > skb->len)
++ rlen = skb->len;
++
++ err = iscsi_if_recv_msg(skb, nlh);
++ if (err) {
++ ev->type = ISCSI_KEVENT_IF_ERROR;
++ ev->iferror = err;
++ }
++ do {
++ /*
++ * special case for GET_STATS:
++ * on success - sending reply and stats from
++ * inside of if_recv_msg(),
++ * on error - fall through.
++ */
++ if (ev->type == ISCSI_UEVENT_GET_STATS && !err)
++ break;
++ err = iscsi_if_send_reply(
++ NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
++ nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
++ } while (err < 0 && err != -ECONNREFUSED);
++ skb_pull(skb, rlen);
++ }
++free_skb:
++ kfree_skb(skb);
+ }
+ mutex_unlock(&rx_queue_mutex);
+ }
+@@ -1396,7 +1407,10 @@ iscsi_register_transport(struct iscsi_transport *tt)
INIT_LIST_HEAD(&priv->list);
priv->daemon_pid = -1;
priv->iscsi_transport = tt;
@@ -343,23 +468,23 @@ index 0dbcedd..2e1ba67 100644
priv->cdev.class = &iscsi_transport_class;
snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name);
diff --git a/scsi_transport_iscsi.h b/scsi_transport_iscsi.h
-index 26717c5..a2dfb0f 100644
+index 6bda9b9..deaa582 100644
--- a/scsi_transport_iscsi.h
+++ b/scsi_transport_iscsi.h
-@@ -24,7 +24,12 @@
- #define SCSI_TRANSPORT_ISCSI_H
+@@ -25,8 +25,12 @@
#include <linux/device.h>
+ #include <linux/list.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
-+#include <linux/mutex.h>
+ #include <linux/mutex.h>
+#endif
#include "iscsi_if.h"
+#include "iscsi_compat.h"
struct scsi_transport_template;
struct iscsi_transport;
-@@ -183,7 +188,7 @@ struct iscsi_cls_session {
+@@ -185,7 +189,7 @@ struct iscsi_cls_session {
/* recovery fields */
int recovery_tmo;