based on patch from Jeremy Laine,
added the missing compat-* patch, and fixed the patch against current backport
--- iscsitarget/debian/rules 2008-11-25 02:42:03.000000000 -0800 +++ iscsitarget/debian/rules 2009-03-03 18:11:03.000000000 -0800 @@ -42,6 +42,11 @@ kdist_clean: dh_clean $(MAKE) -C $(KSRC) SUBDIRS=$(shell pwd)/kernel clean + # Revert patch for kernels < 2.6.23 + if [ -f debian/stamp-patched ]; then \ + patch -p1 -R < patches/compat-2.6.14-2.6.23.patch; \ + rm -f debian/stamp-patched; \ + fi # prep-deb-files rewrites the debian/ files as needed. See RATIONALE for # details @@ -54,6 +59,11 @@ dh_testdir dh_testroot dh_clean -k + # Apply patch for kernels < 2.6.23 + if [ ! -f debian/stamp-patched ] && dpkg --compare-versions $(KVERS) lt 2.6.23; then \ + patch -p1 < patches/compat-2.6.14-2.6.23.patch; \ + touch debian/stamp-patched; \ + fi #$(MAKE) -C $(KSRC) KERNEL_SOURCES=$(KSRC) MODVERSIONS=detect KERNEL=linux-$(KVERS) KDIR=$(KSRC) SUBDIRS=$(shell pwd)/kernel modules $(MAKE) -C $(KSRC) SUBDIRS=$(shell pwd)/kernel modules @@ -101,10 +111,12 @@ dh_installdirs -p$(psource) usr/src/modules/$(PACKAGE)/debian dh_installdirs -p$(psource) usr/src/modules/$(PACKAGE)/include dh_installdirs -p$(psource) usr/src/modules/$(PACKAGE)/kernel + dh_installdirs -p$(psource) usr/src/modules/$(PACKAGE)/patches # Copy only the driver source to the proper location cp kernel/* debian/$(psource)/usr/src/modules/$(PACKAGE)/kernel/ cp include/* debian/$(psource)/usr/src/modules/$(PACKAGE)/include/ + cp patches/* debian/$(psource)/usr/src/modules/$(PACKAGE)/patches/ # Copy the needed debian/ pieces to the proper location cp debian/*-module-* \ diff -uN iscsitarget/patches/compat-2.6.14-2.6.23.patch iscsitarget/patches/compat-2.6.14-2.6.23.patch --- iscsitarget/patches/compat-2.6.14-2.6.23.patch 1969-12-31 16:00:00.000000000 -0800 +++ iscsitarget/patches/compat-2.6.14-2.6.23.patch 2009-03-03 18:11:03.000000000 -0800 @@ -0,0 +1,344 @@ +diff -uNr iscsitarget/kernel/block-io.c iscsitarget/kernel/block-io.c +--- iscsitarget/kernel/block-io.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/block-io.c 2009-03-03 18:01:49.000000000 -0800 +@@ -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 -uNr iscsitarget/kernel/config.c iscsitarget/kernel/config.c +--- iscsitarget/kernel/config.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/config.c 2009-03-03 18:01:49.000000000 -0800 +@@ -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 -uNr iscsitarget/kernel/digest.c iscsitarget/kernel/digest.c +--- iscsitarget/kernel/digest.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/digest.c 2009-03-03 18:02:00.000000000 -0800 +@@ -12,8 +12,7 @@ + + 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)) { + printk("CRC32C digest algorithm not available in kernel\n"); + *val |= ~DIGEST_CRC32C; + } +@@ -37,22 +36,15 @@ + if (!(conn->ddigest_type & DIGEST_ALL)) + conn->ddigest_type = DIGEST_NONE; + +- if (conn->hdigest_type & DIGEST_CRC32C || +- conn->ddigest_type & DIGEST_CRC32C) { +- conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0, +- CRYPTO_ALG_ASYNC); +- conn->rx_hash.flags = 0; +- if (IS_ERR(conn->rx_hash.tfm)) { +- conn->rx_hash.tfm = NULL; ++ 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) { + err = -ENOMEM; + goto out; + } + +- conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0, +- CRYPTO_ALG_ASYNC); +- conn->tx_hash.flags = 0; +- if (IS_ERR(conn->tx_hash.tfm)) { +- conn->tx_hash.tfm = NULL; ++ conn->tx_digest_tfm = crypto_alloc_tfm("crc32c", 0); ++ if (!conn->tx_digest_tfm) { + err = -ENOMEM; + goto out; + } +@@ -73,10 +65,10 @@ + */ + void digest_cleanup(struct iscsi_conn *conn) + { +- if (conn->tx_hash.tfm) +- crypto_free_hash(conn->tx_hash.tfm); +- if (conn->rx_hash.tfm) +- crypto_free_hash(conn->rx_hash.tfm); ++ if (conn->tx_digest_tfm) ++ crypto_free_tfm(conn->tx_digest_tfm); ++ if (conn->rx_digest_tfm) ++ crypto_free_tfm(conn->rx_digest_tfm); + } + + /** +@@ -160,30 +152,35 @@ + } + } + +-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_tfm *tfm, struct iscsi_pdu *pdu, u8 *crc) + { + struct scatterlist sg[2]; +- unsigned int nbytes = sizeof(struct iscsi_hdr); +- +- sg_init_table(sg, pdu->ahssize ? 2 : 1); ++ int i = 0; + +- sg_set_buf(&sg[0], &pdu->bhs, nbytes); ++ SETSG(sg[i], &pdu->bhs, sizeof(struct iscsi_hdr)); ++ i++; + if (pdu->ahssize) { +- sg_set_buf(&sg[1], pdu->ahs, pdu->ahssize); +- nbytes += pdu->ahssize; ++ SETSG(sg[i], pdu->ahs, pdu->ahssize); ++ i++; + } + +- crypto_hash_init(hash); +- crypto_hash_update(hash, sg, nbytes); +- crypto_hash_final(hash, crc); ++ crypto_digest_init(tfm); ++ crypto_digest_update(tfm, sg, i); ++ crypto_digest_final(tfm, crc); + } + + int digest_rx_header(struct iscsi_cmnd *cmnd) + { + u32 crc; + +- digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc); ++ digest_header(cmnd->conn->rx_digest_tfm, &cmnd->pdu, (u8 *) &crc); + if (crc != cmnd->hdigest) + return -EIO; + +@@ -192,19 +189,18 @@ + + 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); + } + +-static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd, ++static void digest_data(struct crypto_tfm *tfm, struct iscsi_cmnd *cmnd, + struct tio *tio, u32 offset, u8 *crc) + { + struct scatterlist *sg = cmnd->conn->hash_sg; + u32 size, length; + int i, idx, count; +- unsigned int nbytes; + + size = cmnd->pdu.datasize; +- nbytes = size = (size + 3) & ~3; ++ size = (size + 3) & ~3; + + offset += tio->offset; + idx = offset >> PAGE_CACHE_SHIFT; +@@ -214,8 +210,7 @@ + + assert(count <= ISCSI_CONN_IOV_MAX); + +- sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg)); +- crypto_hash_init(hash); ++ crypto_digest_init(tfm); + + for (i = 0; size; i++) { + if (offset + size > PAGE_CACHE_SIZE) +@@ -223,15 +218,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_hash_update(hash, sg, nbytes); +- crypto_hash_final(hash, crc); ++ crypto_digest_update(tfm, sg, count); ++ crypto_digest_final(tfm, crc); + } + + int digest_rx_data(struct iscsi_cmnd *cmnd) +@@ -257,10 +252,9 @@ + offset = 0; + } + +- digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc); ++ digest_data(cmnd->conn->rx_digest_tfm, 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)) { + if (crc != cmnd->ddigest) + return -EIO; + } +@@ -274,6 +268,6 @@ + struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs; + + assert(tio); +- digest_data(&cmnd->conn->tx_hash, cmnd, tio, ++ digest_data(cmnd->conn->tx_digest_tfm, cmnd, tio, + be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest); + } +diff -uNr iscsitarget/kernel/event.c iscsitarget/kernel/event.c +--- iscsitarget/kernel/event.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/event.c 2009-03-03 18:01:57.000000000 -0800 +@@ -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 -uNr iscsitarget/kernel/file-io.c iscsitarget/kernel/file-io.c +--- iscsitarget/kernel/file-io.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/file-io.c 2009-03-03 18:02:00.000000000 -0800 +@@ -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 -uNr iscsitarget/kernel/iscsi.c iscsitarget/kernel/iscsi.c +--- iscsitarget/kernel/iscsi.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/iscsi.c 2009-03-03 18:02:00.000000000 -0800 +@@ -15,7 +15,7 @@ + + unsigned long debug_enable_flags; + +-static struct kmem_cache *iscsi_cmnd_cache; ++static kmem_cache_t *iscsi_cmnd_cache; + static char dummy_data[1024]; + + 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 -uNr iscsitarget/kernel/iscsi.h iscsitarget/kernel/iscsi.h +--- iscsitarget/kernel/iscsi.h 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/iscsi.h 2009-03-03 18:02:00.000000000 -0800 +@@ -239,8 +239,8 @@ + u32 write_offset; + int write_state; + +- struct hash_desc rx_hash; +- struct hash_desc tx_hash; ++ struct crypto_tfm *rx_digest_tfm; ++ struct crypto_tfm *tx_digest_tfm; + struct scatterlist hash_sg[ISCSI_CONN_IOV_MAX]; + }; + +diff -uNr iscsitarget/kernel/tio.c iscsitarget/kernel/tio.c +--- iscsitarget/kernel/tio.c 2008-11-25 02:42:03.000000000 -0800 ++++ iscsitarget/kernel/tio.c 2009-03-03 18:02:00.000000000 -0800 +@@ -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; + } +