IET 0.4.17 Patches for SLES10SP2

If you’re using Suse Linux Enterprise Server (SLES) 10 SP2 and want the latest version of the iSCSI Enterprise Target (IET), aka iscsitarget, you’ll want this patch set to basically back out a lot of the compatibility stuff that was placed in the patch’s Makefile.

The reason this special patch is necessary is due to the backporting of numerous functions from 2.6.25 kernel into Novell’s 2.6.16 kernel used in SLES10SP2. This version update is especially necessary if you wish to make use of blockio.

To apply this patch, use the following procedures:

  1. copy the iet-0.4.17 to your system: ‘svn checkout svn://svn.berlios.de/iscsitarget/trunk’
  2. cd trunk/
  3. patch -p1 < ../[this patch]
  4. make sure openssl-devl is installed
  5. make&&make install

Enjoy!
[c]diff -Nur trunk/Makefile iet-0.4.16_sles10sp2/Makefile
— trunk/Makefile 2008-11-03 15:31:35.504757355 -0700
+++ iet-0.4.16_sles10sp2/Makefile 2008-11-02 16:00:51.000000000 -0700
@@ -51,31 +51,6 @@
# base first the earlier patch sets will not need to be modified.
#

-# Compatibility patch for kernels >= 2.6.22 and <= 2.6.23 -ifeq ($(call kver_le,2,6,23),1) - PATCHES := $(PATCHES) compat-2.6.22-2.6.23.patch -endif - -# 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 -endif - -# We don't support kernels < 2.6.14 except for explicit distros -ifeq ($(call kver_lt,2,6,14),1) - UNSUPPORTED := true -endif - -# Compatibility patch for RHEL4/CentOS4 -ifeq ($(call kver_lk,"2\.6\.9-.*\.(EL|plus\.c4)"),1) - PATCHES += compat-rhel4.patch - UNSUPPORTED := -endif MANPAGES:= ietadm.8 ietd.8 ietd.conf.5 Files trunk/kernel/._block-io.c and iet-0.4.16_sles10sp2/kernel/._block-io.c differ Files trunk/kernel/._iscsi.c and iet-0.4.16_sles10sp2/kernel/._iscsi.c differ diff -Nur trunk/kernel/block-io.c iet-0.4.16_sles10sp2/kernel/block-io.c --- trunk/kernel/block-io.c 2008-11-03 15:31:34.132495685 -0700 +++ iet-0.4.16_sles10sp2/kernel/block-io.c 2008-11-02 15:57:55.000000000 -0700 @@ -11,12 +11,12 @@ #include #include -#include #include

#include “iscsi.h”
#include “iscsi_dbg.h”
#include “iotype.h”
+#include

struct blockio_data {
char *path;
@@ -29,10 +29,15 @@
struct completion tio_complete;
};

-static void blockio_bio_endio(struct bio *bio, int error)
+static int
+blockio_bio_endio(struct bio *bio, unsigned int bytes_done, int error)
{
struct tio_work *tio_work = bio->bi_private;

+ /* Ignore partials */
+ if (bio->bi_size)
+ return 1;
+
error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;

if (error)
@@ -43,6 +48,8 @@
complete(&tio_work->tio_complete);

bio_put(bio);
+
+ return 0;
}

