Hi,

I wrote a message by web interface few days ago. (Select "+ new post" and
push "Send to moderators" button.) But nothing is posted to lists, so
I re-write a message and send by e-mail again.


I tried to build open-iscsi-2.0.871.3 on my system with linux-2.6.33.2
by adjusting kernel/Makefile. But I failed to build.
(Simply I added "linux_2_6_33: $(unpatch_code)" in kernel/Makefile.)

Error messages are described below:
----- [snip] -----
  CC [M]  /root/open-iscsi-2.0.871.3/kernel/libiscsi.o
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c: In function 'iscsi_free_task':
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:431: error: implicit
declaration of function '__kfifo_put'
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c: In function
'__iscsi_conn_send_pdu':
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:617: error: implicit
declaration of function '__kfifo_get'
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c: In function 'iscsi_target_alloc':
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:1552: warning: unused
variable 'session'
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c: In function 'iscsi_pool_init':
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:2127: warning: passing
argument 2 of 'kfifo_init' makes pointer from integer without a cast
include/linux/kfifo.h:105: note: expected 'void *' but argument is of
type 'long unsigned int'
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:2127: error: too many
arguments to function 'kfifo_init'
/root/open-iscsi-2.0.871.3/kernel/libiscsi.c:2127: error: void value
not ignored as it ought to be
make[3]: *** [/root/open-iscsi-2.0.871.3/kernel/libiscsi.o] Error 1
----- [snip] -----

The kfifo API seems to have changed from linux-2.6.33,
so I made a patch to support this API change.

The patched open-iscsi-2.0.871.3 was built with linux-2.6.33.2
successfully. And it passed simple test (modprobe iscsi_tcp,
start iscsid, discovery, login, write and modprobe -r iscsi_tcp).
But it has not tested strictly yet.
Also Kernel module development is new to me.

Please use this patch carefully. ;-)


Thanks,
Hiroshi KIHIRA


Signed-off-by: Hiroshi KIHIRA <johnny.h...@gmail.com>
---
 kernel/2.6.33_compat.patch |  201 ++++++++++++++++++++++++++++++++++++++++++++
 kernel/Makefile            |   14 +++-
 2 files changed, 214 insertions(+), 1 deletions(-)
 create mode 100644 kernel/2.6.33_compat.patch

