Hi,

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 wrote 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 very simple test(modprobe iscsi_tcp,
start iscsid, discovery, login, write and modprobe -r iscsi_tcp).
But it has not tested strictly yet.

Please use this patch carefully.


----- [patch] -----
Created By: Hiroshi KIHIRA
Date: 2010-05-01
Description:
 - Add kernel-2.6.33 target.
 - Fix usage of kfifo.


diff -Nur open-iscsi-2.0.871.3.orig/kernel/Makefile open-
iscsi-2.0.871.3/kernel/Makefile
--- open-iscsi-2.0.871.3.orig/kernel/Makefile   2010-03-06
07:32:44.000000000 +0900
+++ open-iscsi-2.0.871.3/kernel/Makefile        2010-05-01 12:37:47.000000000
+0900
@@ -106,6 +106,8 @@

 linux_2_6_32: $(unpatch_code)

+linux_2_6_33: $(unpatch_code)
+
 do_unpatch_code:
        echo "Un-patching source code for use with linux-2.6.14 and up ..."
        patch -R -E -p1 < $(cur_patched)
diff -Nur open-iscsi-2.0.871.3.orig/kernel/libiscsi.c open-
iscsi-2.0.871.3/kernel/libiscsi.c
--- open-iscsi-2.0.871.3.orig/kernel/libiscsi.c 2010-03-06
07:32:44.000000000 +0900
+++ open-iscsi-2.0.871.3/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 (q->queue == NULL) {
+               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 open-iscsi-2.0.871.3.orig/kernel/libiscsi_tcp.c open-
iscsi-2.0.871.3/kernel/libiscsi_tcp.c
--- open-iscsi-2.0.871.3.orig/kernel/libiscsi_tcp.c     2010-03-06
07:32:44.000000000 +0900
+++ open-iscsi-2.0.871.3/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;
                }
----- [patch] -----


Thanks,
Hiroshi KIHIRA

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

Reply via email to