/*
diff -Nur trunk/kernel/config.c iet-0.4.16_sles10sp2/kernel/config.c
— trunk/kernel/config.c 2008-11-03 15:31:34.132495685 -0700
+++ iet-0.4.16_sles10sp2/kernel/config.c 2008-11-02 15:55:25.000000000 -0700
@@ -40,7 +40,7 @@
int i;
struct proc_dir_entry *ent;

– if (!(proc_iet_dir = proc_mkdir(“iet”, init_net.proc_net)))
+ if (!(proc_iet_dir = proc_mkdir(“net/iet”, 0)))
goto err;

proc_iet_dir->owner = THIS_MODULE;
diff -Nur trunk/kernel/digest.c iet-0.4.16_sles10sp2/kernel/digest.c
— trunk/kernel/digest.c 2008-11-03 15:31:34.176504077 -0700
+++ iet-0.4.16_sles10sp2/kernel/digest.c 2008-11-02 15:59:47.000000000 -0700
@@ -12,8 +12,8 @@

void digest_alg_available(unsigned int *val)
{
– if (*val & DIGEST_CRC32C &&
– !crypto_has_alg(“crc32c”, 0, CRYPTO_ALG_ASYNC)) {
+ //if (*val & DIGEST_CRC32C && !crypto_alg_available(“crc32c”, 0)) {
+ if (*val & DIGEST_CRC32C && !crypto_has_alg(“crc32c”, 0, 0)) {
printk(“CRC32C digest algorithm not available in kernel\n”);
*val |= ~DIGEST_CRC32C;
}
@@ -37,10 +37,13 @@
if (!(conn->ddigest_type & DIGEST_ALL))
conn->ddigest_type = DIGEST_NONE;

+ //if (conn->hdigest_type & DIGEST_CRC32C || conn->ddigest_type & DIGEST_CRC32C) {
+ // conn->rx_digest_tfm = crypto_alloc_tfm(“crc32c”, 0);
+ // if (!conn->rx_digest_tfm) {
if (conn->hdigest_type & DIGEST_CRC32C ||
– conn->ddigest_type & DIGEST_CRC32C) {
+ conn->ddigest_type & DIGEST_CRC32C) {
conn->rx_hash.tfm = crypto_alloc_hash(“crc32c”, 0,
– CRYPTO_ALG_ASYNC);
+ CRYPTO_ALG_ASYNC);
conn->rx_hash.flags = 0;
if (IS_ERR(conn->rx_hash.tfm)) {
conn->rx_hash.tfm = NULL;
@@ -48,8 +51,10 @@
goto out;
}

+ //conn->tx_digest_tfm = crypto_alloc_tfm(“crc32c”, 0);
+ //if (!conn->tx_digest_tfm) {
conn->tx_hash.tfm = crypto_alloc_hash(“crc32c”, 0,
– CRYPTO_ALG_ASYNC);
+ CRYPTO_ALG_ASYNC);
conn->tx_hash.flags = 0;
if (IS_ERR(conn->tx_hash.tfm)) {
conn->tx_hash.tfm = NULL;
@@ -73,6 +78,10 @@
*/
void digest_cleanup(struct iscsi_conn *conn)
{
+ //if (conn->tx_digest_tfm)
+ // crypto_free_tfm(conn->tx_digest_tfm);
+ //if (conn->rx_digest_tfm)
+ // crypto_free_tfm(conn->rx_digest_tfm);
if (conn->tx_hash.tfm)
crypto_free_hash(conn->tx_hash.tfm);
if (conn->rx_hash.tfm)
@@ -160,22 +169,34 @@
}
}

-static void digest_header(struct hash_desc *hash, struct iscsi_pdu *pdu,
– u8 *crc)
+/* Copied from linux-iscsi initiator and slightly adjusted */
+#define SETSG(sg, p, l) do { \
+ (sg).page = virt_to_page((p)); \
+ (sg).offset = ((unsigned long)(p) & ~PAGE_CACHE_MASK); \
+ (sg).length = (l); \
+} while (0)
+
+static void digest_header(struct crypto_desc *hash, struct iscsi_pdu *pdu, u8 *crc)
{
struct scatterlist sg[2];
+ //int i = 0;
unsigned int nbytes = sizeof(struct iscsi_hdr);

– sg_init_table(sg, pdu->ahssize ? 2 : 1);

– sg_set_buf(&sg[0], &pdu->bhs, nbytes);
+ //SETSG(sg[i], &pdu->bhs, sizeof(struct iscsi_hdr));
+ //i++;
+ SETSG(sg[0], &pdu->bhs, nbytes);
if (pdu->ahssize) {
– sg_set_buf(&sg[1], pdu->ahs, pdu->ahssize);
+ //SETSG(sg[i], pdu->ahs, pdu->ahssize);
+ //i++;
+ SETSG(sg[1], pdu->ahs, pdu->ahssize);
nbytes += pdu->ahssize;
}

+ //crypto_digest_init(tfm);
crypto_hash_init(hash);
+ //crypto_digest_update(tfm, sg, i);
crypto_hash_update(hash, sg, nbytes);
+ //crypto_digest_final(tfm, crc);
crypto_hash_final(hash, crc);
}

@@ -183,6 +204,7 @@
{
u32 crc;

+ //digest_header(cmnd->conn->rx_digest_tfm, &cmnd->pdu, (u8 *) &crc);
digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
if (crc != cmnd->hdigest)
return -EIO;
@@ -192,9 +214,11 @@

void digest_tx_header(struct iscsi_cmnd *cmnd)
{
– digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
+ //digest_header(cmnd->conn->tx_digest_tfm, &cmnd->pdu, (u8 *) &cmnd->hdigest);
+ digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *)&cmnd->hdigest);
}

+//static void digest_data(struct crypto_tfm *tfm, struct iscsi_cmnd *cmnd,
static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
struct tio *tio, u32 offset, u8 *crc)
{
@@ -204,6 +228,7 @@
unsigned int nbytes;

size = cmnd->pdu.datasize;
+ //size = (size + 3) & ~3;
nbytes = size = (size + 3) & ~3;

offset += tio->offset;
@@ -214,7 +239,7 @@

assert(count <= ISCSI_CONN_IOV_MAX); - sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
+ //crypto_digest_init(tfm);
crypto_hash_init(hash);

for (i = 0; size; i++) {
@@ -223,13 +248,15 @@
else
length = size;

– sg_set_page(&sg[i], tio->pvec[idx + i], length, offset);
+ sg[i].page = tio->pvec[idx + i];
+ sg[i].offset = offset;
+ sg[i].length = length;
size -= length;
offset = 0;
}

– sg_mark_end(&sg[i – 1]);

+ //crypto_digest_update(tfm, sg, count);
+ //crypto_digest_final(tfm, crc);
crypto_hash_update(hash, sg, nbytes);
crypto_hash_final(hash, crc);
}
@@ -257,10 +284,12 @@
offset = 0;
}