diff --git a/kernel/2.6.33_compat.patch b/kernel/2.6.33_compat.patch
new file mode 100644
index 0000000..ad20ba5
--- /dev/null
+++ b/kernel/2.6.33_compat.patch
@@ -0,0 +1,201 @@
+diff -Nur kernel.orig/libiscsi.c kernel/libiscsi.c
+--- kernel.orig/libiscsi.c     2010-03-06 07:32:44.000000000 +0900
++++ kernel/libiscsi.c  2010-05-01 12:58:11.000000000 +0900
+@@ -428,7 +428,7 @@
+       if (conn->login_task == task)
+               return;
+
+-      __kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*));
++      kfifo_in(session->cmdpool.queue, (void*)&task, sizeof(void*));
+
+       if (sc) {
+               task->sc = NULL;
+@@ -614,7 +614,7 @@
+               BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
+               BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
+
+-              if (!__kfifo_get(session->cmdpool.queue,
++              if (!kfifo_out(session->cmdpool.queue,
+                                (void*)&task, sizeof(void*)))
+                       return NULL;
+       }
+@@ -1376,7 +1376,7 @@
+ {
+       struct iscsi_task *task;
+
+-      if (!__kfifo_get(conn->session->cmdpool.queue,
++      if (!kfifo_out(conn->session->cmdpool.queue,
+                        (void *) &task, sizeof(void *)))
+               return NULL;
+
+@@ -2102,7 +2102,7 @@
+
+ /*
+  * Pre-allocate a pool of @max items of @item_size. By default, the pool
+- * should be accessed via kfifo_{get,put} on q->queue.
++ * should be accessed via kfifo_{in,out} on q->queue.
+  * Optionally, the caller can obtain the array of object pointers
+  * by passing in a non-NULL @items pointer
+  */
+@@ -2123,8 +2123,12 @@
+       if (q->pool == NULL)
+               return -ENOMEM;
+
+-      q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
+-                            GFP_KERNEL, NULL);
++      q->queue = kmalloc(sizeof(struct kfifo), GFP_KERNEL);
++      if (IS_ERR(q->queue)) {
++              kfree(q->pool);
++              return -ENOMEM;
++      }
++      kfifo_init(q->queue, (void*)q->pool, max * sizeof(void*));
+       if (IS_ERR(q->queue)) {
+               q->queue = NULL;
+               goto enomem;
+@@ -2136,7 +2140,7 @@
+                       q->max = i;
+                       goto enomem;
+               }
+-              __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
++              kfifo_in(q->queue, (void*)&q->pool[i], sizeof(void*));
+       }
+
+       if (items) {
+@@ -2484,7 +2488,7 @@
+
+       /* allocate login_task used for the login/text sequences */
+       spin_lock_bh(&session->lock);
+-      if (!__kfifo_get(session->cmdpool.queue,
++      if (!kfifo_out(session->cmdpool.queue,
+                          (void*)&conn->login_task,
+                        sizeof(void*))) {
+               spin_unlock_bh(&session->lock);
+@@ -2504,7 +2508,7 @@
+       return cls_conn;
+
+ login_task_data_alloc_fail:
+-      __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
++      kfifo_in(session->cmdpool.queue, (void*)&conn->login_task,
+                   sizeof(void*));
+ login_task_alloc_fail:
+       iscsi_destroy_conn(cls_conn);
+@@ -2567,7 +2571,7 @@
+       free_pages((unsigned long) conn->data,
+                  get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
+       kfree(conn->persistent_address);
+-      __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
++      kfifo_in(session->cmdpool.queue, (void*)&conn->login_task,
+                   sizeof(void*));
+       if (session->leadconn == conn)
+               session->leadconn = NULL;
+diff -Nur kernel.orig/libiscsi_tcp.c kernel/libiscsi_tcp.c
+--- kernel.orig/libiscsi_tcp.c 2010-03-06 07:32:44.000000000 +0900
++++ kernel/libiscsi_tcp.c      2010-05-01 13:31:41.000000000 +0900
+@@ -445,15 +445,15 @@
+               return;
+
+       /* flush task's r2t queues */
+-      while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
+-              __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
++      while (kfifo_out(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
++              kfifo_in(tcp_task->r2tpool.queue, (void*)&r2t,
+                           sizeof(void*));
+               ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
+       }
+
+       r2t = tcp_task->r2t;
+       if (r2t != NULL) {
+-              __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
++              kfifo_in(tcp_task->r2tpool.queue, (void*)&r2t,
+                           sizeof(void*));
+               tcp_task->r2t = NULL;
+       }
+@@ -541,7 +541,7 @@
+               return 0;
+       }
+
+-      rc = __kfifo_get(tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
++      rc = kfifo_out(tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
+       if (!rc) {
+               iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
+                                 "Target has sent more R2Ts than it "
+@@ -554,7 +554,7 @@
+       if (r2t->data_length == 0) {
+               iscsi_conn_printk(KERN_ERR, conn,
+                                 "invalid R2T with zero data len\n");
+-              __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
++              kfifo_in(tcp_task->r2tpool.queue, (void*)&r2t,
+                           sizeof(void*));
+               return ISCSI_ERR_DATALEN;
+       }
+@@ -570,7 +570,7 @@
+                                 "invalid R2T with data len %u at offset %u "
+                                 "and total length %d\n", r2t->data_length,
+                                 r2t->data_offset, scsi_out(task->sc)->length);
+-              __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
++              kfifo_in(tcp_task->r2tpool.queue, (void*)&r2t,
+                           sizeof(void*));
+               return ISCSI_ERR_DATALEN;
+       }
+@@ -580,7 +580,7 @@
+       r2t->sent = 0;
+
+       tcp_task->exp_datasn = r2tsn + 1;
+-      __kfifo_put(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
++      kfifo_in(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
+       conn->r2t_pdus_cnt++;
+
+       iscsi_requeue_task(task);
+@@ -951,7 +951,7 @@
+               return conn->session->tt->init_pdu(task, 0, task->data_count);
+       }
+
+-      BUG_ON(__kfifo_len(tcp_task->r2tqueue));
++      BUG_ON(kfifo_len(tcp_task->r2tqueue));
+       tcp_task->exp_datasn = 0;
+
+       /* Prepare PDU, optionally w/ immediate data */
+@@ -982,7 +982,7 @@
+                       if (r2t->data_length <= r2t->sent) {
+                               ISCSI_DBG_TCP(task->conn,
+                                             "  done with r2t %p\n", r2t);
+-                              __kfifo_put(tcp_task->r2tpool.queue,
++                              kfifo_in(tcp_task->r2tpool.queue,
+                                           (void *)&tcp_task->r2t,
+                                           sizeof(void *));
+                               tcp_task->r2t = r2t = NULL;
+@@ -990,7 +990,7 @@
+               }
+
+               if (r2t == NULL) {
+-                      __kfifo_get(tcp_task->r2tqueue,
++                      kfifo_out(tcp_task->r2tqueue,
+                                   (void *)&tcp_task->r2t, sizeof(void *));
+                       r2t = tcp_task->r2t;
+               }
+@@ -1105,6 +1105,7 @@
+ {
+       int i;
+       int cmd_i;
++      int alloc_ret;
+
+       /*
+        * initialize per-task: R2T pool and xmit queue
+@@ -1127,9 +1128,13 @@
+               }
+
+               /* R2T xmit queue */
+-              tcp_task->r2tqueue = kfifo_alloc(
+-                    session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);
+-              if (tcp_task->r2tqueue == ERR_PTR(-ENOMEM)) {
++              tcp_task->r2tqueue = kmalloc(sizeof(struct kfifo), GFP_KERNEL);
++              if (IS_ERR(tcp_task->r2tqueue))
++                      goto r2t_alloc_fail;
++              alloc_ret = kfifo_alloc(tcp_task->r2tqueue,
++                    session->max_r2t * 4 * sizeof(void*), GFP_KERNEL);
++              if (alloc_ret == -ENOMEM) {
++                      kfree(tcp_task->r2tqueue);
+                       iscsi_pool_free(&tcp_task->r2tpool);
+                       goto r2t_alloc_fail;
+               }
+
diff --git a/kernel/Makefile b/kernel/Makefile
index a264aed..c28d235 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -53,7 +53,8 @@ all: kernel_check
 24_patch=2.6.24_compat.patch
 26_patch=2.6.26_compat.patch
 27_patch=2.6.27_compat.patch
-all_patches=14to21_patch 20to21_patch 24_patch 26_patch 27_patch
+33_patch=2.6.33_compat.patch
+all_patches=14to21_patch 20to21_patch 24_patch 26_patch 27_patch 33_patch
 cur_patched=cur_patched

 ## fun stuff for maintaining multiple versions
@@ -106,6 +107,8 @@ linux_2_6_31: $(unpatch_code)

 linux_2_6_32: $(unpatch_code)

+linux_2_6_33: has_33_patch
+
 do_unpatch_code:
        echo "Un-patching source code for use with linux-2.6.14 and up ..."
        patch -R -E -p1 < $(cur_patched)
@@ -150,6 +153,15 @@ has_27_patch: $(27_patch)
        cp $(27_patch) $@
        ln -s $@ $(cur_patched)

+has_33_patch: $(33_patch)
+       echo "Patching source code for linux-2.6.33 ..."
+       if [ -e $(cur_patched) ]; then \
+               make -C . clean; \
+       fi
+       patch -p1 < $(33_patch)
+       cp $(33_patch) $@
+       ln -s $@ $(cur_patched)
+

 # ============ END code for kernel_check and source patching =================



-- 
Hiroshi KIHIRA <johnny.h...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to