iscsi-target: Update for newer kernels
authorTom Rini <tom_rini@mentor.com>
Mon, 17 Jan 2011 15:20:02 +0000 (08:20 -0700)
committerTom Rini <tom_rini@mentor.com>
Mon, 17 Jan 2011 15:22:45 +0000 (08:22 -0700)
Bring in some patches from upstream that make this compile when using
2.6.37.

Signed-off-by: Tom Rini <tom_rini@mentor.com>
recipes/iscsi-target/iscsi-target-svnr373.patch [new file with mode: 0644]
recipes/iscsi-target/iscsi-target/2.6.37-compat.patch [new file with mode: 0644]
recipes/iscsi-target/iscsi-target_1.4.20.2.bb

diff --git a/recipes/iscsi-target/iscsi-target-svnr373.patch b/recipes/iscsi-target/iscsi-target-svnr373.patch
new file mode 100644 (file)
index 0000000..f1ec506
--- /dev/null
@@ -0,0 +1,47 @@
+Index: trunk/kernel/conn.c
+===================================================================
+--- trunk/kernel/conn.c        (revision 372)
++++ trunk/kernel/conn.c        (revision 373)
+@@ -44,7 +44,7 @@
+               switch (sk->sk_family) {
+               case AF_INET:
+                       snprintf(buf, sizeof(buf),
+-                               "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->inet_daddr));
++                               "%pI4", inet_sk(sk)->inet_daddr);
+                       break;
+               case AF_INET6:
+                       snprintf(buf, sizeof(buf), "[%pI6]",
+Index: trunk/patches/compat-2.6.33-2.6.35.patch
+===================================================================
+--- trunk/patches/compat-2.6.33-2.6.35.patch   (revision 0)
++++ trunk/patches/compat-2.6.33-2.6.35.patch   (revision 373)
+@@ -0,0 +1,13 @@
++diff --git b/kernel/conn.c a/kernel/conn.c
++index c7b8ea1..ec6dada 100644
++--- b/kernel/conn.c
+++++ a/kernel/conn.c
++@@ -44,7 +44,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
++              switch (sk->sk_family) {
++              case AF_INET:
++                      snprintf(buf, sizeof(buf),
++-                              "%pI4", inet_sk(sk)->inet_daddr);
+++                              "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->inet_daddr));
++                      break;
++              case AF_INET6:
++                      snprintf(buf, sizeof(buf), "[%pI6]",
+Index: trunk/Makefile
+===================================================================
+--- trunk/Makefile     (revision 372)
++++ trunk/Makefile     (revision 373)
+@@ -56,6 +56,11 @@
+ # base first the earlier patch sets will not need to be modified.
+ #
++# Compatibility patch for kernels > 2.6.32 <= 2.6.35
++ifeq ($(call kver_le,2,6,35),1)
++      PATCHES := $(PATCHES) compat-2.6.33-2.6.35.patch
++endif
++
+ # Compatibility patch for kernels <= 2.6.32
+ ifeq ($(call kver_le,2,6,32),1)
+       PATCHES := $(PATCHES) compat-2.6.32.patch
diff --git a/recipes/iscsi-target/iscsi-target/2.6.37-compat.patch b/recipes/iscsi-target/iscsi-target/2.6.37-compat.patch
new file mode 100644 (file)
index 0000000..3957369
--- /dev/null
@@ -0,0 +1,385 @@
+http://old.nabble.com/Re:-Issues-compiling-kernel-module-against-current-2.6.37-git-p30440129.html
+
+---
+ Makefile                    |    5 ++
+ kernel/config.c             |   10 ++---
+ kernel/iscsi.h              |    5 --
+ kernel/target.c             |   34 ++++++++++---------
+ kernel/volume.c             |    1 
+ kernel/wthread.c            |   20 -----------
+ patches/compat-2.6.36.patch |   78 ++++++++++++++++++++++++++++++++++++++++++++
+ 7 files changed, 108 insertions(+), 45 deletions(-)
+
+Index: iscsitarget-1.4.20.2/Makefile
+===================================================================
+--- iscsitarget-1.4.20.2.orig/Makefile
++++ iscsitarget-1.4.20.2/Makefile
+@@ -55,6 +55,11 @@ kver_lk = $(shell [ `echo $(KVER) | egre
+ #
+ # Compatibility patch for kernels <= 2.6.32
++ifeq ($(call kver_le,2,6,36),1)
++      PATCHES := $(PATCHES) compat-2.6.36.patch
++endif
++
++# Compatibility patch for kernels > 2.6.32 <= 2.6.35
+ ifeq ($(call kver_le,2,6,32),1)
+       PATCHES := $(PATCHES) compat-2.6.32.patch
+ endif
+Index: iscsitarget-1.4.20.2/kernel/config.c
+===================================================================
+--- iscsitarget-1.4.20.2.orig/kernel/config.c
++++ iscsitarget-1.4.20.2/kernel/config.c
+@@ -9,7 +9,7 @@
+ #include "iscsi.h"
+ #include "iscsi_dbg.h"
+-static DECLARE_MUTEX(ioctl_sem);
++static DEFINE_MUTEX(ioctl_mutex);
+ struct proc_entries {
+       const char *name;
+@@ -258,7 +258,7 @@ static long ioctl(struct file *file, uns
+       long err;
+       u32 id;
+-      err = down_interruptible(&ioctl_sem);
++      err = mutex_lock_interruptible(&ioctl_mutex);
+       if (err < 0)
+               return err;
+@@ -339,7 +339,7 @@ static long ioctl(struct file *file, uns
+       target_unlock(target);
+ done:
+-      up(&ioctl_sem);
++      mutex_unlock(&ioctl_mutex);
+       return err;
+ }
+@@ -347,9 +347,9 @@ done:
+ static int release(struct inode *i __attribute__((unused)),
+                  struct file *f __attribute__((unused)))
+ {
+-      down(&ioctl_sem);
++      mutex_lock(&ioctl_mutex);
+       target_del_all();
+-      up(&ioctl_sem);
++      mutex_unlock(&ioctl_mutex);
+       return 0;
+ }
+Index: iscsitarget-1.4.20.2/kernel/iscsi.h
+===================================================================
+--- iscsitarget-1.4.20.2.orig/kernel/iscsi.h
++++ iscsitarget-1.4.20.2/kernel/iscsi.h
+@@ -8,7 +8,6 @@
+ #ifndef __ISCSI_H__
+ #define __ISCSI_H__
+-#include <linux/blkdev.h>
+ #include <linux/completion.h>
+ #include <linux/pagemap.h>
+ #include <linux/seq_file.h>
+@@ -94,8 +93,6 @@ struct worker_thread_info {
+       struct list_head work_queue;
+       wait_queue_head_t wthread_sleep;
+-
+-      struct io_context *wthread_ioc;
+ };
+ struct iscsi_cmnd;
+@@ -130,7 +127,7 @@ struct iscsi_target {
+       /* Points either to own list or global pool */
+       struct worker_thread_info * wthread_info;
+-      struct semaphore target_sem;
++      struct mutex target_mutex;
+ };
+ struct iscsi_queue {
+Index: iscsitarget-1.4.20.2/kernel/target.c
+===================================================================
+--- iscsitarget-1.4.20.2.orig/kernel/target.c
++++ iscsitarget-1.4.20.2/kernel/target.c
+@@ -4,6 +4,8 @@
+  * Released under the terms of the GNU GPL v2.0.
+  */
++#include <linux/mutex.h>
++
+ #include "iscsi.h"
+ #include "digest.h"
+ #include "iscsi_dbg.h"
+@@ -11,7 +13,7 @@
+ #define       MAX_NR_TARGETS  (1UL << 30)
+ static LIST_HEAD(target_list);
+-static DECLARE_MUTEX(target_list_sem);
++static DEFINE_MUTEX(target_list_mutex);
+ static u32 next_target_id;
+ static u32 nr_targets;
+@@ -48,16 +50,16 @@ inline int target_lock(struct iscsi_targ
+       int err = 0;
+       if (interruptible)
+-              err = down_interruptible(&target->target_sem);
++              err = mutex_lock_interruptible(&target->target_mutex);
+       else
+-              down(&target->target_sem);
++              mutex_lock(&target->target_mutex);
+       return err;
+ }
+ inline void target_unlock(struct iscsi_target *target)
+ {
+-      up(&target->target_sem);
++      mutex_unlock(&target->target_mutex);
+ }
+ static struct iscsi_target *__target_lookup_by_id(u32 id)
+@@ -86,9 +88,9 @@ struct iscsi_target *target_lookup_by_id
+ {
+       struct iscsi_target *target;
+-      down(&target_list_sem);
++      mutex_lock(&target_list_mutex);
+       target = __target_lookup_by_id(id);
+-      up(&target_list_sem);
++      mutex_unlock(&target_list_mutex);
+       return target;
+ }
+@@ -157,7 +159,7 @@ static int iscsi_target_create(struct ta
+       strncpy(target->name, name, sizeof(target->name) - 1);
+-      init_MUTEX(&target->target_sem);
++      mutex_init(&target->target_mutex);
+       spin_lock_init(&target->session_list_lock);
+       INIT_LIST_HEAD(&target->session_list);
+@@ -195,7 +197,7 @@ int target_add(struct target_info *info)
+       u32 tid = info->tid;
+       int err;
+-      err = down_interruptible(&target_list_sem);
++      err = mutex_lock_interruptible(&target_list_mutex);
+       if (err < 0)
+               return err;
+@@ -223,7 +225,7 @@ int target_add(struct target_info *info)
+       if (!err)
+               nr_targets++;
+ out:
+-      up(&target_list_sem);
++      mutex_unlock(&target_list_mutex);
+       return err;
+ }
+@@ -248,7 +250,7 @@ static void target_destroy(struct iscsi_
+       module_put(THIS_MODULE);
+ }
+-/* @locking: target_list_sem must be locked */
++/* @locking: target_list_mutex must be locked */
+ static int __target_del(struct iscsi_target *target)
+ {
+       int err;
+@@ -283,7 +285,7 @@ int target_del(u32 id)
+       struct iscsi_target *target;
+       int err;
+-      err = down_interruptible(&target_list_sem);
++      err = mutex_lock_interruptible(&target_list_mutex);
+       if (err < 0)
+               return err;
+@@ -295,7 +297,7 @@ int target_del(u32 id)
+       err = __target_del(target);
+ out:
+-      up(&target_list_sem);
++      mutex_unlock(&target_list_mutex);
+       return err;
+ }
+@@ -305,7 +307,7 @@ void target_del_all(void)
+       struct iscsi_target *target, *tmp;
+       int err;
+-      down(&target_list_sem);
++      mutex_lock(&target_list_mutex);
+       if (!list_empty(&target_list))
+               iprintk("Removing all connections, sessions and targets\n");
+@@ -319,7 +321,7 @@ void target_del_all(void)
+       next_target_id = 0;
+-      up(&target_list_sem);
++      mutex_unlock(&target_list_mutex);
+ }
+ static void *iet_seq_start(struct seq_file *m, loff_t *pos)
+@@ -327,7 +329,7 @@ static void *iet_seq_start(struct seq_fi
+       int err;
+       /* are you sure this is to be interruptible? */
+-      err = down_interruptible(&target_list_sem);
++      err = mutex_lock_interruptible(&target_list_mutex);
+       if (err < 0)
+               return ERR_PTR(err);
+@@ -341,7 +343,7 @@ static void *iet_seq_next(struct seq_fil
+ static void iet_seq_stop(struct seq_file *m, void *v)
+ {
+-      up(&target_list_sem);
++      mutex_unlock(&target_list_mutex);
+ }
+ static int iet_seq_show(struct seq_file *m, void *p)
+Index: iscsitarget-1.4.20.2/kernel/volume.c
+===================================================================
+--- iscsitarget-1.4.20.2.orig/kernel/volume.c
++++ iscsitarget-1.4.20.2/kernel/volume.c
+@@ -6,6 +6,7 @@
+ #include <linux/types.h>
+ #include <linux/parser.h>
++#include <linux/blkdev.h>
+ #include "iscsi.h"
+ #include "iscsi_dbg.h"
+Index: iscsitarget-1.4.20.2/kernel/wthread.c
+===================================================================
+--- iscsitarget-1.4.20.2.orig/kernel/wthread.c
++++ iscsitarget-1.4.20.2/kernel/wthread.c
+@@ -67,15 +67,6 @@ static int worker_thread(void *arg)
+       struct iscsi_conn *conn;
+       DECLARE_WAITQUEUE(wait, current);
+-      get_io_context(GFP_KERNEL, -1);
+-
+-      if (!current->io_context)
+-              eprintk("%s\n", "Failed to get IO context");
+-      else if (info->wthread_ioc)
+-              copy_io_context(&current->io_context, &info->wthread_ioc);
+-      else
+-              info->wthread_ioc = current->io_context;
+-
+       add_wait_queue(&info->wthread_sleep, &wait);
+       __set_current_state(TASK_RUNNING);
+@@ -100,16 +91,6 @@ static int worker_thread(void *arg)
+       remove_wait_queue(&info->wthread_sleep, &wait);
+-      if (current->io_context) {
+-              struct io_context *ioc = current->io_context;
+-
+-              task_lock(current);
+-              current->io_context = NULL;
+-              task_unlock(current);
+-
+-              put_io_context(ioc);
+-      }
+-
+       return 0;
+ }
+@@ -160,7 +141,6 @@ int wthread_init(struct worker_thread_in
+       spin_lock_init(&info->wthread_lock);
+       info->nr_running_wthreads = 0;
+-      info->wthread_ioc = NULL;
+       INIT_LIST_HEAD(&info->work_queue);
+       INIT_LIST_HEAD(&info->wthread_list);
+Index: iscsitarget-1.4.20.2/patches/compat-2.6.36.patch
+===================================================================
+--- /dev/null
++++ iscsitarget-1.4.20.2/patches/compat-2.6.36.patch
+@@ -0,0 +1,78 @@
++diff --git a/kernel/iscsi.h b/kernel/iscsi.h
++index f9076f2..da0cdfd 100644
++--- a/kernel/iscsi.h
+++++ b/kernel/iscsi.h
++@@ -8,6 +8,7 @@
++ #ifndef __ISCSI_H__
++ #define __ISCSI_H__
++
+++#include <linux/blkdev.h>
++ #include <linux/completion.h>
++ #include <linux/pagemap.h>
++ #include <linux/seq_file.h>
++@@ -93,6 +94,8 @@ struct worker_thread_info {
++ struct list_head work_queue;
++
++ wait_queue_head_t wthread_sleep;
+++
+++     struct io_context *wthread_ioc;
++ };
++
++ struct iscsi_cmnd;
++diff --git a/kernel/volume.c b/kernel/volume.c
++index ecffa21..2c9a698 100644
++--- a/kernel/volume.c
+++++ b/kernel/volume.c
++@@ -6,7 +6,6 @@
++
++ #include <linux/types.h>
++ #include <linux/parser.h>
++-#include <linux/blkdev.h>
++
++ #include "iscsi.h"
++ #include "iscsi_dbg.h"
++diff --git a/kernel/wthread.c b/kernel/wthread.c
++index 884c03a..997a3d6 100644
++--- a/kernel/wthread.c
+++++ b/kernel/wthread.c
++@@ -67,6 +67,15 @@ static int worker_thread(void *arg)
++ struct iscsi_conn *conn;
++ DECLARE_WAITQUEUE(wait, current);
++
+++     get_io_context(GFP_KERNEL, -1);
+++
+++     if (!current->io_context)
+++      eprintk("%s\n", "Failed to get IO context");
+++     else if (info->wthread_ioc)
+++      copy_io_context(¤t->io_context, &info->wthread_ioc);
+++     else
+++      info->wthread_ioc = current->io_context;
+++
++ add_wait_queue(&info->wthread_sleep, &wait);
++
++ __set_current_state(TASK_RUNNING);
++@@ -91,6 +100,16 @@ static int worker_thread(void *arg)
++
++ remove_wait_queue(&info->wthread_sleep, &wait);
++
+++     if (current->io_context) {
+++      struct io_context *ioc = current->io_context;
+++
+++      task_lock(current);
+++      current->io_context = NULL;
+++      task_unlock(current);
+++
+++      put_io_context(ioc);
+++     }
+++
++ return 0;
++ }
++
++@@ -141,6 +160,7 @@ int wthread_init(struct worker_thread_info *info)
++ spin_lock_init(&info->wthread_lock);
++
++ info->nr_running_wthreads = 0;
+++     info->wthread_ioc = NULL;
++
++ INIT_LIST_HEAD(&info->work_queue);
++ INIT_LIST_HEAD(&info->wthread_list);
index db85aba..1a02a65 100644 (file)
@@ -3,7 +3,7 @@ HOMEPAGE = "http://iscsitarget.sourceforge.net/"
 LICENSE = "GPL"
 DEPENDS = "openssl"
 RRECOMMENDS_${PN} = "kernel-module-crc32c kernel-module-libcrc32c"
-PR = "r0"
+PR = "r1"
 
 # this recipe has a DEFAULT_PREFERENCE -1 for beagleboard 
 # actually this probably is only needed for angstrom and minimal
@@ -20,6 +20,8 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/iscsitarget/iscsitarget-${PV}.tar.gz \
            file://ietd.conf \
            file://init \
            file://Makefile.patch \
+           file://iscsi-target-svnr373.patch \
+           file://2.6.37-compat.patch \
            "
 SRC_URI[md5sum] = "2f23c0bfe124d79f5c20e34ef2aaff82"
 SRC_URI[sha256sum] = "0f3c8e2c2038fbbd7059d1efdd428260013212daca75c1d56abbeec33cb8d388"