+ //digest_data(cmnd->conn->rx_digest_tfm, cmnd, tio, offset, (u8 *) &crc);
digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);

+ //if (!cmnd->conn->read_overflow && (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
if (!cmnd->conn->read_overflow &&
– (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
+ (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
if (crc != cmnd->ddigest)
return -EIO;
}
@@ -274,6 +303,7 @@
struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;

assert(tio);
+ //digest_data(cmnd->conn->tx_digest_tfm, cmnd, tio,
digest_data(&cmnd->conn->tx_hash, cmnd, tio,
be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
}
diff -Nur trunk/kernel/event.c iet-0.4.16_sles10sp2/kernel/event.c
— trunk/kernel/event.c 2008-11-03 15:31:34.184505603 -0700
+++ iet-0.4.16_sles10sp2/kernel/event.c 2008-11-02 15:55:25.000000000 -0700
@@ -28,7 +28,7 @@
return 0;
}

-static void event_recv_skb(struct sk_buff *skb)
+static int event_recv_skb(struct sk_buff *skb)
{
int err;
struct nlmsghdr *nlh;
@@ -37,7 +37,7 @@
while (skb->len >= NLMSG_SPACE(0)) {
nlh = (struct nlmsghdr *)skb->data;
if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
– break;
+ return 0;
rlen = NLMSG_ALIGN(nlh->nlmsg_len);
if (rlen > skb->len)
rlen = skb->len;
@@ -47,6 +47,19 @@
netlink_ack(skb, nlh, 0);
skb_pull(skb, rlen);
}
+ return 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);
+ }
}

static int notify(void *data, int len, int gfp_mask)
@@ -82,8 +95,7 @@

int event_init(void)
{
– nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb,
– NULL, THIS_MODULE);
+ nl = netlink_kernel_create(NETLINK_IET, 1, event_recv, THIS_MODULE);
if (!nl)
return -ENOMEM;
else
diff -Nur trunk/kernel/file-io.c iet-0.4.16_sles10sp2/kernel/file-io.c
— trunk/kernel/file-io.c 2008-11-03 15:31:34.188506365 -0700
+++ iet-0.4.16_sles10sp2/kernel/file-io.c 2008-11-02 15:55:25.000000000 -0700
@@ -53,9 +53,9 @@
set_fs(get_ds());

if (rw == READ)
– ret = do_sync_read(filp, buf, count, &ppos);
+ ret = generic_file_read(filp, buf, count, &ppos);
else
– ret = do_sync_write(filp, buf, count, &ppos);
+ ret = generic_file_write(filp, buf, count, &ppos);

set_fs(oldfs);

diff -Nur trunk/kernel/iscsi.c iet-0.4.16_sles10sp2/kernel/iscsi.c
— trunk/kernel/iscsi.c 2008-11-03 15:31:34.136496448 -0700
+++ iet-0.4.16_sles10sp2/kernel/iscsi.c 2008-11-02 15:59:01.000000000 -0700
@@ -15,7 +15,7 @@

unsigned long debug_enable_flags;

-static struct kmem_cache *iscsi_cmnd_cache;
+static kmem_cache_t *iscsi_cmnd_cache;
static u8 dummy_data[PAGE_SIZE];

static int ctr_major;
@@ -1762,7 +1762,8 @@
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; diff -Nur trunk/kernel/iscsi.h iet-0.4.16_sles10sp2/kernel/iscsi.h --- trunk/kernel/iscsi.h 2008-11-03 15:31:34.176504077 -0700 +++ iet-0.4.16_sles10sp2/kernel/iscsi.h 2008-11-03 15:32:49.342836992 -0700 @@ -241,6 +241,8 @@ u32 write_offset; int write_state; + //struct crypto_tfm *rx_digest_tfm; + //struct crypto_tfm *tx_digest_tfm; struct hash_desc rx_hash; struct hash_desc tx_hash; struct scatterlist hash_sg[ISCSI_CONN_IOV_MAX]; diff -Nur trunk/kernel/tio.c iet-0.4.16_sles10sp2/kernel/tio.c --- trunk/kernel/tio.c 2008-11-03 15:31:34.568578840 -0700 +++ iet-0.4.16_sles10sp2/kernel/tio.c 2008-11-02 15:55:25.000000000 -0700 @@ -35,7 +35,7 @@ return 0; } -static struct kmem_cache *tio_cache; +static kmem_cache_t *tio_cache; struct tio *tio_alloc(int count) { @@ -110,7 +110,8 @@ 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; }[/c]

Leave a Reply

Your email address will not be published. Required fields are marked *