FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Kernel Team

 
 
LinkBack Thread Tools
 
Old 06-22-2011, 08:51 AM
Stefan Bader
 
Default UBUNTU: SAUCE: iscsitarget: Remove driver from the kernel

This driver is not boot/install essential and is provided by the
iscsitarget-dkms package. Having it in the kernel itself only
duplicates code and adds a chance of getting out of sync.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
debian.master/config/config.common.ubuntu | 1 -
ubuntu/Kconfig | 4 -
ubuntu/Makefile | 4 -
ubuntu/iscsitarget/BOM | 2 -
ubuntu/iscsitarget/Kconfig | 3 -
ubuntu/iscsitarget/Makefile | 17 -
ubuntu/iscsitarget/block-io.c | 327 -----
ubuntu/iscsitarget/compat.h | 30 -
ubuntu/iscsitarget/config.c | 362 ------
ubuntu/iscsitarget/conn.c | 262 ----
ubuntu/iscsitarget/digest.c | 279 ----
ubuntu/iscsitarget/digest.h | 20 -
ubuntu/iscsitarget/event.c | 96 --
ubuntu/iscsitarget/file-io.c | 261 ----
ubuntu/iscsitarget/include/iet_u.h | 151 ---
ubuntu/iscsitarget/iotype.c | 110 --
ubuntu/iscsitarget/iotype.h | 42 -
ubuntu/iscsitarget/iscsi.c | 1967 -----------------------------
ubuntu/iscsitarget/iscsi.h | 524 --------
ubuntu/iscsitarget/iscsi_dbg.h | 137 --
ubuntu/iscsitarget/iscsi_hdr.h | 509 --------
ubuntu/iscsitarget/nthread.c | 790 ------------
ubuntu/iscsitarget/null-io.c | 98 --
ubuntu/iscsitarget/param.c | 205 ---
ubuntu/iscsitarget/session.c | 180 ---
ubuntu/iscsitarget/target.c | 374 ------
ubuntu/iscsitarget/target_disk.c | 589 ---------
ubuntu/iscsitarget/tio.c | 121 --
ubuntu/iscsitarget/ua.c | 176 ---
ubuntu/iscsitarget/volume.c | 422 ------
ubuntu/iscsitarget/wthread.c | 258 ----
31 files changed, 0 insertions(+), 8321 deletions(-)
delete mode 100644 ubuntu/iscsitarget/BOM
delete mode 100644 ubuntu/iscsitarget/Kconfig
delete mode 100644 ubuntu/iscsitarget/Makefile
delete mode 100644 ubuntu/iscsitarget/block-io.c
delete mode 100644 ubuntu/iscsitarget/compat.h
delete mode 100644 ubuntu/iscsitarget/config.c
delete mode 100644 ubuntu/iscsitarget/conn.c
delete mode 100644 ubuntu/iscsitarget/digest.c
delete mode 100644 ubuntu/iscsitarget/digest.h
delete mode 100644 ubuntu/iscsitarget/event.c
delete mode 100644 ubuntu/iscsitarget/file-io.c
delete mode 100644 ubuntu/iscsitarget/include/iet_u.h
delete mode 100644 ubuntu/iscsitarget/iotype.c
delete mode 100644 ubuntu/iscsitarget/iotype.h
delete mode 100644 ubuntu/iscsitarget/iscsi.c
delete mode 100644 ubuntu/iscsitarget/iscsi.h
delete mode 100644 ubuntu/iscsitarget/iscsi_dbg.h
delete mode 100644 ubuntu/iscsitarget/iscsi_hdr.h
delete mode 100644 ubuntu/iscsitarget/nthread.c
delete mode 100644 ubuntu/iscsitarget/null-io.c
delete mode 100644 ubuntu/iscsitarget/param.c
delete mode 100644 ubuntu/iscsitarget/session.c
delete mode 100644 ubuntu/iscsitarget/target.c
delete mode 100644 ubuntu/iscsitarget/target_disk.c
delete mode 100644 ubuntu/iscsitarget/tio.c
delete mode 100644 ubuntu/iscsitarget/ua.c
delete mode 100644 ubuntu/iscsitarget/volume.c
delete mode 100644 ubuntu/iscsitarget/wthread.c

diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index 202ef91..7f30751 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -4156,7 +4156,6 @@ CONFIG_SCSI_IN2000=m
CONFIG_SCSI_INIA100=m
CONFIG_SCSI_INITIO=m
CONFIG_SCSI_IPS=m
-# CONFIG_SCSI_ISCSITARGET is not set
CONFIG_SCSI_ISCSI_ATTRS=m
# CONFIG_SCSI_IZIP_EPP16 is not set
# CONFIG_SCSI_IZIP_SLOW_CTR is not set
diff --git a/ubuntu/Kconfig b/ubuntu/Kconfig
index 443457e..0159dd3 100644
--- a/ubuntu/Kconfig
+++ b/ubuntu/Kconfig
@@ -34,10 +34,6 @@ source "ubuntu/omnibook/Kconfig"
##
##
##
-source "ubuntu/iscsitarget/Kconfig"
-##
-##
-##
source "ubuntu/rtl8192se/Kconfig"
##
##
diff --git a/ubuntu/Makefile b/ubuntu/Makefile
index 43b53d1..f71a0d5 100644
--- a/ubuntu/Makefile
+++ b/ubuntu/Makefile
@@ -36,10 +36,6 @@ obj-$(CONFIG_NDISWRAPPER) += ndiswrapper/
##
##
##
-obj-$(CONFIG_SCSI_ISCSITARGET) += iscsitarget/
-##
-##
-##
obj-$(CONFIG_RTL8192SE) += rtl8192se/
##
##
diff --git a/ubuntu/iscsitarget/BOM b/ubuntu/iscsitarget/BOM
deleted file mode 100644
index 40751ae..0000000
--- a/ubuntu/iscsitarget/BOM
+++ /dev/null
@@ -1,2 +0,0 @@
-Downloaded from: http://sourceforge.net/projects/iscsitarget/files/
-Current Version: 1.4.20.2
diff --git a/ubuntu/iscsitarget/Kconfig b/ubuntu/iscsitarget/Kconfig
deleted file mode 100644
index e5964dc..0000000
--- a/ubuntu/iscsitarget/Kconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-config SCSI_ISCSITARGET
- tristate "iSCSI Target Driver"
- depends on SCSI
diff --git a/ubuntu/iscsitarget/Makefile b/ubuntu/iscsitarget/Makefile
deleted file mode 100644
index 727c706..0000000
--- a/ubuntu/iscsitarget/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Makefile for the Linux kernel device drivers.
-#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-EXTRA_CFLAGS += -I$(src)/include
-
-obj-m += iscsi_trgt.o
-iscsi_trgt-objs := tio.o iscsi.o nthread.o wthread.o config.o digest.o
- conn.o session.o target.o volume.o iotype.o
- file-io.o null-io.o target_disk.o event.o param.o
- block-io.o ua.o
-
diff --git a/ubuntu/iscsitarget/block-io.c b/ubuntu/iscsitarget/block-io.c
deleted file mode 100644
index 3e7de38..0000000
--- a/ubuntu/iscsitarget/block-io.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Target device block I/O.
- *
- * Based on file I/O driver from FUJITA Tomonori
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * (C) 2006 Andre Brinkmann <brinkman at hni dot upb dot de>
- * (C) 2007 Ross Walker <rswwalker at hotmail dot com>
- * (C) 2007 Ming Zhang <blackmagic02881 at gmail dot com>
- * This code is licenced under the GPL.
- */
-
-#include <linux/types.h>
-#include <linux/blkdev.h>
-#include <linux/parser.h>
-#include <linux/buffer_head.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-struct blockio_data {
- char *path;
- struct block_device *bdev;
-};
-
-struct tio_work {
- atomic_t error;
- atomic_t bios_remaining;
- struct completion tio_complete;
-};
-
-static void blockio_bio_endio(struct bio *bio, int error)
-{
- struct tio_work *tio_work = bio->bi_private;
-
- error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;
-
- if (error)
- atomic_set(&tio_work->error, error);
-
- /* If last bio signal completion */
- if (atomic_dec_and_test(&tio_work->bios_remaining))
- complete(&tio_work->tio_complete);
-
- bio_put(bio);
-}
-
-/*
- * Blockio_make_request(): The function translates an iscsi-request into
- * a number of requests to the corresponding block device.
- */
-static int
-blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
-{
- struct blockio_data *bio_data = volume->private;
- struct request_queue *bdev_q = bdev_get_queue(bio_data->bdev);
- struct tio_work *tio_work;
- struct bio *tio_bio = NULL, *bio = NULL, *biotail = NULL;
-
- u32 offset = tio->offset;
- u32 size = tio->size;
- u32 tio_index = 0;
-
- int max_pages = 1;
- int err = 0;
-
- loff_t ppos = ((loff_t) tio->idx << PAGE_SHIFT) + offset;
-
- /* Calculate max_pages for bio_alloc (memory saver) */
- if (bdev_q)
- max_pages = bio_get_nr_vecs(bio_data->bdev);
-
- tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL);
- if (!tio_work)
- return -ENOMEM;
-
- atomic_set(&tio_work->error, 0);
- atomic_set(&tio_work->bios_remaining, 0);
- init_completion(&tio_work->tio_complete);
-
- /* Main processing loop, allocate and fill all bios */
- while (tio_index < tio->pg_cnt) {
- bio = bio_alloc(GFP_KERNEL, min(max_pages, BIO_MAX_PAGES));
- if (!bio) {
- err = -ENOMEM;
- goto out;
- }
-
- /* bi_sector is ALWAYS in units of 512 bytes */
- bio->bi_sector = ppos >> 9;
- bio->bi_bdev = bio_data->bdev;
- bio->bi_end_io = blockio_bio_endio;
- bio->bi_private = tio_work;
-
- if (tio_bio)
- biotail = biotail->bi_next = bio;
- else
- tio_bio = biotail = bio;
-
- atomic_inc(&tio_work->bios_remaining);
-
- /* Loop for filling bio */
- while (tio_index < tio->pg_cnt) {
- unsigned int bytes = PAGE_SIZE - offset;
-
- if (bytes > size)
- bytes = size;
-
- if (!bio_add_page(bio, tio->pvec[tio_index], bytes, offset))
- break;
-
- size -= bytes;
- ppos += bytes;
-
- offset = 0;
-
- tio_index++;
- }
- }
-
- /* Walk the list, submitting bios 1 by 1 */
- while (tio_bio) {
- bio = tio_bio;
- tio_bio = tio_bio->bi_next;
- bio->bi_next = NULL;
-
- submit_bio(rw, bio);
- }
-
- if (bdev_q && bdev_q->unplug_fn)
- bdev_q->unplug_fn(bdev_q);
-
- wait_for_completion(&tio_work->tio_complete);
-
- err = atomic_read(&tio_work->error);
-
- kfree(tio_work);
-
- return err;
-out:
- while (tio_bio) {
- bio = tio_bio;
- tio_bio = tio_bio->bi_next;
-
- bio_put(bio);
- }
-
- kfree(tio_work);
-
- return err;
-}
-
-static int
-blockio_open_path(struct iet_volume *volume, const char *path)
-{
- struct blockio_data *bio_data = volume->private;
- struct block_device *bdev;
- int flags = FMODE_READ | (LUReadonly(volume) ? 0 : FMODE_WRITE);
- int err = 0;
-
- bio_data->path = kstrdup(path, GFP_KERNEL);
- if (!bio_data->path)
- return -ENOMEM;
-
- bdev = blkdev_get_by_path(path, flags | FMODE_EXCL, THIS_MODULE);
- if (IS_ERR(bdev)) {
- err = PTR_ERR(bdev);
- eprintk("Can't open device %s, error %d
", path, err);
- bio_data->bdev = NULL;
- } else {
- bio_data->bdev = bdev;
- fsync_bdev(bio_data->bdev);
- }
-
- return err;
-}
-
-/* Create an enumeration of our accepted actions */
-enum
-{
- opt_path, opt_ignore, opt_err,
-};
-
-/* Create a match table using our action enums and their matching options */
-static match_table_t tokens = {
- {opt_path, "path=%s"},
- {opt_ignore, "scsiid=%s"},
- {opt_ignore, "scsisn=%s"},
- {opt_ignore, "type=%s"},
- {opt_ignore, "iomode=%s"},
- {opt_ignore, "blocksize=%s"},
- {opt_err, NULL},
-};
-
-static int
-parse_blockio_params(struct iet_volume *volume, char *params)
-{
- struct blockio_data *info = volume->private;
- int err = 0;
- char *p, *q;
-
- /* Loop through parameters separated by commas, look up our
- * parameter in match table, return enumeration and arguments
- * select case based on the returned enum and run the action */
- while ((p = strsep(&params, ",")) != NULL) {
- substring_t args[MAX_OPT_ARGS];
- int token;
- if (!*p)
- continue;
- iet_strtolower(p);
- token = match_token(p, tokens, args);
- switch (token) {
- case opt_path:
- if (info->path) {
- iprintk("Target %s, LUN %u: "
- "duplicate "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- goto out;
- }
- if (!(q = match_strdup(&args[0]))) {
- err = -ENOMEM;
- goto out;
- }
- err = blockio_open_path(volume, q);
- kfree(q);
- if (err < 0)
- goto out;
- break;
- case opt_ignore:
- break;
- default:
- iprintk("Target %s, LUN %u: unknown param %s
",
- volume->target->name, volume->lun, p);
- return -EINVAL;
- }
- }
-
- if (!info->path) {
- iprintk("Target %s, LUN %u: missing "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- }
-
- out:
- return err;
-}
-
-static void
-blockio_detach(struct iet_volume *volume)
-{
- struct blockio_data *bio_data = volume->private;
- int flags = FMODE_READ | (LUReadonly(volume) ? 0 : FMODE_WRITE);
-
- if (bio_data->bdev)
- blkdev_put(bio_data->bdev, flags | FMODE_EXCL);
- kfree(bio_data->path);
-
- kfree(volume->private);
-}
-
-static int
-blockio_attach(struct iet_volume *volume, char *args)
-{
- struct blockio_data *bio_data;
- int err = 0;
-
- if (volume->private) {
- eprintk("Lun %u already attached on Target %s
",
- volume->lun, volume->target->name);
- return -EBUSY;
- }
-
- bio_data = kzalloc(sizeof (*bio_data), GFP_KERNEL);
- if (!bio_data)
- return -ENOMEM;
-
- volume->private = bio_data;
-
- err = parse_blockio_params(volume, args);
- if (!err) {
- /* see Documentation/ABI/testing/sysfs-block */
- unsigned bsz = bdev_logical_block_size(bio_data->bdev);
- if (!volume->blk_shift)
- volume->blk_shift = blksize_bits(bsz);
- else if (volume->blk_shift < blksize_bits(bsz)) {
- eprintk("Specified block size (%u) smaller than "
- "device %s logical block size (%u)
",
- (1 << volume->blk_shift), bio_data->path, bsz);
- err = -EINVAL;
- }
- }
- if (err < 0) {
- eprintk("Error attaching Lun %u to Target %s
",
- volume->lun, volume->target->name);
- goto out;
- }
-
- volume->blk_cnt = bio_data->bdev->bd_inode->i_size >> volume->blk_shift;
-
- /* Offer neither write nor read caching */
- ClearLURCache(volume);
- ClearLUWCache(volume);
-
- out:
- if (err < 0)
- blockio_detach(volume);
-
- return err;
-}
-
-static void
-blockio_show(struct iet_volume *volume, struct seq_file *seq)
-{
- struct blockio_data *bio_data = volume->private;
-
- /* Used to display blockio volume info in /proc/net/iet/volumes */
- seq_printf(seq, " path:%s
", bio_data->path);
-}
-
-struct iotype blockio = {
- .name = "blockio",
- .attach = blockio_attach,
- .make_request = blockio_make_request,
- .detach = blockio_detach,
- .show = blockio_show,
-};
diff --git a/ubuntu/iscsitarget/compat.h b/ubuntu/iscsitarget/compat.h
deleted file mode 100644
index 631a49c..0000000
--- a/ubuntu/iscsitarget/compat.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Kernel compatibility routines
- *
- * Copyright (C) 2008 Ross Walker <rswwalker at gmail dot com>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#ifndef __IET_COMPAT_H__
-#define __IET_COMPAT_H__
-
-#include <linux/version.h>
-
-#ifndef DECLARE_COMPLETION_ONSTACK
-#define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
-#endif
-
-#ifndef is_power_of_2
-#define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
-#endif
-
-#ifndef log2
-#define log2(n) ((sizeof(n) <= 4) ? (fls(n) - 1) : (fls64(n) - 1))
-#endif
-
-#ifndef roundup_pow_of_two
-#define roundup_pow_of_two(n) (1UL << fls_long(n - 1))
-#endif
-
-#endif /* __IET_COMPAT_H__ */
diff --git a/ubuntu/iscsitarget/config.c b/ubuntu/iscsitarget/config.c
deleted file mode 100644
index 2146504..0000000
--- a/ubuntu/iscsitarget/config.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- *
- * This code is licenced under the GPL.
- */
-
-#include <linux/proc_fs.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-
-static DEFINE_SEMAPHORE(ioctl_sem);
-
-struct proc_entries {
- const char *name;
- struct file_operations *fops;
-};
-
-static struct proc_entries iet_proc_entries[] =
-{
- {"volume", &volume_seq_fops},
- {"session", &session_seq_fops},
-};
-
-static struct proc_dir_entry *proc_iet_dir;
-
-void iet_procfs_exit(void)
-{
- int i;
-
- if (!proc_iet_dir)
- return;
-
- for (i = 0; i < ARRAY_SIZE(iet_proc_entries); i++)
- remove_proc_entry(iet_proc_entries[i].name, proc_iet_dir);
-
- remove_proc_entry(proc_iet_dir->name, proc_iet_dir->parent);
-}
-
-int iet_procfs_init(void)
-{
- int i;
- struct proc_dir_entry *ent;
-
- if (!(proc_iet_dir = proc_mkdir("iet", init_net.proc_net)))
- goto err;
-
- for (i = 0; i < ARRAY_SIZE(iet_proc_entries); i++) {
- ent = create_proc_entry(iet_proc_entries[i].name, 0, proc_iet_dir);
- if (ent)
- ent->proc_fops = iet_proc_entries[i].fops;
- else
- goto err;
- }
-
- return 0;
-
-err:
- if (proc_iet_dir)
- iet_procfs_exit();
-
- return -ENOMEM;
-}
-
-static int get_module_info(unsigned long ptr)
-{
- struct module_info info;
- int err;
-
- snprintf(info.version, sizeof(info.version), "%s", IET_VERSION_STRING);
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int get_conn_info(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct iscsi_conn *conn;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- conn = conn_lookup(session, info.cid);
- if (!conn)
- return -ENOENT;
-
- info.cid = conn->cid;
- info.stat_sn = conn->stat_sn;
- info.exp_stat_sn = conn->exp_stat_sn;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_conn(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- return conn_add(session, &info);
-}
-
-static int del_conn(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- return conn_del(session, &info);
-}
-
-static int get_session_info(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- info.exp_cmd_sn = session->exp_cmd_sn;
- info.max_cmd_sn = session->max_cmd_sn;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_session(struct iscsi_target *target, unsigned long ptr)
-{
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return session_add(target, &info);
-}
-
-static int del_session(struct iscsi_target *target, unsigned long ptr)
-{
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return session_del(target, info.sid);
-}
-
-static int add_volume(struct iscsi_target *target, unsigned long ptr)
-{
- struct volume_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return volume_add(target, &info);
-}
-
-static int del_volume(struct iscsi_target *target, unsigned long ptr)
-{
- struct volume_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return iscsi_volume_del(target, &info);
-}
-
-static int iscsi_param_config(struct iscsi_target *target, unsigned long ptr, int set)
-{
- struct iscsi_param_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- err = iscsi_param_set(target, &info, set);
- if (err < 0 || set)
- return err;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_target(unsigned long ptr)
-{
- struct target_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- err = target_add(&info);
- if (err < 0)
- return err;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static long ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct iscsi_target *target = NULL;
- long err;
- u32 id;
-
- err = down_interruptible(&ioctl_sem);
- if (err < 0)
- return err;
-
- if (cmd == GET_MODULE_INFO) {
- err = get_module_info(arg);
- goto done;
- }
-
- if (cmd == ADD_TARGET) {
- err = add_target(arg);
- goto done;
- }
-
- err = get_user(id, (u32 *) arg);
- if (err < 0)
- goto done;
-
- /* locking handled in target_del */
- if (cmd == DEL_TARGET) {
- err = target_del(id);
- goto done;
- }
-
- target = target_lookup_by_id(id);
- if (!target) {
- err = -ENOENT;
- goto done;
- }
-
- err = target_lock(target, 1);
- if (err < 0)
- goto done;
-
- switch (cmd) {
- case ADD_VOLUME:
- err = add_volume(target, arg);
- break;
-
- case DEL_VOLUME:
- err = del_volume(target, arg);
- break;
-
- case ADD_SESSION:
- err = add_session(target, arg);
- break;
-
- case DEL_SESSION:
- err = del_session(target, arg);
- break;
-
- case GET_SESSION_INFO:
- err = get_session_info(target, arg);
- break;
-
- case ISCSI_PARAM_SET:
- err = iscsi_param_config(target, arg, 1);
- break;
-
- case ISCSI_PARAM_GET:
- err = iscsi_param_config(target, arg, 0);
- break;
-
- case ADD_CONN:
- err = add_conn(target, arg);
- break;
-
- case DEL_CONN:
- err = del_conn(target, arg);
- break;
-
- case GET_CONN_INFO:
- err = get_conn_info(target, arg);
- break;
- default:
- eprintk("invalid ioctl cmd %x
", cmd);
- err = -EINVAL;
- }
-
- target_unlock(target);
-done:
- up(&ioctl_sem);
-
- return err;
-}
-
-static int release(struct inode *i __attribute__((unused)),
- struct file *f __attribute__((unused)))
-{
- down(&ioctl_sem);
- target_del_all();
- up(&ioctl_sem);
-
- return 0;
-}
-
-struct file_operations ctr_fops = {
- .owner = THIS_MODULE,
- .unlocked_ioctl = ioctl,
- .compat_ioctl = ioctl,
- .release = release
-};
diff --git a/ubuntu/iscsitarget/conn.c b/ubuntu/iscsitarget/conn.c
deleted file mode 100644
index f2c98b7..0000000
--- a/ubuntu/iscsitarget/conn.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <linux/file.h>
-#include <linux/ip.h>
-#include <net/tcp.h>
-#include <scsi/scsi.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "digest.h"
-
-static void print_conn_state(char *p, size_t size, unsigned long state)
-{
- if (test_bit(CONN_ACTIVE, &state))
- snprintf(p, size, "%s", "active");
- else if (test_bit(CONN_CLOSING, &state))
- snprintf(p, size, "%s", "closing");
- else
- snprintf(p, size, "%s", "unknown");
-}
-
-static void print_digest_state(char *p, size_t size, unsigned long flags)
-{
- if (DIGEST_NONE & flags)
- snprintf(p, size, "%s", "none");
- else if (DIGEST_CRC32C & flags)
- snprintf(p, size, "%s", "crc32c");
- else
- snprintf(p, size, "%s", "unknown");
-}
-
-void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
-{
- struct iscsi_conn *conn;
- struct sock *sk;
- char buf[64];
-
- list_for_each_entry(conn, &session->conn_list, list) {
- sk = conn->sock->sk;
- switch (sk->sk_family) {
- case AF_INET:
- snprintf(buf, sizeof(buf),
- "%pI4", &inet_sk(sk)->inet_daddr);
- break;
- case AF_INET6:
- snprintf(buf, sizeof(buf), "[%pI6]",
- &inet6_sk(sk)->daddr);
- break;
- default:
- break;
- }
- seq_printf(seq, " cid:%u ip:%s ", conn->cid, buf);
- print_conn_state(buf, sizeof(buf), conn->state);
- seq_printf(seq, "state:%s ", buf);
- print_digest_state(buf, sizeof(buf), conn->hdigest_type);
- seq_printf(seq, "hd:%s ", buf);
- print_digest_state(buf, sizeof(buf), conn->ddigest_type);
- seq_printf(seq, "dd:%s
", buf);
- }
-}
-
-struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid)
-{
- struct iscsi_conn *conn;
-
- list_for_each_entry(conn, &session->conn_list, list) {
- if (conn->cid == cid)
- return conn;
- }
- return NULL;
-}
-
-static void iet_state_change(struct sock *sk)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct iscsi_target *target = conn->session->target;
-
- if (sk->sk_state != TCP_ESTABLISHED)
- conn_close(conn);
- else
- nthread_wakeup(target);
-
- target->nthread_info.old_state_change(sk);
-}
-
-static void iet_data_ready(struct sock *sk, int len)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct iscsi_target *target = conn->session->target;
-
- nthread_wakeup(target);
- target->nthread_info.old_data_ready(sk, len);
-}
-
-/*
- * @locking: grabs the target's nthread_lock to protect it from races with
- * set_conn_wspace_wait()
- */
-static void iet_write_space(struct sock *sk)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct network_thread_info *info = &conn->session->target->nthread_info;
-
- spin_lock_bh(&info->nthread_lock);
-
- if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
- test_bit(CONN_WSPACE_WAIT, &conn->state)) {
- clear_bit(CONN_WSPACE_WAIT, &conn->state);
- __nthread_wakeup(info);
- }
-
- spin_unlock_bh(&info->nthread_lock);
-
- info->old_write_space(sk);
-}
-
-static void iet_socket_bind(struct iscsi_conn *conn)
-{
- int opt = 1;
- mm_segment_t oldfs;
- struct iscsi_session *session = conn->session;
- struct iscsi_target *target = session->target;
-
- dprintk(D_GENERIC, "%llu
", (unsigned long long) session->sid);
-
- conn->sock = SOCKET_I(conn->file->f_dentry->d_inode);
- conn->sock->sk->sk_user_data = conn;
-
- write_lock_bh(&conn->sock->sk->sk_callback_lock);
- target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
- conn->sock->sk->sk_state_change = iet_state_change;
-
- target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
- conn->sock->sk->sk_data_ready = iet_data_ready;
-
- target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
- conn->sock->sk->sk_write_space = iet_write_space;
- write_unlock_bh(&conn->sock->sk->sk_callback_lock);
-
- oldfs = get_fs();
- set_fs(get_ds());
- conn->sock->ops->setsockopt(conn->sock, SOL_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt));
- set_fs(oldfs);
-}
-
-int conn_free(struct iscsi_conn *conn)
-{
- dprintk(D_GENERIC, "%p %#Lx %u
", conn->session,
- (unsigned long long) conn->session->sid, conn->cid);
-
- assert(atomic_read(&conn->nr_cmnds) == 0);
- assert(list_empty(&conn->pdu_list));
- assert(list_empty(&conn->write_list));
-
- list_del(&conn->list);
- list_del(&conn->poll_list);
-
- del_timer_sync(&conn->nop_timer);
- digest_cleanup(conn);
- kfree(conn);
-
- return 0;
-}
-
-static int iet_conn_alloc(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
-
- dprintk(D_SETUP, "%#Lx:%u
", (unsigned long long) session->sid, info->cid);
-
- conn = kzalloc(sizeof(*conn), GFP_KERNEL);
- if (!conn)
- return -ENOMEM;
-
- conn->session = session;
- conn->cid = info->cid;
- conn->stat_sn = info->stat_sn;
- conn->exp_stat_sn = info->exp_stat_sn;
-
- conn->hdigest_type = info->header_digest;
- conn->ddigest_type = info->data_digest;
- if (digest_init(conn) < 0) {
- kfree(conn);
- return -ENOMEM;
- }
-
- spin_lock_init(&conn->list_lock);
- atomic_set(&conn->nr_cmnds, 0);
- atomic_set(&conn->nr_busy_cmnds, 0);
- INIT_LIST_HEAD(&conn->pdu_list);
- INIT_LIST_HEAD(&conn->write_list);
- INIT_LIST_HEAD(&conn->poll_list);
- init_timer(&conn->nop_timer);
-
- list_add(&conn->list, &session->conn_list);
-
- set_bit(CONN_ACTIVE, &conn->state);
-
- conn->file = fget(info->fd);
- iet_socket_bind(conn);
-
- list_add(&conn->poll_list, &session->target->nthread_info.active_conns);
-
- nthread_wakeup(conn->session->target);
-
- return 0;
-}
-
-void conn_close(struct iscsi_conn *conn)
-{
- struct iscsi_cmnd *cmnd;
- struct iscsi_session *session = conn->session;
-
- if (test_and_clear_bit(CONN_ACTIVE, &conn->state))
- set_bit(CONN_CLOSING, &conn->state);
-
- spin_lock(&conn->list_lock);
- list_for_each_entry(cmnd, &conn->pdu_list, conn_list) {
- set_cmnd_tmfabort(cmnd);
- if (cmnd->lun) {
- ua_establish_for_session(session, cmnd->lun->lun, 0x47, 0x7f);
- iscsi_cmnd_set_sense(cmnd, UNIT_ATTENTION, 0x6e, 0x0);
- }
- }
- spin_unlock(&conn->list_lock);
-
- nthread_wakeup(conn->session->target);
-}
-
-int conn_add(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
- int err;
-
- conn = conn_lookup(session, info->cid);
- if (conn)
- conn_close(conn);
-
- err = iet_conn_alloc(session, info);
- if (!err && conn)
- err = -EEXIST;
-
- return err;
-}
-
-int conn_del(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
- int err = -EEXIST;
-
- conn = conn_lookup(session, info->cid);
- if (!conn)
- return err;
-
- conn_close(conn);
-
- return 0;
-}
diff --git a/ubuntu/iscsitarget/digest.c b/ubuntu/iscsitarget/digest.c
deleted file mode 100644
index 32b4d76..0000000
--- a/ubuntu/iscsitarget/digest.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * iSCSI digest handling.
- * (C) 2004 - 2006 Xiranet Communications GmbH <arne.redlich@xiranet.com>
- * This code is licensed under the GPL.
- */
-
-#include <linux/types.h>
-
-#include "iscsi.h"
-#include "digest.h"
-#include "iscsi_dbg.h"
-
-void digest_alg_available(unsigned int *val)
-{
- if (*val & DIGEST_CRC32C &&
- !crypto_has_alg("crc32c", 0, CRYPTO_ALG_ASYNC)) {
- printk("CRC32C digest algorithm not available in kernel
");
- *val |= ~DIGEST_CRC32C;
- }
-}
-
-/**
- * initialize support for digest calculation.
- *
- * digest_init -
- * @conn: ptr to connection to make use of digests
- *
- * @return: 0 on success, < 0 on error
- */
-int digest_init(struct iscsi_conn *conn)
-{
- int err = 0;
-
- if (!(conn->hdigest_type & DIGEST_ALL))
- conn->hdigest_type = DIGEST_NONE;
-
- 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;
- 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;
- err = -ENOMEM;
- goto out;
- }
- }
-
-out:
- if (err)
- digest_cleanup(conn);
-
- return err;
-}
-
-/**
- * free resources used for digest calculation.
- *
- * digest_cleanup -
- * @conn: ptr to connection that made use of digests
- */
-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);
-}
-
-/**
- * debug handling of header digest errors:
- * simulates a digest error after n PDUs / every n-th PDU of type
- * HDIGEST_ERR_CORRUPT_PDU_TYPE.
- */
-static inline void __dbg_simulate_header_digest_error(struct iscsi_cmnd *cmnd)
-{
-#define HDIGEST_ERR_AFTER_N_CMNDS 1000
-#define HDIGEST_ERR_ONLY_ONCE 1
-#define HDIGEST_ERR_CORRUPT_PDU_TYPE ISCSI_OP_SCSI_CMD
-#define HDIGEST_ERR_CORRUPT_PDU_WITH_DATA_ONLY 0
-
- static int num_cmnds = 0;
- static int num_errs = 0;
-
- if (cmnd_opcode(cmnd) == HDIGEST_ERR_CORRUPT_PDU_TYPE) {
- if (HDIGEST_ERR_CORRUPT_PDU_WITH_DATA_ONLY) {
- if (cmnd->pdu.datasize)
- num_cmnds++;
- } else
- num_cmnds++;
- }
-
- if ((num_cmnds == HDIGEST_ERR_AFTER_N_CMNDS)
- && (!(HDIGEST_ERR_ONLY_ONCE && num_errs))) {
- printk("*** Faking header digest error ***
");
- printk(" cmnd: 0x%x, itt 0x%x, sn 0x%x
",
- cmnd_opcode(cmnd),
- be32_to_cpu(cmnd->pdu.bhs.itt),
- be32_to_cpu(cmnd->pdu.bhs.sn));
- cmnd->hdigest = ~cmnd->hdigest;
- /* make things even worse by manipulating header fields */
- cmnd->pdu.datasize += 8;
- num_errs++;
- num_cmnds = 0;
- }
- return;
-}
-
-/**
- * debug handling of data digest errors:
- * simulates a digest error after n PDUs / every n-th PDU of type
- * DDIGEST_ERR_CORRUPT_PDU_TYPE.
- */
-static inline void __dbg_simulate_data_digest_error(struct iscsi_cmnd *cmnd)
-{
-#define DDIGEST_ERR_AFTER_N_CMNDS 50
-#define DDIGEST_ERR_ONLY_ONCE 1
-#define DDIGEST_ERR_CORRUPT_PDU_TYPE ISCSI_OP_SCSI_DATA_OUT
-#define DDIGEST_ERR_CORRUPT_UNSOL_DATA_ONLY 0
-
- static int num_cmnds = 0;
- static int num_errs = 0;
-
- if ((cmnd->pdu.datasize)
- && (cmnd_opcode(cmnd) == DDIGEST_ERR_CORRUPT_PDU_TYPE)) {
- switch (cmnd_opcode(cmnd)) {
- case ISCSI_OP_SCSI_DATA_OUT:
- if ((DDIGEST_ERR_CORRUPT_UNSOL_DATA_ONLY)
- && (cmnd->pdu.bhs.ttt != ISCSI_RESERVED_TAG))
- break;
- default:
- num_cmnds++;
- }
- }
-
- if ((num_cmnds == DDIGEST_ERR_AFTER_N_CMNDS)
- && (!(DDIGEST_ERR_ONLY_ONCE && num_errs))
- && (cmnd->pdu.datasize)
- && (!cmnd->conn->read_overflow)) {
- printk("*** Faking data digest error: ***");
- printk(" cmnd 0x%x, itt 0x%x, sn 0x%x
",
- cmnd_opcode(cmnd),
- be32_to_cpu(cmnd->pdu.bhs.itt),
- be32_to_cpu(cmnd->pdu.bhs.sn));
- cmnd->ddigest = ~cmnd->ddigest;
- num_errs++;
- num_cmnds = 0;
- }
-}
-
-static void digest_header(struct hash_desc *hash, 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);
-
- sg_set_buf(&sg[0], &pdu->bhs, nbytes);
- if (pdu->ahssize) {
- sg_set_buf(&sg[1], pdu->ahs, pdu->ahssize);
- nbytes += pdu->ahssize;
- }
-
- crypto_hash_init(hash);
- crypto_hash_update(hash, sg, nbytes);
- crypto_hash_final(hash, crc);
-}
-
-int digest_rx_header(struct iscsi_cmnd *cmnd)
-{
- u32 crc;
-
- digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
- if (crc != cmnd->hdigest)
- return -EIO;
-
- return 0;
-}
-
-void digest_tx_header(struct iscsi_cmnd *cmnd)
-{
- digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
-}
-
-static void digest_data(struct hash_desc *hash, 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;
-
- offset += tio->offset;
- idx = offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
- count = get_pgcnt(size, offset);
- assert(idx + count <= tio->pg_cnt);
-
- assert(count <= ISCSI_CONN_IOV_MAX);
-
- sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
- crypto_hash_init(hash);
-
- for (i = 0; size; i++) {
- if (offset + size > PAGE_CACHE_SIZE)
- length = PAGE_CACHE_SIZE - offset;
- else
- length = size;
-
- sg_set_page(&sg[i], tio->pvec[idx + i], length, offset);
- size -= length;
- offset = 0;
- }
-
- sg_mark_end(&sg[i - 1]);
-
- crypto_hash_update(hash, sg, nbytes);
- crypto_hash_final(hash, crc);
-}
-
-int digest_rx_data(struct iscsi_cmnd *cmnd)
-{
- struct tio *tio;
- struct iscsi_cmnd *scsi_cmnd;
- struct iscsi_data_out_hdr *req;
- u32 offset, crc;
-
- switch (cmnd_opcode(cmnd)) {
- case ISCSI_OP_SCSI_REJECT:
- case ISCSI_OP_PDU_REJECT:
- case ISCSI_OP_DATA_REJECT:
- return 0;
- case ISCSI_OP_SCSI_DATA_OUT:
- scsi_cmnd = cmnd->req;
- req = (struct iscsi_data_out_hdr *) &cmnd->pdu.bhs;
- tio = scsi_cmnd->tio;
- offset = be32_to_cpu(req->buffer_offset);
- break;
- default:
- tio = cmnd->tio;
- offset = 0;
- }
-
- digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
-
- if (!cmnd->conn->read_overflow &&
- (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
- if (crc != cmnd->ddigest)
- return -EIO;
- }
-
- return 0;
-}
-
-void digest_tx_data(struct iscsi_cmnd *cmnd)
-{
- struct tio *tio = cmnd->tio;
- struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;
-
- assert(tio);
- digest_data(&cmnd->conn->tx_hash, cmnd, tio,
- be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
-}
diff --git a/ubuntu/iscsitarget/digest.h b/ubuntu/iscsitarget/digest.h
deleted file mode 100644
index 9b9d845..0000000
--- a/ubuntu/iscsitarget/digest.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * iSCSI digest handling.
- * (C) 2004 Xiranet Communications GmbH <arne.redlich@xiranet.com>
- * This code is licensed under the GPL.
- */
-
-#ifndef __IET_DIGEST_H__
-#define __IET_DIGEST_H__
-
-extern void digest_alg_available(unsigned int *val);
-extern int digest_init(struct iscsi_conn *conn);
-extern void digest_cleanup(struct iscsi_conn *conn);
-
-extern int digest_rx_header(struct iscsi_cmnd *cmnd);
-extern int digest_rx_data(struct iscsi_cmnd *cmnd);
-
-extern void digest_tx_header(struct iscsi_cmnd *cmnd);
-extern void digest_tx_data(struct iscsi_cmnd *cmnd);
-
-#endif /* __IET_DIGEST_H__ */
diff --git a/ubuntu/iscsitarget/event.c b/ubuntu/iscsitarget/event.c
deleted file mode 100644
index 240404d..0000000
--- a/ubuntu/iscsitarget/event.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Event notification code.
- * (C) 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- *
- * Some functions are based on audit code.
- */
-
-#include <net/tcp.h>
-#include "iet_u.h"
-#include "iscsi_dbg.h"
-
-static struct sock *nl;
-static u32 ietd_pid;
-
-static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
-{
- u32 uid, pid, seq;
- char *data;
-
- pid = NETLINK_CREDS(skb)->pid;
- uid = NETLINK_CREDS(skb)->uid;
- seq = nlh->nlmsg_seq;
- data = NLMSG_DATA(nlh);
-
- ietd_pid = pid;
-
- return 0;
-}
-
-static void event_recv_skb(struct sk_buff *skb)
-{
- int err;
- struct nlmsghdr *nlh;
- u32 rlen;
-
- while (skb->len >= NLMSG_SPACE(0)) {
- nlh = (struct nlmsghdr *)skb->data;
- if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
- break;
- rlen = NLMSG_ALIGN(nlh->nlmsg_len);
- if (rlen > skb->len)
- rlen = skb->len;
- if ((err = event_recv_msg(skb, nlh))) {
- netlink_ack(skb, nlh, -err);
- } else if (nlh->nlmsg_flags & NLM_F_ACK)
- netlink_ack(skb, nlh, 0);
- skb_pull(skb, rlen);
- }
-}
-
-static int notify(void *data, int len, int gfp_mask)
-{
- struct sk_buff *skb;
- struct nlmsghdr *nlh;
- static u32 seq = 0;
-
- if (!(skb = alloc_skb(NLMSG_SPACE(len), gfp_mask)))
- return -ENOMEM;
-
- nlh = __nlmsg_put(skb, ietd_pid, seq++, NLMSG_DONE, len - sizeof(*nlh), 0);
-
- memcpy(NLMSG_DATA(nlh), data, len);
-
- return netlink_unicast(nl, skb, ietd_pid, 0);
-}
-
-int event_send(u32 tid, u64 sid, u32 cid, u32 state, int atomic)
-{
- int err;
- struct iet_event event;
-
- event.tid = tid;
- event.sid = sid;
- event.cid = cid;
- event.state = state;
-
- err = notify(&event, NLMSG_SPACE(sizeof(struct iet_event)), 0);
-
- return err;
-}
-
-int event_init(void)
-{
- nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb,
- NULL, THIS_MODULE);
- if (!nl)
- return -ENOMEM;
- else
- return 0;
-}
-
-void event_exit(void)
-{
- netlink_kernel_release(nl);
-}
diff --git a/ubuntu/iscsitarget/file-io.c b/ubuntu/iscsitarget/file-io.c
deleted file mode 100644
index a050fcc..0000000
--- a/ubuntu/iscsitarget/file-io.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Target device file I/O.
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include <linux/types.h>
-#include <linux/blkdev.h>
-#include <linux/parser.h>
-#include <linux/writeback.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-struct fileio_data {
- char *path;
- struct file *filp;
-};
-
-static int fileio_make_request(struct iet_volume *lu, struct tio *tio, int rw)
-{
- struct fileio_data *p = lu->private;
- struct file *filp;
- mm_segment_t oldfs;
- struct page *page;
- u32 offset, size;
- loff_t ppos, count;
- char *buf;
- int i, err = 0;
- ssize_t ret;
-
- assert(p);
- filp = p->filp;
- size = tio->size;
- offset= tio->offset;
-
- ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- ppos += offset;
-
- for (i = 0; i < tio->pg_cnt; i++) {
- page = tio->pvec[i];
- assert(page);
- buf = page_address(page);
- buf += offset;
-
- if (offset + size > PAGE_CACHE_SIZE)
- count = PAGE_CACHE_SIZE - offset;
- else
- count = size;
-
- oldfs = get_fs();
- set_fs(get_ds());
-
- if (rw == READ)
- ret = vfs_read(filp, buf, count, &ppos);
- else
- ret = vfs_write(filp, buf, count, &ppos);
-
- set_fs(oldfs);
-
- if (ret != count) {
- eprintk("I/O error %lld, %ld
", count, (long) ret);
- err = -EIO;
- }
-
- size -= count;
- offset = 0;
- }
- assert(!size);
-
- return err;
-}
-
-static int fileio_sync(struct iet_volume *lu, struct tio *tio)
-{
- struct fileio_data *p = lu->private;
- struct inode *inode = p->filp->f_dentry->d_inode;
- struct address_space *mapping = inode->i_mapping;
- loff_t ppos, count;
- int res;
-
- if (tio) {
- ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- ppos += tio->offset;
- count = tio->size;
- } else {
- ppos = 0;
- count = lu->blk_cnt << lu->blk_shift;
- }
-
- res = filemap_write_and_wait_range(mapping, ppos, ppos + count - 1);
- if (res) {
- eprintk("I/O error: syncing pages failed: %d
", res);
- return -EIO;
- } else
- return 0;
-}
-
-static int open_path(struct iet_volume *volume, const char *path)
-{
- int err = 0;
- struct fileio_data *info = volume->private;
- struct file *filp;
- mm_segment_t oldfs;
- int flags;
-
- info->path = kstrdup(path, GFP_KERNEL);
- if (!info->path)
- return -ENOMEM;
-
- oldfs = get_fs();
- set_fs(get_ds());
- flags = (LUReadonly(volume) ? O_RDONLY : O_RDWR) | O_LARGEFILE;
- filp = filp_open(path, flags, 0);
- set_fs(oldfs);
-
- if (IS_ERR(filp)) {
- err = PTR_ERR(filp);
- eprintk("Can't open %s %d
", path, err);
- info->filp = NULL;
- } else
- info->filp = filp;
-
- return err;
-}
-
-enum {
- opt_path, opt_ignore, opt_err,
-};
-
-static match_table_t tokens = {
- {opt_path, "path=%s"},
- {opt_ignore, "scsiid=%s"},
- {opt_ignore, "scsisn=%s"},
- {opt_ignore, "type=%s"},
- {opt_ignore, "iomode=%s"},
- {opt_ignore, "blocksize=%s"},
- {opt_err, NULL},
-};
-
-static int parse_fileio_params(struct iet_volume *volume, char *params)
-{
- struct fileio_data *info = volume->private;
- int err = 0;
- char *p, *q;
-
- while ((p = strsep(&params, ",")) != NULL) {
- substring_t args[MAX_OPT_ARGS];
- int token;
- if (!*p)
- continue;
- iet_strtolower(p);
- token = match_token(p, tokens, args);
- switch (token) {
- case opt_path:
- if (info->path) {
- iprintk("Target %s, LUN %u: "
- "duplicate "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- goto out;
- }
- if (!(q = match_strdup(&args[0]))) {
- err = -ENOMEM;
- goto out;
- }
- err = open_path(volume, q);
- kfree(q);
- if (err < 0)
- goto out;
- break;
- case opt_ignore:
- break;
- default:
- iprintk("Target %s, LUN %u: unknown param %s
",
- volume->target->name, volume->lun, p);
- return -EINVAL;
- }
- }
-
- if (!info->path) {
- iprintk("Target %s, LUN %u: missing "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- }
-out:
- return err;
-}
-
-static void fileio_detach(struct iet_volume *lu)
-{
- struct fileio_data *p = lu->private;
-
- kfree(p->path);
- if (p->filp)
- filp_close(p->filp, NULL);
- kfree(p);
- lu->private = NULL;
-}
-
-static int fileio_attach(struct iet_volume *lu, char *args)
-{
- int err = 0;
- struct fileio_data *p;
- struct inode *inode;
-
- if (lu->private) {
- printk("already attached ? %d
", lu->lun);
- return -EBUSY;
- }
-
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return -ENOMEM;
-
- lu->private = p;
-
- if ((err = parse_fileio_params(lu, args)) < 0) {
- eprintk("%d
", err);
- goto out;
- }
- inode = p->filp->f_dentry->d_inode;
-
- if (S_ISREG(inode->i_mode))
- ;
- else if (S_ISBLK(inode->i_mode))
- inode = inode->i_bdev->bd_inode;
- else {
- err = -EINVAL;
- goto out;
- }
-
- if (!lu->blk_shift)
- lu->blk_shift = blksize_bits(IET_DEF_BLOCK_SIZE);
-
- lu->blk_cnt = inode->i_size >> lu->blk_shift;
-
- /* we're using the page cache */
- SetLURCache(lu);
-out:
- if (err < 0)
- fileio_detach(lu);
- return err;
-}
-
-static void fileio_show(struct iet_volume *lu, struct seq_file *seq)
-{
- struct fileio_data *p = lu->private;
- seq_printf(seq, " path:%s
", p->path);
-}
-
-struct iotype fileio =
-{
- .name = "fileio",
- .attach = fileio_attach,
- .make_request = fileio_make_request,
- .sync = fileio_sync,
- .detach = fileio_detach,
- .show = fileio_show,
-};
diff --git a/ubuntu/iscsitarget/include/iet_u.h b/ubuntu/iscsitarget/include/iet_u.h
deleted file mode 100644
index 6fdc716..0000000
--- a/ubuntu/iscsitarget/include/iet_u.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef _IET_U_H
-#define _IET_U_H
-
-#define IET_VERSION_STRING "1.4.20.2"
-
-/* The maximum length of 223 bytes in the RFC. */
-#define ISCSI_NAME_LEN 256
-#define ISCSI_ARGS_LEN 2048
-
-#define ISCSI_LISTEN_PORT 3260
-
-#define SCSI_ID_LEN 16
-#define SCSI_SN_LEN (SCSI_ID_LEN * 2)
-
-#ifndef aligned_u64
-#define aligned_u64 unsigned long long __attribute__((aligned(8)))
-#endif
-
-struct module_info {
- char version[128];
-};
-
-struct target_info {
- u32 tid;
- char name[ISCSI_NAME_LEN];
-};
-
-struct volume_info {
- u32 tid;
- u32 lun;
- aligned_u64 args_ptr;
- u32 args_len;
-};
-
-struct session_info {
- u32 tid;
-
- aligned_u64 sid;
- char initiator_name[ISCSI_NAME_LEN];
- u32 exp_cmd_sn;
- u32 max_cmd_sn;
-};
-
-#define DIGEST_ALL (DIGEST_NONE | DIGEST_CRC32C)
-#define DIGEST_NONE (1 << 0)
-#define DIGEST_CRC32C (1 << 1)
-
-struct conn_info {
- u32 tid;
- aligned_u64 sid;
-
- u32 cid;
- u32 stat_sn;
- u32 exp_stat_sn;
- int header_digest;
- int data_digest;
- int fd;
-};
-
-enum {
- key_initial_r2t,
- key_immediate_data,
- key_max_connections,
- key_max_recv_data_length,
- key_max_xmit_data_length,
- key_max_burst_length,
- key_first_burst_length,
- key_default_wait_time,
- key_default_retain_time,
- key_max_outstanding_r2t,
- key_data_pdu_inorder,
- key_data_sequence_inorder,
- key_error_recovery_level,
- key_header_digest,
- key_data_digest,
- key_ofmarker,
- key_ifmarker,
- key_ofmarkint,
- key_ifmarkint,
- session_key_last,
-};
-
-enum {
- key_wthreads,
- key_target_type,
- key_queued_cmnds,
- key_nop_interval,
- key_nop_timeout,
- target_key_last,
-};
-
-enum {
- key_session,
- key_target,
-};
-
-struct iscsi_param_info {
- u32 tid;
- aligned_u64 sid;
-
- u32 param_type;
- u32 partial;
-
- u32 session_param[session_key_last];
- u32 target_param[target_key_last];
-};
-
-enum iet_event_state {
- E_CONN_CLOSE,
-};
-
-struct iet_event {
- u32 tid;
- aligned_u64 sid;
- u32 cid;
- u32 state;
-};
-
-#define DEFAULT_NR_WTHREADS 8
-#define MIN_NR_WTHREADS 1
-#define MAX_NR_WTHREADS 128
-
-#define DEFAULT_NR_QUEUED_CMNDS 32
-#define MIN_NR_QUEUED_CMNDS 1
-#define MAX_NR_QUEUED_CMNDS 256
-
-#define DEFAULT_NOP_INTERVAL 0
-#define MIN_NOP_INTERVAL 0
-#define MAX_NOP_INTERVAL 90
-
-#define DEFAULT_NOP_TIMEOUT 0
-#define MIN_NOP_TIMEOUT 0
-#define MAX_NOP_TIMEOUT 90
-
-#define NETLINK_IET 21
-
-#define GET_MODULE_INFO _IOW('i', 20, struct module_info)
-#define ADD_TARGET _IOWR('i', 21, struct target_info)
-#define DEL_TARGET _IOW('i', 22, struct target_info)
-#define ADD_VOLUME _IOW('i', 24, struct volume_info)
-#define DEL_VOLUME _IOW('i', 25, struct volume_info)
-#define ADD_SESSION _IOW('i', 26, struct session_info)
-#define DEL_SESSION _IOW('i', 27, struct session_info)
-#define GET_SESSION_INFO _IOWR('i', 28, struct session_info)
-#define ADD_CONN _IOW('i', 29, struct conn_info)
-#define DEL_CONN _IOW('i', 30, struct conn_info)
-#define GET_CONN_INFO _IOWR('i', 31, struct conn_info)
-#define ISCSI_PARAM_SET _IOW('i', 32, struct iscsi_param_info)
-#define ISCSI_PARAM_GET _IOWR('i', 33, struct iscsi_param_info)
-
-#endif
diff --git a/ubuntu/iscsitarget/iotype.c b/ubuntu/iscsitarget/iotype.c
deleted file mode 100644
index 007d1fe..0000000
--- a/ubuntu/iscsitarget/iotype.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Manager for various I/O types.
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include "iscsi.h"
-#include "iotype.h"
-#include "iscsi_dbg.h"
-
-static LIST_HEAD(iotypes);
-static rwlock_t iotypes_lock = __RW_LOCK_UNLOCKED(iotypes_lock);
-
-static struct iotype *find_iotype(const char *name)
-{
- struct iotype *iot = NULL;
-
- list_for_each_entry(iot, &iotypes, iot_list) {
- if (strcmp(iot->name, name) == 0)
- return iot;
- }
- return NULL;
-}
-
-struct iotype *get_iotype(const char *name)
-{
- struct iotype *iot;
-
- read_lock(&iotypes_lock);
- iot = find_iotype(name);
- read_unlock(&iotypes_lock);
-
- return iot;
-}
-
-void put_iotype(struct iotype *iot)
-{
- if (!iot)
- return;
- return;
-}
-
-static int register_iotype(struct iotype *iot)
-{
- int err = 0;
- struct iotype *p;
-
- write_lock(&iotypes_lock);
-
- p = find_iotype(iot->name);
- if (p)
- err = -EBUSY;
- else
- list_add_tail(&iot->iot_list, &iotypes);
-
- write_unlock(&iotypes_lock);
-
- return err;
-}
-
-static int unregister_iotype(struct iotype *iot)
-{
- int err = 0;
- struct iotype *p;
-
- write_lock(&iotypes_lock);
-
- p = find_iotype(iot->name);
- if (p && p == iot)
- list_del_init(&iot->iot_list);
- else
- err = -EINVAL;
-
- write_unlock(&iotypes_lock);
-
-
- return err;
-}
-
-struct iotype *iotype_array[] = {
- &fileio,
- &blockio,
- &nullio,
-};
-
-int iotype_init(void)
-{
- int i, err;
-
- for (i = 0; i < ARRAY_SIZE(iotype_array); i++) {
- if (!(err = register_iotype(iotype_array[i])))
- iprintk("Registered io type %s
",
- iotype_array[i]->name);
- else {
- eprintk("Failed to register io type %s
",
- iotype_array[i]->name);
- break;
- }
- }
-
- return err;
-}
-
-void iotype_exit(void)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(iotype_array); i++)
- unregister_iotype(iotype_array[i]);
-}
diff --git a/ubuntu/iscsitarget/iotype.h b/ubuntu/iscsitarget/iotype.h
deleted file mode 100644
index db7956a..0000000
--- a/ubuntu/iscsitarget/iotype.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include <linux/ctype.h>
-#include "iscsi.h"
-
-#ifndef __IOTYPE_H__
-#define __IOTYPE_H__
-
-struct iotype {
- const char *name;
- struct list_head iot_list;
-
- int (*attach)(struct iet_volume *dev, char *args);
- int (*make_request)(struct iet_volume *dev, struct tio *tio, int rw);
- int (*sync)(struct iet_volume *dev, struct tio *tio);
- void (*detach)(struct iet_volume *dev);
- void (*show)(struct iet_volume *dev, struct seq_file *seq);
-};
-
-extern struct iotype fileio;
-extern struct iotype nullio;
-extern struct iotype blockio;
-
-extern int iotype_init(void);
-extern void iotype_exit(void);
-
-/* For option parameter parsing.
- * This is slightly iet specific: we only tolower() up to the first '='.
- * Note that this changes *c _in place_, but our parsing
- * routines copy the input to a scratch page before parsing anyways. */
-static inline void iet_strtolower(char *c)
-{
- if (!c)
- return;
- for (; *c && *c != '='; c++)
- *c = tolower(*c);
-}
-
-#endif
diff --git a/ubuntu/iscsitarget/iscsi.c b/ubuntu/iscsitarget/iscsi.c
deleted file mode 100644
index 05197f2..0000000
--- a/ubuntu/iscsitarget/iscsi.c
+++ /dev/null
@@ -1,1967 +0,0 @@
-/*
- * Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>
- * Copyright (C) 2008 Arne Redlich <agr@powerkom-dd.de>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <linux/module.h>
-#include <linux/hash.h>
-#include <net/tcp.h>
-#include <scsi/scsi.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-unsigned long debug_enable_flags;
-unsigned long worker_thread_pool_size;
-
-static struct kmem_cache *iscsi_cmnd_cache;
-static u8 dummy_data[PAGE_SIZE];
-
-static int ctr_major;
-static char ctr_name[] = "ietctl";
-extern struct file_operations ctr_fops;
-
-static u32 cmnd_write_size(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_scsi_cmd_hdr *hdr = cmnd_hdr(cmnd);
-
- if (hdr->flags & ISCSI_CMD_WRITE)
- return be32_to_cpu(hdr->data_length);
- return 0;
-}
-
-static u32 cmnd_read_size(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_scsi_cmd_hdr *hdr = cmnd_hdr(cmnd);
-
- if (hdr->flags & ISCSI_CMD_READ) {
- struct iscsi_rlength_ahdr *ahdr =
- (struct iscsi_rlength_ahdr *)cmnd->pdu.ahs;
-
- if (!(hdr->flags & ISCSI_CMD_WRITE))
- return be32_to_cpu(hdr->data_length);
- if (ahdr && ahdr->ahstype == ISCSI_AHSTYPE_RLENGTH)
- return be32_to_cpu(ahdr->read_length);
- }
- return 0;
-}
-
-static void iscsi_device_queue_cmnd(struct iscsi_cmnd *cmnd)
-{
- set_cmnd_waitio(cmnd);
- wthread_queue(cmnd);
-}
-
-static void iscsi_scsi_queuecmnd(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_queue *queue = &cmnd->lun->queue;
-
- dprintk(D_GENERIC, "%p
", cmnd);
-
- if ((cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) != ISCSI_CMD_UNTAGGED &&
- (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) != ISCSI_CMD_SIMPLE) {
- cmnd->pdu.bhs.flags &= ~ISCSI_CMD_ATTR_MASK;
- cmnd->pdu.bhs.flags |= ISCSI_CMD_UNTAGGED;
- }
-
- spin_lock(&queue->queue_lock);
-
- set_cmnd_queued(cmnd);
-
- switch (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- if (!list_empty(&queue->wait_list) || queue->ordered_cmnd)
- goto pending;
- queue->active_cnt++;
- break;
-
- default:
- BUG();
- }
- spin_unlock(&queue->queue_lock);
-
- iscsi_device_queue_cmnd(cmnd);
- return;
- pending:
- assert(list_empty(&cmnd->list));
-
- list_add_tail(&cmnd->list, &queue->wait_list);
- spin_unlock(&queue->queue_lock);
- return;
-}
-
-static void iscsi_scsi_dequeuecmnd(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_queue *queue;
-
- if (!cmnd->lun)
- return;
- queue = &cmnd->lun->queue;
- spin_lock(&queue->queue_lock);
- switch (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- --queue->active_cnt;
- break;
- case ISCSI_CMD_ORDERED:
- case ISCSI_CMD_HEAD_OF_QUEUE:
- case ISCSI_CMD_ACA:
- BUG();
- default:
- /* Should the iscsi_scsi_queuecmnd func reject this ? */
- break;
- }
-
- while (!list_empty(&queue->wait_list)) {
- cmnd = list_entry(queue->wait_list.next, struct iscsi_cmnd, list);
- switch ((cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK)) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- list_del_init(&cmnd->list);
- queue->active_cnt++;
- iscsi_device_queue_cmnd(cmnd);
- break;
- case ISCSI_CMD_ORDERED:
- case ISCSI_CMD_HEAD_OF_QUEUE:
- case ISCSI_CMD_ACA:
- BUG();
- }
- }
-
- spin_unlock(&queue->queue_lock);
-
- return;
-}
-
-/**
- * create a new command.
- *
- * iscsi_cmnd_create -
- * @conn: ptr to connection (for i/o)
- *
- * @return ptr to command or NULL
- */
-
-struct iscsi_cmnd *cmnd_alloc(struct iscsi_conn *conn, int req)
-{
- struct iscsi_cmnd *cmnd;
-
- /* TODO: async interface is necessary ? */
- cmnd = kmem_cache_alloc(iscsi_cmnd_cache, GFP_KERNEL|__GFP_NOFAIL);
-
- memset(cmnd, 0, sizeof(*cmnd));
- INIT_LIST_HEAD(&cmnd->list);
- INIT_LIST_HEAD(&cmnd->pdu_list);
- INIT_LIST_HEAD(&cmnd->conn_list);
- INIT_LIST_HEAD(&cmnd->hash_list);
- cmnd->conn = conn;
- spin_lock(&conn->list_lock);
- atomic_inc(&conn->nr_cmnds);
- if (req)
- list_add_tail(&cmnd->conn_list, &conn->pdu_list);
- spin_unlock(&conn->list_lock);
- cmnd->tio = NULL;
-
- dprintk(D_GENERIC, "%p:%p
", conn, cmnd);
-
- return cmnd;
-}
-
-/**
- * create a new command used as response.
- *
- * iscsi_cmnd_create_rsp_cmnd -
- * @cmnd: ptr to request command
- *
- * @return ptr to response command or NULL
- */
-
-static struct iscsi_cmnd *iscsi_cmnd_create_rsp_cmnd(struct iscsi_cmnd *cmnd, int final)
-{
- struct iscsi_cmnd *rsp = cmnd_alloc(cmnd->conn, 0);
-
- if (final)
- set_cmnd_final(rsp);
- list_add_tail(&rsp->pdu_list, &cmnd->pdu_list);
- rsp->req = cmnd;
- return rsp;
-}
-
-static struct iscsi_cmnd *get_rsp_cmnd(struct iscsi_cmnd *req)
-{
- return list_entry(req->pdu_list.prev, struct iscsi_cmnd, pdu_list);
-}
-
-static void iscsi_cmnds_init_write(struct list_head *send)
-{
- struct iscsi_cmnd *cmnd = list_entry(send->next, struct iscsi_cmnd, list);
- struct iscsi_conn *conn = cmnd->conn;
- struct list_head *pos, *next;
-
- spin_lock(&conn->list_lock);
-
- list_for_each_safe(pos, next, send) {
- cmnd = list_entry(pos, struct iscsi_cmnd, list);
-
- dprintk(D_GENERIC, "%p:%x
", cmnd, cmnd_opcode(cmnd));
-
- list_del_init(&cmnd->list);
- assert(conn == cmnd->conn);
- list_add_tail(&cmnd->list, &conn->write_list);
- }
-
- spin_unlock(&conn->list_lock);
-
- nthread_wakeup(conn->session->target);
-}
-
-static void iscsi_cmnd_init_write(struct iscsi_cmnd *cmnd)
-{
- LIST_HEAD(head);
-
- if (!list_empty(&cmnd->list)) {
- eprintk("%x %x %x %x %lx %u %u %u %u %u %u %u %d %d
",
- cmnd_itt(cmnd), cmnd_ttt(cmnd), cmnd_opcode(cmnd),
- cmnd_scsicode(cmnd), cmnd->flags, cmnd->r2t_sn,
- cmnd->r2t_length, cmnd->is_unsolicited_data,
- cmnd->target_task_tag, cmnd->outstanding_r2t,
- cmnd->hdigest, cmnd->ddigest,
- list_empty(&cmnd->pdu_list), list_empty(&cmnd->hash_list));
-
- assert(list_empty(&cmnd->list));
- }
- list_add(&cmnd->list, &head);
- iscsi_cmnds_init_write(&head);
-}
-
-static void do_send_data_rsp(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct iscsi_cmnd *data_cmnd;
- struct tio *tio = cmnd->tio;
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd);
- struct iscsi_data_in_hdr *rsp;
- u32 pdusize, expsize, scsisize, size, offset, sn;
- LIST_HEAD(send);
-
- dprintk(D_GENERIC, "%p
", cmnd);
- pdusize = conn->session->param.max_xmit_data_length;
- expsize = cmnd_read_size(cmnd);
- size = min(expsize, tio->size);
- offset = 0;
- sn = 0;
-
- while (1) {
- data_cmnd = iscsi_cmnd_create_rsp_cmnd(cmnd, size <= pdusize);
- tio_get(tio);
- data_cmnd->tio = tio;
- rsp = (struct iscsi_data_in_hdr *)&data_cmnd->pdu.bhs;
-
- rsp->opcode = ISCSI_OP_SCSI_DATA_IN;
- rsp->itt = req->itt;
- rsp->ttt = cpu_to_be32(ISCSI_RESERVED_TAG);
- rsp->buffer_offset = offset;
- rsp->data_sn = cpu_to_be32(sn);
-
- if (size <= pdusize) {
- data_cmnd->pdu.datasize = size;
- rsp->flags = ISCSI_FLG_FINAL | ISCSI_FLG_STATUS;
-
- scsisize = tio->size;
- if (scsisize < expsize) {
- rsp->flags |= ISCSI_FLG_RESIDUAL_UNDERFLOW;
- size = expsize - scsisize;
- } else if (scsisize > expsize) {
- rsp->flags |= ISCSI_FLG_RESIDUAL_OVERFLOW;
- size = scsisize - expsize;
- } else
- size = 0;
- rsp->residual_count = cpu_to_be32(size);
- list_add_tail(&data_cmnd->list, &send);
-
- break;
- }
-
- data_cmnd->pdu.datasize = pdusize;
-
- size -= pdusize;
- offset += pdusize;
- sn++;
-
- list_add_tail(&data_cmnd->list, &send);
- }
-
- iscsi_cmnds_init_write(&send);
-}
-
-static struct iscsi_cmnd *create_scsi_rsp(struct iscsi_cmnd *req)
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_scsi_cmd_hdr *req_hdr = cmnd_hdr(req);
- struct iscsi_scsi_rsp_hdr *rsp_hdr;
- struct iscsi_sense_data *sense;
-
- rsp = iscsi_cmnd_create_rsp_cmnd(req, 1);
-
- rsp_hdr = (struct iscsi_scsi_rsp_hdr *)&rsp->pdu.bhs;
- rsp_hdr->opcode = ISCSI_OP_SCSI_RSP;
- rsp_hdr->flags = ISCSI_FLG_FINAL;
- rsp_hdr->response = ISCSI_RESPONSE_COMMAND_COMPLETED;
- rsp_hdr->cmd_status = req->status;
- rsp_hdr->itt = req_hdr->itt;
-
- if (req->status == SAM_STAT_CHECK_CONDITION) {
- assert(!rsp->tio);
- rsp->tio = tio_alloc(1);
- sense = (struct iscsi_sense_data *)
- page_address(rsp->tio->pvec[0]);
-
- assert(sense);
- clear_page(sense);
- sense->length = cpu_to_be16(IET_SENSE_BUF_SIZE);
-
- memcpy(sense->data, req->sense_buf, IET_SENSE_BUF_SIZE);
- rsp->pdu.datasize = sizeof(struct iscsi_sense_data) +
- IET_SENSE_BUF_SIZE;
-
- rsp->tio->size = (rsp->pdu.datasize + 3) & -4;
- rsp->tio->offset = 0;
- }
-
- return rsp;
-}
-
-void iscsi_cmnd_set_sense(struct iscsi_cmnd *cmnd, u8 sense_key, u8 asc,
- u8 ascq)
-{
- cmnd->status = SAM_STAT_CHECK_CONDITION;
-
- cmnd->sense_buf[0] = 0xf0;
- cmnd->sense_buf[2] = sense_key;
- cmnd->sense_buf[7] = 6; // Additional sense length
- cmnd->sense_buf[12] = asc;
- cmnd->sense_buf[13] = ascq;
-
- /* Call to ACA/UAI handler */
-}
-
-static struct iscsi_cmnd *create_sense_rsp(struct iscsi_cmnd *req,
- u8 sense_key, u8 asc, u8 ascq)
-{
- iscsi_cmnd_set_sense(req, sense_key, asc, ascq);
- return create_scsi_rsp(req);
-}
-
-void send_scsi_rsp(struct iscsi_cmnd *req, void (*func)(struct iscsi_cmnd *))
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_scsi_rsp_hdr *rsp_hdr;
- u32 size;
-
- func(req);
- rsp = create_scsi_rsp(req);
-
- switch (req->status) {
- case SAM_STAT_GOOD:
- case SAM_STAT_RESERVATION_CONFLICT:
- rsp_hdr = (struct iscsi_scsi_rsp_hdr *) &rsp->pdu.bhs;
- if ((size = cmnd_read_size(req)) != 0) {
- rsp_hdr->flags |= ISCSI_FLG_RESIDUAL_UNDERFLOW;
- rsp_hdr->residual_count = cpu_to_be32(size);
- }
- break;
- default:
- break;
- }
-
- iscsi_cmnd_init_write(rsp);
-}
-
-void send_data_rsp(struct iscsi_cmnd *req, void (*func)(struct iscsi_cmnd *))
-{
- struct iscsi_cmnd *rsp;
-
- func(req);
-
- if (req->status == SAM_STAT_GOOD)
- do_send_data_rsp(req);
- else {
- rsp = create_scsi_rsp(req);
- iscsi_cmnd_init_write(rsp);
- }
-}
-
-/**
- * Free a command.
- * Also frees the additional header.
- *
- * iscsi_cmnd_remove -
- * @cmnd: ptr to command
- */
-
-static void iscsi_cmnd_remove(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn;
-
- if (!cmnd)
- return;
-
- if (cmnd_timer_active(cmnd)) {
- clear_cmnd_timer_active(cmnd);
- del_timer_sync(&cmnd->timer);
- }
-
- dprintk(D_GENERIC, "%p
", cmnd);
- conn = cmnd->conn;
- kfree(cmnd->pdu.ahs);
-
- if (!list_empty(&cmnd->list)) {
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd);
-
- eprintk("cmnd %p still on some list?, %x, %x, %x, %x, %x, %x, %x %lx
",
- cmnd, req->opcode, req->scb[0], req->flags, req->itt,
- be32_to_cpu(req->data_length),
- req->cmd_sn, be32_to_cpu(cmnd->pdu.datasize),
- conn->state);
-
- if (cmnd->req) {
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd->req);
- eprintk("%p %x %u
", req, req->opcode, req->scb[0]);
- }
- dump_stack();
- BUG();
- }
- list_del(&cmnd->list);
- spin_lock(&conn->list_lock);
- atomic_dec(&conn->nr_cmnds);
- list_del(&cmnd->conn_list);
- spin_unlock(&conn->list_lock);
-
- if (cmnd->tio)
- tio_put(cmnd->tio);
-
- kmem_cache_free(iscsi_cmnd_cache, cmnd);
-}
-
-static void cmnd_skip_pdu(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct tio *tio = cmnd->tio;
- char *addr;
- u32 size;
- int i;
-
- eprintk("%x %x %x %u
", cmnd_itt(cmnd), cmnd_opcode(cmnd),
- cmnd_hdr(cmnd)->scb[0], cmnd->pdu.datasize);
-
- if (!(size = cmnd->pdu.datasize))
- return;
-
- if (tio)
- assert(tio->pg_cnt > 0);
- else
- tio = cmnd->tio = tio_alloc(1);
-
- addr = page_address(tio->pvec[0]);
- assert(addr);
- size = (size + 3) & -4;
- conn->read_size = size;
- for (i = 0; size > PAGE_CACHE_SIZE; i++, size -= PAGE_CACHE_SIZE) {
- assert(i < ISCSI_CONN_IOV_MAX);
- conn->read_iov[i].iov_base = addr;
- conn->read_iov[i].iov_len = PAGE_CACHE_SIZE;
- }
- conn->read_iov[i].iov_base = addr;
- conn->read_iov[i].iov_len = size;
- conn->read_msg.msg_iov = conn->read_iov;
- conn->read_msg.msg_iovlen = ++i;
-}
-
-static void iscsi_cmnd_reject(struct iscsi_cmnd *req, int reason)
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_reject_hdr *rsp_hdr;
- struct tio *tio;
- char *addr;
-
- rsp = iscsi_cmnd_create_rsp_cmnd(req, 1);
- rsp_hdr = (struct iscsi_reject_hdr *)&rsp->pdu.bhs;
-
- rsp_hdr->opcode = ISCSI_OP_REJECT;
- rsp_hdr->ffffffff = ISCSI_RESERVED_TAG;
- rsp_hdr->reason = reason;
-
- rsp->tio = tio = tio_alloc(1);
- addr = page_address(tio->pvec[0]);
- clear_page(addr);
- memcpy(addr, &req->pdu.bhs, sizeof(struct iscsi_hdr));
- tio->size = rsp->pdu.datasize = sizeof(struct iscsi_hdr);
- cmnd_skip_pdu(req);
-
- req->pdu.bhs.opcode = ISCSI_OP_PDU_REJECT;
-}
-
-static void cmnd_set_sn(struct iscsi_cmnd *cmnd, int set_stat_sn)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct iscsi_session *sess = conn->session;
-
- if (set_stat_sn)
- cmnd->pdu.bhs.sn = cpu_to_be32(conn->stat_sn++);
- cmnd->pdu.bhs.exp_sn = cpu_to_be32(sess->exp_cmd_sn);
- cmnd->pdu.bhs.max_sn = cpu_to_be32(sess->exp_cmd_sn + sess->max_queued_cmnds);
-}
-
-static void update_stat_sn(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- u32 exp_stat_sn;
-
- cmnd->pdu.bhs.exp_sn = exp_stat_sn = be32_to_cpu(cmnd->pdu.bhs.exp_sn);
- dprintk(D_GENERIC, "%x,%x
", cmnd_opcode(cmnd), exp_stat_sn);
- if ((int)(exp_stat_sn - conn->exp_stat_sn) > 0 &&
- (int)(exp_stat_sn - conn->stat_sn) <= 0) {
- // free pdu resources
- cmnd->conn->exp_stat_sn = exp_stat_sn;
- }
-}
-
-static int check_cmd_sn(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_session *session = cmnd->conn->session;
- u32 cmd_sn;
-
- cmnd->pdu.bhs.sn = cmd_sn = be32_to_cpu(cmnd->pdu.bhs.sn);
-
- dprintk(D_GENERIC, "cmd_sn(%u) exp_cmd_sn(%u) max_cmd_sn(%u)
",
- cmd_sn, session->exp_cmd_sn, session->max_cmd_sn);
-
- if (between(cmd_sn, session->exp_cmd_sn, session->max_cmd_sn))
- return 0;
- else if (cmnd_immediate(cmnd))
- return 0;
-
- eprintk("sequence error: cmd_sn(%u) exp_cmd_sn(%u) max_cmd_sn(%u)
",
- cmd_sn, session->exp_cmd_sn, session->max_cmd_sn);
-
- set_cmnd_tmfabort(cmnd);
-
- return -ISCSI_REASON_PROTOCOL_ERROR;
-}
-
-static struct iscsi_cmnd *__cmnd_find_hash(struct iscsi_session *session, u32 itt, u32 ttt)
-{
- struct list_head *head;
- struct iscsi_cmnd *cmnd;
-
- head = &session->cmnd_hash[cmnd_hashfn(itt)];
-
- list_for_each_entry(cmnd, head, hash_list) {
- if (cmnd->pdu.bhs.itt == itt) {
- if ((ttt != ISCSI_RESERVED_TAG) && (ttt != cmnd->target_task_tag))
- continue;
- return cmnd;
- }
- }
-
- return NULL;
-}
-
-static struct iscsi_cmnd *cmnd_find_hash(struct iscsi_session *session, u32 itt, u32 ttt)
-{
- struct iscsi_cmnd *cmnd;
-
- spin_lock(&session->cmnd_hash_lock);
-
- cmnd = __cmnd_find_hash(session, itt, ttt);
-
- spin_unlock(&session->cmnd_hash_lock);
-
- return cmnd;
-}
-
-static int cmnd_insert_hash_ttt(struct iscsi_cmnd *cmnd, u32 ttt)
-{
- struct iscsi_session
 
Old 06-22-2011, 08:51 AM
Stefan Bader
 
Default UBUNTU: SAUCE: iscsitarget: Remove driver from the kernel

This driver is not boot/install essential and is provided by the
iscsitarget-dkms package. Having it in the kernel itself only
duplicates code and adds a chance of getting out of sync.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
debian.master/config/config.common.ubuntu | 1 -
ubuntu/Kconfig | 4 -
ubuntu/Makefile | 4 -
ubuntu/iscsitarget/BOM | 2 -
ubuntu/iscsitarget/Kconfig | 3 -
ubuntu/iscsitarget/Makefile | 17 -
ubuntu/iscsitarget/block-io.c | 327 -----
ubuntu/iscsitarget/compat.h | 30 -
ubuntu/iscsitarget/config.c | 362 ------
ubuntu/iscsitarget/conn.c | 262 ----
ubuntu/iscsitarget/digest.c | 279 ----
ubuntu/iscsitarget/digest.h | 20 -
ubuntu/iscsitarget/event.c | 96 --
ubuntu/iscsitarget/file-io.c | 261 ----
ubuntu/iscsitarget/include/iet_u.h | 151 ---
ubuntu/iscsitarget/iotype.c | 110 --
ubuntu/iscsitarget/iotype.h | 42 -
ubuntu/iscsitarget/iscsi.c | 1967 -----------------------------
ubuntu/iscsitarget/iscsi.h | 524 --------
ubuntu/iscsitarget/iscsi_dbg.h | 137 --
ubuntu/iscsitarget/iscsi_hdr.h | 509 --------
ubuntu/iscsitarget/nthread.c | 790 ------------
ubuntu/iscsitarget/null-io.c | 98 --
ubuntu/iscsitarget/param.c | 205 ---
ubuntu/iscsitarget/session.c | 180 ---
ubuntu/iscsitarget/target.c | 374 ------
ubuntu/iscsitarget/target_disk.c | 589 ---------
ubuntu/iscsitarget/tio.c | 121 --
ubuntu/iscsitarget/ua.c | 176 ---
ubuntu/iscsitarget/volume.c | 422 ------
ubuntu/iscsitarget/wthread.c | 258 ----
31 files changed, 0 insertions(+), 8321 deletions(-)
delete mode 100644 ubuntu/iscsitarget/BOM
delete mode 100644 ubuntu/iscsitarget/Kconfig
delete mode 100644 ubuntu/iscsitarget/Makefile
delete mode 100644 ubuntu/iscsitarget/block-io.c
delete mode 100644 ubuntu/iscsitarget/compat.h
delete mode 100644 ubuntu/iscsitarget/config.c
delete mode 100644 ubuntu/iscsitarget/conn.c
delete mode 100644 ubuntu/iscsitarget/digest.c
delete mode 100644 ubuntu/iscsitarget/digest.h
delete mode 100644 ubuntu/iscsitarget/event.c
delete mode 100644 ubuntu/iscsitarget/file-io.c
delete mode 100644 ubuntu/iscsitarget/include/iet_u.h
delete mode 100644 ubuntu/iscsitarget/iotype.c
delete mode 100644 ubuntu/iscsitarget/iotype.h
delete mode 100644 ubuntu/iscsitarget/iscsi.c
delete mode 100644 ubuntu/iscsitarget/iscsi.h
delete mode 100644 ubuntu/iscsitarget/iscsi_dbg.h
delete mode 100644 ubuntu/iscsitarget/iscsi_hdr.h
delete mode 100644 ubuntu/iscsitarget/nthread.c
delete mode 100644 ubuntu/iscsitarget/null-io.c
delete mode 100644 ubuntu/iscsitarget/param.c
delete mode 100644 ubuntu/iscsitarget/session.c
delete mode 100644 ubuntu/iscsitarget/target.c
delete mode 100644 ubuntu/iscsitarget/target_disk.c
delete mode 100644 ubuntu/iscsitarget/tio.c
delete mode 100644 ubuntu/iscsitarget/ua.c
delete mode 100644 ubuntu/iscsitarget/volume.c
delete mode 100644 ubuntu/iscsitarget/wthread.c

diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index 202ef91..7f30751 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -4156,7 +4156,6 @@ CONFIG_SCSI_IN2000=m
CONFIG_SCSI_INIA100=m
CONFIG_SCSI_INITIO=m
CONFIG_SCSI_IPS=m
-# CONFIG_SCSI_ISCSITARGET is not set
CONFIG_SCSI_ISCSI_ATTRS=m
# CONFIG_SCSI_IZIP_EPP16 is not set
# CONFIG_SCSI_IZIP_SLOW_CTR is not set
diff --git a/ubuntu/Kconfig b/ubuntu/Kconfig
index 443457e..0159dd3 100644
--- a/ubuntu/Kconfig
+++ b/ubuntu/Kconfig
@@ -34,10 +34,6 @@ source "ubuntu/omnibook/Kconfig"
##
##
##
-source "ubuntu/iscsitarget/Kconfig"
-##
-##
-##
source "ubuntu/rtl8192se/Kconfig"
##
##
diff --git a/ubuntu/Makefile b/ubuntu/Makefile
index 43b53d1..f71a0d5 100644
--- a/ubuntu/Makefile
+++ b/ubuntu/Makefile
@@ -36,10 +36,6 @@ obj-$(CONFIG_NDISWRAPPER) += ndiswrapper/
##
##
##
-obj-$(CONFIG_SCSI_ISCSITARGET) += iscsitarget/
-##
-##
-##
obj-$(CONFIG_RTL8192SE) += rtl8192se/
##
##
diff --git a/ubuntu/iscsitarget/BOM b/ubuntu/iscsitarget/BOM
deleted file mode 100644
index 40751ae..0000000
--- a/ubuntu/iscsitarget/BOM
+++ /dev/null
@@ -1,2 +0,0 @@
-Downloaded from: http://sourceforge.net/projects/iscsitarget/files/
-Current Version: 1.4.20.2
diff --git a/ubuntu/iscsitarget/Kconfig b/ubuntu/iscsitarget/Kconfig
deleted file mode 100644
index e5964dc..0000000
--- a/ubuntu/iscsitarget/Kconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-config SCSI_ISCSITARGET
- tristate "iSCSI Target Driver"
- depends on SCSI
diff --git a/ubuntu/iscsitarget/Makefile b/ubuntu/iscsitarget/Makefile
deleted file mode 100644
index 727c706..0000000
--- a/ubuntu/iscsitarget/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Makefile for the Linux kernel device drivers.
-#
-# Note! Dependencies are done automagically by 'make dep', which also
-# removes any old dependencies. DON'T put your own dependencies here
-# unless it's something special (not a .c file).
-#
-# Note 2! The CFLAGS definitions are now in the main makefile.
-
-EXTRA_CFLAGS += -I$(src)/include
-
-obj-m += iscsi_trgt.o
-iscsi_trgt-objs := tio.o iscsi.o nthread.o wthread.o config.o digest.o
- conn.o session.o target.o volume.o iotype.o
- file-io.o null-io.o target_disk.o event.o param.o
- block-io.o ua.o
-
diff --git a/ubuntu/iscsitarget/block-io.c b/ubuntu/iscsitarget/block-io.c
deleted file mode 100644
index 3e7de38..0000000
--- a/ubuntu/iscsitarget/block-io.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Target device block I/O.
- *
- * Based on file I/O driver from FUJITA Tomonori
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * (C) 2006 Andre Brinkmann <brinkman at hni dot upb dot de>
- * (C) 2007 Ross Walker <rswwalker at hotmail dot com>
- * (C) 2007 Ming Zhang <blackmagic02881 at gmail dot com>
- * This code is licenced under the GPL.
- */
-
-#include <linux/types.h>
-#include <linux/blkdev.h>
-#include <linux/parser.h>
-#include <linux/buffer_head.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-struct blockio_data {
- char *path;
- struct block_device *bdev;
-};
-
-struct tio_work {
- atomic_t error;
- atomic_t bios_remaining;
- struct completion tio_complete;
-};
-
-static void blockio_bio_endio(struct bio *bio, int error)
-{
- struct tio_work *tio_work = bio->bi_private;
-
- error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;
-
- if (error)
- atomic_set(&tio_work->error, error);
-
- /* If last bio signal completion */
- if (atomic_dec_and_test(&tio_work->bios_remaining))
- complete(&tio_work->tio_complete);
-
- bio_put(bio);
-}
-
-/*
- * Blockio_make_request(): The function translates an iscsi-request into
- * a number of requests to the corresponding block device.
- */
-static int
-blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
-{
- struct blockio_data *bio_data = volume->private;
- struct request_queue *bdev_q = bdev_get_queue(bio_data->bdev);
- struct tio_work *tio_work;
- struct bio *tio_bio = NULL, *bio = NULL, *biotail = NULL;
-
- u32 offset = tio->offset;
- u32 size = tio->size;
- u32 tio_index = 0;
-
- int max_pages = 1;
- int err = 0;
-
- loff_t ppos = ((loff_t) tio->idx << PAGE_SHIFT) + offset;
-
- /* Calculate max_pages for bio_alloc (memory saver) */
- if (bdev_q)
- max_pages = bio_get_nr_vecs(bio_data->bdev);
-
- tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL);
- if (!tio_work)
- return -ENOMEM;
-
- atomic_set(&tio_work->error, 0);
- atomic_set(&tio_work->bios_remaining, 0);
- init_completion(&tio_work->tio_complete);
-
- /* Main processing loop, allocate and fill all bios */
- while (tio_index < tio->pg_cnt) {
- bio = bio_alloc(GFP_KERNEL, min(max_pages, BIO_MAX_PAGES));
- if (!bio) {
- err = -ENOMEM;
- goto out;
- }
-
- /* bi_sector is ALWAYS in units of 512 bytes */
- bio->bi_sector = ppos >> 9;
- bio->bi_bdev = bio_data->bdev;
- bio->bi_end_io = blockio_bio_endio;
- bio->bi_private = tio_work;
-
- if (tio_bio)
- biotail = biotail->bi_next = bio;
- else
- tio_bio = biotail = bio;
-
- atomic_inc(&tio_work->bios_remaining);
-
- /* Loop for filling bio */
- while (tio_index < tio->pg_cnt) {
- unsigned int bytes = PAGE_SIZE - offset;
-
- if (bytes > size)
- bytes = size;
-
- if (!bio_add_page(bio, tio->pvec[tio_index], bytes, offset))
- break;
-
- size -= bytes;
- ppos += bytes;
-
- offset = 0;
-
- tio_index++;
- }
- }
-
- /* Walk the list, submitting bios 1 by 1 */
- while (tio_bio) {
- bio = tio_bio;
- tio_bio = tio_bio->bi_next;
- bio->bi_next = NULL;
-
- submit_bio(rw, bio);
- }
-
- if (bdev_q && bdev_q->unplug_fn)
- bdev_q->unplug_fn(bdev_q);
-
- wait_for_completion(&tio_work->tio_complete);
-
- err = atomic_read(&tio_work->error);
-
- kfree(tio_work);
-
- return err;
-out:
- while (tio_bio) {
- bio = tio_bio;
- tio_bio = tio_bio->bi_next;
-
- bio_put(bio);
- }
-
- kfree(tio_work);
-
- return err;
-}
-
-static int
-blockio_open_path(struct iet_volume *volume, const char *path)
-{
- struct blockio_data *bio_data = volume->private;
- struct block_device *bdev;
- int flags = FMODE_READ | (LUReadonly(volume) ? 0 : FMODE_WRITE);
- int err = 0;
-
- bio_data->path = kstrdup(path, GFP_KERNEL);
- if (!bio_data->path)
- return -ENOMEM;
-
- bdev = blkdev_get_by_path(path, flags | FMODE_EXCL, THIS_MODULE);
- if (IS_ERR(bdev)) {
- err = PTR_ERR(bdev);
- eprintk("Can't open device %s, error %d
", path, err);
- bio_data->bdev = NULL;
- } else {
- bio_data->bdev = bdev;
- fsync_bdev(bio_data->bdev);
- }
-
- return err;
-}
-
-/* Create an enumeration of our accepted actions */
-enum
-{
- opt_path, opt_ignore, opt_err,
-};
-
-/* Create a match table using our action enums and their matching options */
-static match_table_t tokens = {
- {opt_path, "path=%s"},
- {opt_ignore, "scsiid=%s"},
- {opt_ignore, "scsisn=%s"},
- {opt_ignore, "type=%s"},
- {opt_ignore, "iomode=%s"},
- {opt_ignore, "blocksize=%s"},
- {opt_err, NULL},
-};
-
-static int
-parse_blockio_params(struct iet_volume *volume, char *params)
-{
- struct blockio_data *info = volume->private;
- int err = 0;
- char *p, *q;
-
- /* Loop through parameters separated by commas, look up our
- * parameter in match table, return enumeration and arguments
- * select case based on the returned enum and run the action */
- while ((p = strsep(&params, ",")) != NULL) {
- substring_t args[MAX_OPT_ARGS];
- int token;
- if (!*p)
- continue;
- iet_strtolower(p);
- token = match_token(p, tokens, args);
- switch (token) {
- case opt_path:
- if (info->path) {
- iprintk("Target %s, LUN %u: "
- "duplicate "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- goto out;
- }
- if (!(q = match_strdup(&args[0]))) {
- err = -ENOMEM;
- goto out;
- }
- err = blockio_open_path(volume, q);
- kfree(q);
- if (err < 0)
- goto out;
- break;
- case opt_ignore:
- break;
- default:
- iprintk("Target %s, LUN %u: unknown param %s
",
- volume->target->name, volume->lun, p);
- return -EINVAL;
- }
- }
-
- if (!info->path) {
- iprintk("Target %s, LUN %u: missing "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- }
-
- out:
- return err;
-}
-
-static void
-blockio_detach(struct iet_volume *volume)
-{
- struct blockio_data *bio_data = volume->private;
- int flags = FMODE_READ | (LUReadonly(volume) ? 0 : FMODE_WRITE);
-
- if (bio_data->bdev)
- blkdev_put(bio_data->bdev, flags | FMODE_EXCL);
- kfree(bio_data->path);
-
- kfree(volume->private);
-}
-
-static int
-blockio_attach(struct iet_volume *volume, char *args)
-{
- struct blockio_data *bio_data;
- int err = 0;
-
- if (volume->private) {
- eprintk("Lun %u already attached on Target %s
",
- volume->lun, volume->target->name);
- return -EBUSY;
- }
-
- bio_data = kzalloc(sizeof (*bio_data), GFP_KERNEL);
- if (!bio_data)
- return -ENOMEM;
-
- volume->private = bio_data;
-
- err = parse_blockio_params(volume, args);
- if (!err) {
- /* see Documentation/ABI/testing/sysfs-block */
- unsigned bsz = bdev_logical_block_size(bio_data->bdev);
- if (!volume->blk_shift)
- volume->blk_shift = blksize_bits(bsz);
- else if (volume->blk_shift < blksize_bits(bsz)) {
- eprintk("Specified block size (%u) smaller than "
- "device %s logical block size (%u)
",
- (1 << volume->blk_shift), bio_data->path, bsz);
- err = -EINVAL;
- }
- }
- if (err < 0) {
- eprintk("Error attaching Lun %u to Target %s
",
- volume->lun, volume->target->name);
- goto out;
- }
-
- volume->blk_cnt = bio_data->bdev->bd_inode->i_size >> volume->blk_shift;
-
- /* Offer neither write nor read caching */
- ClearLURCache(volume);
- ClearLUWCache(volume);
-
- out:
- if (err < 0)
- blockio_detach(volume);
-
- return err;
-}
-
-static void
-blockio_show(struct iet_volume *volume, struct seq_file *seq)
-{
- struct blockio_data *bio_data = volume->private;
-
- /* Used to display blockio volume info in /proc/net/iet/volumes */
- seq_printf(seq, " path:%s
", bio_data->path);
-}
-
-struct iotype blockio = {
- .name = "blockio",
- .attach = blockio_attach,
- .make_request = blockio_make_request,
- .detach = blockio_detach,
- .show = blockio_show,
-};
diff --git a/ubuntu/iscsitarget/compat.h b/ubuntu/iscsitarget/compat.h
deleted file mode 100644
index 631a49c..0000000
--- a/ubuntu/iscsitarget/compat.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Kernel compatibility routines
- *
- * Copyright (C) 2008 Ross Walker <rswwalker at gmail dot com>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#ifndef __IET_COMPAT_H__
-#define __IET_COMPAT_H__
-
-#include <linux/version.h>
-
-#ifndef DECLARE_COMPLETION_ONSTACK
-#define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
-#endif
-
-#ifndef is_power_of_2
-#define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
-#endif
-
-#ifndef log2
-#define log2(n) ((sizeof(n) <= 4) ? (fls(n) - 1) : (fls64(n) - 1))
-#endif
-
-#ifndef roundup_pow_of_two
-#define roundup_pow_of_two(n) (1UL << fls_long(n - 1))
-#endif
-
-#endif /* __IET_COMPAT_H__ */
diff --git a/ubuntu/iscsitarget/config.c b/ubuntu/iscsitarget/config.c
deleted file mode 100644
index 2146504..0000000
--- a/ubuntu/iscsitarget/config.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- *
- * This code is licenced under the GPL.
- */
-
-#include <linux/proc_fs.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-
-static DEFINE_SEMAPHORE(ioctl_sem);
-
-struct proc_entries {
- const char *name;
- struct file_operations *fops;
-};
-
-static struct proc_entries iet_proc_entries[] =
-{
- {"volume", &volume_seq_fops},
- {"session", &session_seq_fops},
-};
-
-static struct proc_dir_entry *proc_iet_dir;
-
-void iet_procfs_exit(void)
-{
- int i;
-
- if (!proc_iet_dir)
- return;
-
- for (i = 0; i < ARRAY_SIZE(iet_proc_entries); i++)
- remove_proc_entry(iet_proc_entries[i].name, proc_iet_dir);
-
- remove_proc_entry(proc_iet_dir->name, proc_iet_dir->parent);
-}
-
-int iet_procfs_init(void)
-{
- int i;
- struct proc_dir_entry *ent;
-
- if (!(proc_iet_dir = proc_mkdir("iet", init_net.proc_net)))
- goto err;
-
- for (i = 0; i < ARRAY_SIZE(iet_proc_entries); i++) {
- ent = create_proc_entry(iet_proc_entries[i].name, 0, proc_iet_dir);
- if (ent)
- ent->proc_fops = iet_proc_entries[i].fops;
- else
- goto err;
- }
-
- return 0;
-
-err:
- if (proc_iet_dir)
- iet_procfs_exit();
-
- return -ENOMEM;
-}
-
-static int get_module_info(unsigned long ptr)
-{
- struct module_info info;
- int err;
-
- snprintf(info.version, sizeof(info.version), "%s", IET_VERSION_STRING);
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int get_conn_info(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct iscsi_conn *conn;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- conn = conn_lookup(session, info.cid);
- if (!conn)
- return -ENOENT;
-
- info.cid = conn->cid;
- info.stat_sn = conn->stat_sn;
- info.exp_stat_sn = conn->exp_stat_sn;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_conn(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- return conn_add(session, &info);
-}
-
-static int del_conn(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct conn_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- return conn_del(session, &info);
-}
-
-static int get_session_info(struct iscsi_target *target, unsigned long ptr)
-{
- struct iscsi_session *session;
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- session = session_lookup(target, info.sid);
- if (!session)
- return -ENOENT;
-
- info.exp_cmd_sn = session->exp_cmd_sn;
- info.max_cmd_sn = session->max_cmd_sn;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_session(struct iscsi_target *target, unsigned long ptr)
-{
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return session_add(target, &info);
-}
-
-static int del_session(struct iscsi_target *target, unsigned long ptr)
-{
- struct session_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return session_del(target, info.sid);
-}
-
-static int add_volume(struct iscsi_target *target, unsigned long ptr)
-{
- struct volume_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return volume_add(target, &info);
-}
-
-static int del_volume(struct iscsi_target *target, unsigned long ptr)
-{
- struct volume_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- return iscsi_volume_del(target, &info);
-}
-
-static int iscsi_param_config(struct iscsi_target *target, unsigned long ptr, int set)
-{
- struct iscsi_param_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- err = iscsi_param_set(target, &info, set);
- if (err < 0 || set)
- return err;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static int add_target(unsigned long ptr)
-{
- struct target_info info;
- int err;
-
- err = copy_from_user(&info, (void *) ptr, sizeof(info));
- if (err)
- return -EFAULT;
-
- err = target_add(&info);
- if (err < 0)
- return err;
-
- err = copy_to_user((void *) ptr, &info, sizeof(info));
- if (err)
- return -EFAULT;
-
- return 0;
-}
-
-static long ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
- struct iscsi_target *target = NULL;
- long err;
- u32 id;
-
- err = down_interruptible(&ioctl_sem);
- if (err < 0)
- return err;
-
- if (cmd == GET_MODULE_INFO) {
- err = get_module_info(arg);
- goto done;
- }
-
- if (cmd == ADD_TARGET) {
- err = add_target(arg);
- goto done;
- }
-
- err = get_user(id, (u32 *) arg);
- if (err < 0)
- goto done;
-
- /* locking handled in target_del */
- if (cmd == DEL_TARGET) {
- err = target_del(id);
- goto done;
- }
-
- target = target_lookup_by_id(id);
- if (!target) {
- err = -ENOENT;
- goto done;
- }
-
- err = target_lock(target, 1);
- if (err < 0)
- goto done;
-
- switch (cmd) {
- case ADD_VOLUME:
- err = add_volume(target, arg);
- break;
-
- case DEL_VOLUME:
- err = del_volume(target, arg);
- break;
-
- case ADD_SESSION:
- err = add_session(target, arg);
- break;
-
- case DEL_SESSION:
- err = del_session(target, arg);
- break;
-
- case GET_SESSION_INFO:
- err = get_session_info(target, arg);
- break;
-
- case ISCSI_PARAM_SET:
- err = iscsi_param_config(target, arg, 1);
- break;
-
- case ISCSI_PARAM_GET:
- err = iscsi_param_config(target, arg, 0);
- break;
-
- case ADD_CONN:
- err = add_conn(target, arg);
- break;
-
- case DEL_CONN:
- err = del_conn(target, arg);
- break;
-
- case GET_CONN_INFO:
- err = get_conn_info(target, arg);
- break;
- default:
- eprintk("invalid ioctl cmd %x
", cmd);
- err = -EINVAL;
- }
-
- target_unlock(target);
-done:
- up(&ioctl_sem);
-
- return err;
-}
-
-static int release(struct inode *i __attribute__((unused)),
- struct file *f __attribute__((unused)))
-{
- down(&ioctl_sem);
- target_del_all();
- up(&ioctl_sem);
-
- return 0;
-}
-
-struct file_operations ctr_fops = {
- .owner = THIS_MODULE,
- .unlocked_ioctl = ioctl,
- .compat_ioctl = ioctl,
- .release = release
-};
diff --git a/ubuntu/iscsitarget/conn.c b/ubuntu/iscsitarget/conn.c
deleted file mode 100644
index f2c98b7..0000000
--- a/ubuntu/iscsitarget/conn.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <linux/file.h>
-#include <linux/ip.h>
-#include <net/tcp.h>
-#include <scsi/scsi.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "digest.h"
-
-static void print_conn_state(char *p, size_t size, unsigned long state)
-{
- if (test_bit(CONN_ACTIVE, &state))
- snprintf(p, size, "%s", "active");
- else if (test_bit(CONN_CLOSING, &state))
- snprintf(p, size, "%s", "closing");
- else
- snprintf(p, size, "%s", "unknown");
-}
-
-static void print_digest_state(char *p, size_t size, unsigned long flags)
-{
- if (DIGEST_NONE & flags)
- snprintf(p, size, "%s", "none");
- else if (DIGEST_CRC32C & flags)
- snprintf(p, size, "%s", "crc32c");
- else
- snprintf(p, size, "%s", "unknown");
-}
-
-void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
-{
- struct iscsi_conn *conn;
- struct sock *sk;
- char buf[64];
-
- list_for_each_entry(conn, &session->conn_list, list) {
- sk = conn->sock->sk;
- switch (sk->sk_family) {
- case AF_INET:
- snprintf(buf, sizeof(buf),
- "%pI4", &inet_sk(sk)->inet_daddr);
- break;
- case AF_INET6:
- snprintf(buf, sizeof(buf), "[%pI6]",
- &inet6_sk(sk)->daddr);
- break;
- default:
- break;
- }
- seq_printf(seq, " cid:%u ip:%s ", conn->cid, buf);
- print_conn_state(buf, sizeof(buf), conn->state);
- seq_printf(seq, "state:%s ", buf);
- print_digest_state(buf, sizeof(buf), conn->hdigest_type);
- seq_printf(seq, "hd:%s ", buf);
- print_digest_state(buf, sizeof(buf), conn->ddigest_type);
- seq_printf(seq, "dd:%s
", buf);
- }
-}
-
-struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid)
-{
- struct iscsi_conn *conn;
-
- list_for_each_entry(conn, &session->conn_list, list) {
- if (conn->cid == cid)
- return conn;
- }
- return NULL;
-}
-
-static void iet_state_change(struct sock *sk)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct iscsi_target *target = conn->session->target;
-
- if (sk->sk_state != TCP_ESTABLISHED)
- conn_close(conn);
- else
- nthread_wakeup(target);
-
- target->nthread_info.old_state_change(sk);
-}
-
-static void iet_data_ready(struct sock *sk, int len)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct iscsi_target *target = conn->session->target;
-
- nthread_wakeup(target);
- target->nthread_info.old_data_ready(sk, len);
-}
-
-/*
- * @locking: grabs the target's nthread_lock to protect it from races with
- * set_conn_wspace_wait()
- */
-static void iet_write_space(struct sock *sk)
-{
- struct iscsi_conn *conn = sk->sk_user_data;
- struct network_thread_info *info = &conn->session->target->nthread_info;
-
- spin_lock_bh(&info->nthread_lock);
-
- if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
- test_bit(CONN_WSPACE_WAIT, &conn->state)) {
- clear_bit(CONN_WSPACE_WAIT, &conn->state);
- __nthread_wakeup(info);
- }
-
- spin_unlock_bh(&info->nthread_lock);
-
- info->old_write_space(sk);
-}
-
-static void iet_socket_bind(struct iscsi_conn *conn)
-{
- int opt = 1;
- mm_segment_t oldfs;
- struct iscsi_session *session = conn->session;
- struct iscsi_target *target = session->target;
-
- dprintk(D_GENERIC, "%llu
", (unsigned long long) session->sid);
-
- conn->sock = SOCKET_I(conn->file->f_dentry->d_inode);
- conn->sock->sk->sk_user_data = conn;
-
- write_lock_bh(&conn->sock->sk->sk_callback_lock);
- target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
- conn->sock->sk->sk_state_change = iet_state_change;
-
- target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
- conn->sock->sk->sk_data_ready = iet_data_ready;
-
- target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
- conn->sock->sk->sk_write_space = iet_write_space;
- write_unlock_bh(&conn->sock->sk->sk_callback_lock);
-
- oldfs = get_fs();
- set_fs(get_ds());
- conn->sock->ops->setsockopt(conn->sock, SOL_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt));
- set_fs(oldfs);
-}
-
-int conn_free(struct iscsi_conn *conn)
-{
- dprintk(D_GENERIC, "%p %#Lx %u
", conn->session,
- (unsigned long long) conn->session->sid, conn->cid);
-
- assert(atomic_read(&conn->nr_cmnds) == 0);
- assert(list_empty(&conn->pdu_list));
- assert(list_empty(&conn->write_list));
-
- list_del(&conn->list);
- list_del(&conn->poll_list);
-
- del_timer_sync(&conn->nop_timer);
- digest_cleanup(conn);
- kfree(conn);
-
- return 0;
-}
-
-static int iet_conn_alloc(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
-
- dprintk(D_SETUP, "%#Lx:%u
", (unsigned long long) session->sid, info->cid);
-
- conn = kzalloc(sizeof(*conn), GFP_KERNEL);
- if (!conn)
- return -ENOMEM;
-
- conn->session = session;
- conn->cid = info->cid;
- conn->stat_sn = info->stat_sn;
- conn->exp_stat_sn = info->exp_stat_sn;
-
- conn->hdigest_type = info->header_digest;
- conn->ddigest_type = info->data_digest;
- if (digest_init(conn) < 0) {
- kfree(conn);
- return -ENOMEM;
- }
-
- spin_lock_init(&conn->list_lock);
- atomic_set(&conn->nr_cmnds, 0);
- atomic_set(&conn->nr_busy_cmnds, 0);
- INIT_LIST_HEAD(&conn->pdu_list);
- INIT_LIST_HEAD(&conn->write_list);
- INIT_LIST_HEAD(&conn->poll_list);
- init_timer(&conn->nop_timer);
-
- list_add(&conn->list, &session->conn_list);
-
- set_bit(CONN_ACTIVE, &conn->state);
-
- conn->file = fget(info->fd);
- iet_socket_bind(conn);
-
- list_add(&conn->poll_list, &session->target->nthread_info.active_conns);
-
- nthread_wakeup(conn->session->target);
-
- return 0;
-}
-
-void conn_close(struct iscsi_conn *conn)
-{
- struct iscsi_cmnd *cmnd;
- struct iscsi_session *session = conn->session;
-
- if (test_and_clear_bit(CONN_ACTIVE, &conn->state))
- set_bit(CONN_CLOSING, &conn->state);
-
- spin_lock(&conn->list_lock);
- list_for_each_entry(cmnd, &conn->pdu_list, conn_list) {
- set_cmnd_tmfabort(cmnd);
- if (cmnd->lun) {
- ua_establish_for_session(session, cmnd->lun->lun, 0x47, 0x7f);
- iscsi_cmnd_set_sense(cmnd, UNIT_ATTENTION, 0x6e, 0x0);
- }
- }
- spin_unlock(&conn->list_lock);
-
- nthread_wakeup(conn->session->target);
-}
-
-int conn_add(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
- int err;
-
- conn = conn_lookup(session, info->cid);
- if (conn)
- conn_close(conn);
-
- err = iet_conn_alloc(session, info);
- if (!err && conn)
- err = -EEXIST;
-
- return err;
-}
-
-int conn_del(struct iscsi_session *session, struct conn_info *info)
-{
- struct iscsi_conn *conn;
- int err = -EEXIST;
-
- conn = conn_lookup(session, info->cid);
- if (!conn)
- return err;
-
- conn_close(conn);
-
- return 0;
-}
diff --git a/ubuntu/iscsitarget/digest.c b/ubuntu/iscsitarget/digest.c
deleted file mode 100644
index 32b4d76..0000000
--- a/ubuntu/iscsitarget/digest.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * iSCSI digest handling.
- * (C) 2004 - 2006 Xiranet Communications GmbH <arne.redlich@xiranet.com>
- * This code is licensed under the GPL.
- */
-
-#include <linux/types.h>
-
-#include "iscsi.h"
-#include "digest.h"
-#include "iscsi_dbg.h"
-
-void digest_alg_available(unsigned int *val)
-{
- if (*val & DIGEST_CRC32C &&
- !crypto_has_alg("crc32c", 0, CRYPTO_ALG_ASYNC)) {
- printk("CRC32C digest algorithm not available in kernel
");
- *val |= ~DIGEST_CRC32C;
- }
-}
-
-/**
- * initialize support for digest calculation.
- *
- * digest_init -
- * @conn: ptr to connection to make use of digests
- *
- * @return: 0 on success, < 0 on error
- */
-int digest_init(struct iscsi_conn *conn)
-{
- int err = 0;
-
- if (!(conn->hdigest_type & DIGEST_ALL))
- conn->hdigest_type = DIGEST_NONE;
-
- 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;
- 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;
- err = -ENOMEM;
- goto out;
- }
- }
-
-out:
- if (err)
- digest_cleanup(conn);
-
- return err;
-}
-
-/**
- * free resources used for digest calculation.
- *
- * digest_cleanup -
- * @conn: ptr to connection that made use of digests
- */
-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);
-}
-
-/**
- * debug handling of header digest errors:
- * simulates a digest error after n PDUs / every n-th PDU of type
- * HDIGEST_ERR_CORRUPT_PDU_TYPE.
- */
-static inline void __dbg_simulate_header_digest_error(struct iscsi_cmnd *cmnd)
-{
-#define HDIGEST_ERR_AFTER_N_CMNDS 1000
-#define HDIGEST_ERR_ONLY_ONCE 1
-#define HDIGEST_ERR_CORRUPT_PDU_TYPE ISCSI_OP_SCSI_CMD
-#define HDIGEST_ERR_CORRUPT_PDU_WITH_DATA_ONLY 0
-
- static int num_cmnds = 0;
- static int num_errs = 0;
-
- if (cmnd_opcode(cmnd) == HDIGEST_ERR_CORRUPT_PDU_TYPE) {
- if (HDIGEST_ERR_CORRUPT_PDU_WITH_DATA_ONLY) {
- if (cmnd->pdu.datasize)
- num_cmnds++;
- } else
- num_cmnds++;
- }
-
- if ((num_cmnds == HDIGEST_ERR_AFTER_N_CMNDS)
- && (!(HDIGEST_ERR_ONLY_ONCE && num_errs))) {
- printk("*** Faking header digest error ***
");
- printk(" cmnd: 0x%x, itt 0x%x, sn 0x%x
",
- cmnd_opcode(cmnd),
- be32_to_cpu(cmnd->pdu.bhs.itt),
- be32_to_cpu(cmnd->pdu.bhs.sn));
- cmnd->hdigest = ~cmnd->hdigest;
- /* make things even worse by manipulating header fields */
- cmnd->pdu.datasize += 8;
- num_errs++;
- num_cmnds = 0;
- }
- return;
-}
-
-/**
- * debug handling of data digest errors:
- * simulates a digest error after n PDUs / every n-th PDU of type
- * DDIGEST_ERR_CORRUPT_PDU_TYPE.
- */
-static inline void __dbg_simulate_data_digest_error(struct iscsi_cmnd *cmnd)
-{
-#define DDIGEST_ERR_AFTER_N_CMNDS 50
-#define DDIGEST_ERR_ONLY_ONCE 1
-#define DDIGEST_ERR_CORRUPT_PDU_TYPE ISCSI_OP_SCSI_DATA_OUT
-#define DDIGEST_ERR_CORRUPT_UNSOL_DATA_ONLY 0
-
- static int num_cmnds = 0;
- static int num_errs = 0;
-
- if ((cmnd->pdu.datasize)
- && (cmnd_opcode(cmnd) == DDIGEST_ERR_CORRUPT_PDU_TYPE)) {
- switch (cmnd_opcode(cmnd)) {
- case ISCSI_OP_SCSI_DATA_OUT:
- if ((DDIGEST_ERR_CORRUPT_UNSOL_DATA_ONLY)
- && (cmnd->pdu.bhs.ttt != ISCSI_RESERVED_TAG))
- break;
- default:
- num_cmnds++;
- }
- }
-
- if ((num_cmnds == DDIGEST_ERR_AFTER_N_CMNDS)
- && (!(DDIGEST_ERR_ONLY_ONCE && num_errs))
- && (cmnd->pdu.datasize)
- && (!cmnd->conn->read_overflow)) {
- printk("*** Faking data digest error: ***");
- printk(" cmnd 0x%x, itt 0x%x, sn 0x%x
",
- cmnd_opcode(cmnd),
- be32_to_cpu(cmnd->pdu.bhs.itt),
- be32_to_cpu(cmnd->pdu.bhs.sn));
- cmnd->ddigest = ~cmnd->ddigest;
- num_errs++;
- num_cmnds = 0;
- }
-}
-
-static void digest_header(struct hash_desc *hash, 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);
-
- sg_set_buf(&sg[0], &pdu->bhs, nbytes);
- if (pdu->ahssize) {
- sg_set_buf(&sg[1], pdu->ahs, pdu->ahssize);
- nbytes += pdu->ahssize;
- }
-
- crypto_hash_init(hash);
- crypto_hash_update(hash, sg, nbytes);
- crypto_hash_final(hash, crc);
-}
-
-int digest_rx_header(struct iscsi_cmnd *cmnd)
-{
- u32 crc;
-
- digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
- if (crc != cmnd->hdigest)
- return -EIO;
-
- return 0;
-}
-
-void digest_tx_header(struct iscsi_cmnd *cmnd)
-{
- digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
-}
-
-static void digest_data(struct hash_desc *hash, 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;
-
- offset += tio->offset;
- idx = offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
- count = get_pgcnt(size, offset);
- assert(idx + count <= tio->pg_cnt);
-
- assert(count <= ISCSI_CONN_IOV_MAX);
-
- sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
- crypto_hash_init(hash);
-
- for (i = 0; size; i++) {
- if (offset + size > PAGE_CACHE_SIZE)
- length = PAGE_CACHE_SIZE - offset;
- else
- length = size;
-
- sg_set_page(&sg[i], tio->pvec[idx + i], length, offset);
- size -= length;
- offset = 0;
- }
-
- sg_mark_end(&sg[i - 1]);
-
- crypto_hash_update(hash, sg, nbytes);
- crypto_hash_final(hash, crc);
-}
-
-int digest_rx_data(struct iscsi_cmnd *cmnd)
-{
- struct tio *tio;
- struct iscsi_cmnd *scsi_cmnd;
- struct iscsi_data_out_hdr *req;
- u32 offset, crc;
-
- switch (cmnd_opcode(cmnd)) {
- case ISCSI_OP_SCSI_REJECT:
- case ISCSI_OP_PDU_REJECT:
- case ISCSI_OP_DATA_REJECT:
- return 0;
- case ISCSI_OP_SCSI_DATA_OUT:
- scsi_cmnd = cmnd->req;
- req = (struct iscsi_data_out_hdr *) &cmnd->pdu.bhs;
- tio = scsi_cmnd->tio;
- offset = be32_to_cpu(req->buffer_offset);
- break;
- default:
- tio = cmnd->tio;
- offset = 0;
- }
-
- digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
-
- if (!cmnd->conn->read_overflow &&
- (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
- if (crc != cmnd->ddigest)
- return -EIO;
- }
-
- return 0;
-}
-
-void digest_tx_data(struct iscsi_cmnd *cmnd)
-{
- struct tio *tio = cmnd->tio;
- struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;
-
- assert(tio);
- digest_data(&cmnd->conn->tx_hash, cmnd, tio,
- be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
-}
diff --git a/ubuntu/iscsitarget/digest.h b/ubuntu/iscsitarget/digest.h
deleted file mode 100644
index 9b9d845..0000000
--- a/ubuntu/iscsitarget/digest.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * iSCSI digest handling.
- * (C) 2004 Xiranet Communications GmbH <arne.redlich@xiranet.com>
- * This code is licensed under the GPL.
- */
-
-#ifndef __IET_DIGEST_H__
-#define __IET_DIGEST_H__
-
-extern void digest_alg_available(unsigned int *val);
-extern int digest_init(struct iscsi_conn *conn);
-extern void digest_cleanup(struct iscsi_conn *conn);
-
-extern int digest_rx_header(struct iscsi_cmnd *cmnd);
-extern int digest_rx_data(struct iscsi_cmnd *cmnd);
-
-extern void digest_tx_header(struct iscsi_cmnd *cmnd);
-extern void digest_tx_data(struct iscsi_cmnd *cmnd);
-
-#endif /* __IET_DIGEST_H__ */
diff --git a/ubuntu/iscsitarget/event.c b/ubuntu/iscsitarget/event.c
deleted file mode 100644
index 240404d..0000000
--- a/ubuntu/iscsitarget/event.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Event notification code.
- * (C) 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- *
- * Some functions are based on audit code.
- */
-
-#include <net/tcp.h>
-#include "iet_u.h"
-#include "iscsi_dbg.h"
-
-static struct sock *nl;
-static u32 ietd_pid;
-
-static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
-{
- u32 uid, pid, seq;
- char *data;
-
- pid = NETLINK_CREDS(skb)->pid;
- uid = NETLINK_CREDS(skb)->uid;
- seq = nlh->nlmsg_seq;
- data = NLMSG_DATA(nlh);
-
- ietd_pid = pid;
-
- return 0;
-}
-
-static void event_recv_skb(struct sk_buff *skb)
-{
- int err;
- struct nlmsghdr *nlh;
- u32 rlen;
-
- while (skb->len >= NLMSG_SPACE(0)) {
- nlh = (struct nlmsghdr *)skb->data;
- if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
- break;
- rlen = NLMSG_ALIGN(nlh->nlmsg_len);
- if (rlen > skb->len)
- rlen = skb->len;
- if ((err = event_recv_msg(skb, nlh))) {
- netlink_ack(skb, nlh, -err);
- } else if (nlh->nlmsg_flags & NLM_F_ACK)
- netlink_ack(skb, nlh, 0);
- skb_pull(skb, rlen);
- }
-}
-
-static int notify(void *data, int len, int gfp_mask)
-{
- struct sk_buff *skb;
- struct nlmsghdr *nlh;
- static u32 seq = 0;
-
- if (!(skb = alloc_skb(NLMSG_SPACE(len), gfp_mask)))
- return -ENOMEM;
-
- nlh = __nlmsg_put(skb, ietd_pid, seq++, NLMSG_DONE, len - sizeof(*nlh), 0);
-
- memcpy(NLMSG_DATA(nlh), data, len);
-
- return netlink_unicast(nl, skb, ietd_pid, 0);
-}
-
-int event_send(u32 tid, u64 sid, u32 cid, u32 state, int atomic)
-{
- int err;
- struct iet_event event;
-
- event.tid = tid;
- event.sid = sid;
- event.cid = cid;
- event.state = state;
-
- err = notify(&event, NLMSG_SPACE(sizeof(struct iet_event)), 0);
-
- return err;
-}
-
-int event_init(void)
-{
- nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb,
- NULL, THIS_MODULE);
- if (!nl)
- return -ENOMEM;
- else
- return 0;
-}
-
-void event_exit(void)
-{
- netlink_kernel_release(nl);
-}
diff --git a/ubuntu/iscsitarget/file-io.c b/ubuntu/iscsitarget/file-io.c
deleted file mode 100644
index a050fcc..0000000
--- a/ubuntu/iscsitarget/file-io.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Target device file I/O.
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include <linux/types.h>
-#include <linux/blkdev.h>
-#include <linux/parser.h>
-#include <linux/writeback.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-struct fileio_data {
- char *path;
- struct file *filp;
-};
-
-static int fileio_make_request(struct iet_volume *lu, struct tio *tio, int rw)
-{
- struct fileio_data *p = lu->private;
- struct file *filp;
- mm_segment_t oldfs;
- struct page *page;
- u32 offset, size;
- loff_t ppos, count;
- char *buf;
- int i, err = 0;
- ssize_t ret;
-
- assert(p);
- filp = p->filp;
- size = tio->size;
- offset= tio->offset;
-
- ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- ppos += offset;
-
- for (i = 0; i < tio->pg_cnt; i++) {
- page = tio->pvec[i];
- assert(page);
- buf = page_address(page);
- buf += offset;
-
- if (offset + size > PAGE_CACHE_SIZE)
- count = PAGE_CACHE_SIZE - offset;
- else
- count = size;
-
- oldfs = get_fs();
- set_fs(get_ds());
-
- if (rw == READ)
- ret = vfs_read(filp, buf, count, &ppos);
- else
- ret = vfs_write(filp, buf, count, &ppos);
-
- set_fs(oldfs);
-
- if (ret != count) {
- eprintk("I/O error %lld, %ld
", count, (long) ret);
- err = -EIO;
- }
-
- size -= count;
- offset = 0;
- }
- assert(!size);
-
- return err;
-}
-
-static int fileio_sync(struct iet_volume *lu, struct tio *tio)
-{
- struct fileio_data *p = lu->private;
- struct inode *inode = p->filp->f_dentry->d_inode;
- struct address_space *mapping = inode->i_mapping;
- loff_t ppos, count;
- int res;
-
- if (tio) {
- ppos = (loff_t) tio->idx << PAGE_CACHE_SHIFT;
- ppos += tio->offset;
- count = tio->size;
- } else {
- ppos = 0;
- count = lu->blk_cnt << lu->blk_shift;
- }
-
- res = filemap_write_and_wait_range(mapping, ppos, ppos + count - 1);
- if (res) {
- eprintk("I/O error: syncing pages failed: %d
", res);
- return -EIO;
- } else
- return 0;
-}
-
-static int open_path(struct iet_volume *volume, const char *path)
-{
- int err = 0;
- struct fileio_data *info = volume->private;
- struct file *filp;
- mm_segment_t oldfs;
- int flags;
-
- info->path = kstrdup(path, GFP_KERNEL);
- if (!info->path)
- return -ENOMEM;
-
- oldfs = get_fs();
- set_fs(get_ds());
- flags = (LUReadonly(volume) ? O_RDONLY : O_RDWR) | O_LARGEFILE;
- filp = filp_open(path, flags, 0);
- set_fs(oldfs);
-
- if (IS_ERR(filp)) {
- err = PTR_ERR(filp);
- eprintk("Can't open %s %d
", path, err);
- info->filp = NULL;
- } else
- info->filp = filp;
-
- return err;
-}
-
-enum {
- opt_path, opt_ignore, opt_err,
-};
-
-static match_table_t tokens = {
- {opt_path, "path=%s"},
- {opt_ignore, "scsiid=%s"},
- {opt_ignore, "scsisn=%s"},
- {opt_ignore, "type=%s"},
- {opt_ignore, "iomode=%s"},
- {opt_ignore, "blocksize=%s"},
- {opt_err, NULL},
-};
-
-static int parse_fileio_params(struct iet_volume *volume, char *params)
-{
- struct fileio_data *info = volume->private;
- int err = 0;
- char *p, *q;
-
- while ((p = strsep(&params, ",")) != NULL) {
- substring_t args[MAX_OPT_ARGS];
- int token;
- if (!*p)
- continue;
- iet_strtolower(p);
- token = match_token(p, tokens, args);
- switch (token) {
- case opt_path:
- if (info->path) {
- iprintk("Target %s, LUN %u: "
- "duplicate "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- goto out;
- }
- if (!(q = match_strdup(&args[0]))) {
- err = -ENOMEM;
- goto out;
- }
- err = open_path(volume, q);
- kfree(q);
- if (err < 0)
- goto out;
- break;
- case opt_ignore:
- break;
- default:
- iprintk("Target %s, LUN %u: unknown param %s
",
- volume->target->name, volume->lun, p);
- return -EINVAL;
- }
- }
-
- if (!info->path) {
- iprintk("Target %s, LUN %u: missing "Path" param
",
- volume->target->name, volume->lun);
- err = -EINVAL;
- }
-out:
- return err;
-}
-
-static void fileio_detach(struct iet_volume *lu)
-{
- struct fileio_data *p = lu->private;
-
- kfree(p->path);
- if (p->filp)
- filp_close(p->filp, NULL);
- kfree(p);
- lu->private = NULL;
-}
-
-static int fileio_attach(struct iet_volume *lu, char *args)
-{
- int err = 0;
- struct fileio_data *p;
- struct inode *inode;
-
- if (lu->private) {
- printk("already attached ? %d
", lu->lun);
- return -EBUSY;
- }
-
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return -ENOMEM;
-
- lu->private = p;
-
- if ((err = parse_fileio_params(lu, args)) < 0) {
- eprintk("%d
", err);
- goto out;
- }
- inode = p->filp->f_dentry->d_inode;
-
- if (S_ISREG(inode->i_mode))
- ;
- else if (S_ISBLK(inode->i_mode))
- inode = inode->i_bdev->bd_inode;
- else {
- err = -EINVAL;
- goto out;
- }
-
- if (!lu->blk_shift)
- lu->blk_shift = blksize_bits(IET_DEF_BLOCK_SIZE);
-
- lu->blk_cnt = inode->i_size >> lu->blk_shift;
-
- /* we're using the page cache */
- SetLURCache(lu);
-out:
- if (err < 0)
- fileio_detach(lu);
- return err;
-}
-
-static void fileio_show(struct iet_volume *lu, struct seq_file *seq)
-{
- struct fileio_data *p = lu->private;
- seq_printf(seq, " path:%s
", p->path);
-}
-
-struct iotype fileio =
-{
- .name = "fileio",
- .attach = fileio_attach,
- .make_request = fileio_make_request,
- .sync = fileio_sync,
- .detach = fileio_detach,
- .show = fileio_show,
-};
diff --git a/ubuntu/iscsitarget/include/iet_u.h b/ubuntu/iscsitarget/include/iet_u.h
deleted file mode 100644
index 6fdc716..0000000
--- a/ubuntu/iscsitarget/include/iet_u.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef _IET_U_H
-#define _IET_U_H
-
-#define IET_VERSION_STRING "1.4.20.2"
-
-/* The maximum length of 223 bytes in the RFC. */
-#define ISCSI_NAME_LEN 256
-#define ISCSI_ARGS_LEN 2048
-
-#define ISCSI_LISTEN_PORT 3260
-
-#define SCSI_ID_LEN 16
-#define SCSI_SN_LEN (SCSI_ID_LEN * 2)
-
-#ifndef aligned_u64
-#define aligned_u64 unsigned long long __attribute__((aligned(8)))
-#endif
-
-struct module_info {
- char version[128];
-};
-
-struct target_info {
- u32 tid;
- char name[ISCSI_NAME_LEN];
-};
-
-struct volume_info {
- u32 tid;
- u32 lun;
- aligned_u64 args_ptr;
- u32 args_len;
-};
-
-struct session_info {
- u32 tid;
-
- aligned_u64 sid;
- char initiator_name[ISCSI_NAME_LEN];
- u32 exp_cmd_sn;
- u32 max_cmd_sn;
-};
-
-#define DIGEST_ALL (DIGEST_NONE | DIGEST_CRC32C)
-#define DIGEST_NONE (1 << 0)
-#define DIGEST_CRC32C (1 << 1)
-
-struct conn_info {
- u32 tid;
- aligned_u64 sid;
-
- u32 cid;
- u32 stat_sn;
- u32 exp_stat_sn;
- int header_digest;
- int data_digest;
- int fd;
-};
-
-enum {
- key_initial_r2t,
- key_immediate_data,
- key_max_connections,
- key_max_recv_data_length,
- key_max_xmit_data_length,
- key_max_burst_length,
- key_first_burst_length,
- key_default_wait_time,
- key_default_retain_time,
- key_max_outstanding_r2t,
- key_data_pdu_inorder,
- key_data_sequence_inorder,
- key_error_recovery_level,
- key_header_digest,
- key_data_digest,
- key_ofmarker,
- key_ifmarker,
- key_ofmarkint,
- key_ifmarkint,
- session_key_last,
-};
-
-enum {
- key_wthreads,
- key_target_type,
- key_queued_cmnds,
- key_nop_interval,
- key_nop_timeout,
- target_key_last,
-};
-
-enum {
- key_session,
- key_target,
-};
-
-struct iscsi_param_info {
- u32 tid;
- aligned_u64 sid;
-
- u32 param_type;
- u32 partial;
-
- u32 session_param[session_key_last];
- u32 target_param[target_key_last];
-};
-
-enum iet_event_state {
- E_CONN_CLOSE,
-};
-
-struct iet_event {
- u32 tid;
- aligned_u64 sid;
- u32 cid;
- u32 state;
-};
-
-#define DEFAULT_NR_WTHREADS 8
-#define MIN_NR_WTHREADS 1
-#define MAX_NR_WTHREADS 128
-
-#define DEFAULT_NR_QUEUED_CMNDS 32
-#define MIN_NR_QUEUED_CMNDS 1
-#define MAX_NR_QUEUED_CMNDS 256
-
-#define DEFAULT_NOP_INTERVAL 0
-#define MIN_NOP_INTERVAL 0
-#define MAX_NOP_INTERVAL 90
-
-#define DEFAULT_NOP_TIMEOUT 0
-#define MIN_NOP_TIMEOUT 0
-#define MAX_NOP_TIMEOUT 90
-
-#define NETLINK_IET 21
-
-#define GET_MODULE_INFO _IOW('i', 20, struct module_info)
-#define ADD_TARGET _IOWR('i', 21, struct target_info)
-#define DEL_TARGET _IOW('i', 22, struct target_info)
-#define ADD_VOLUME _IOW('i', 24, struct volume_info)
-#define DEL_VOLUME _IOW('i', 25, struct volume_info)
-#define ADD_SESSION _IOW('i', 26, struct session_info)
-#define DEL_SESSION _IOW('i', 27, struct session_info)
-#define GET_SESSION_INFO _IOWR('i', 28, struct session_info)
-#define ADD_CONN _IOW('i', 29, struct conn_info)
-#define DEL_CONN _IOW('i', 30, struct conn_info)
-#define GET_CONN_INFO _IOWR('i', 31, struct conn_info)
-#define ISCSI_PARAM_SET _IOW('i', 32, struct iscsi_param_info)
-#define ISCSI_PARAM_GET _IOWR('i', 33, struct iscsi_param_info)
-
-#endif
diff --git a/ubuntu/iscsitarget/iotype.c b/ubuntu/iscsitarget/iotype.c
deleted file mode 100644
index 007d1fe..0000000
--- a/ubuntu/iscsitarget/iotype.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Manager for various I/O types.
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include "iscsi.h"
-#include "iotype.h"
-#include "iscsi_dbg.h"
-
-static LIST_HEAD(iotypes);
-static rwlock_t iotypes_lock = __RW_LOCK_UNLOCKED(iotypes_lock);
-
-static struct iotype *find_iotype(const char *name)
-{
- struct iotype *iot = NULL;
-
- list_for_each_entry(iot, &iotypes, iot_list) {
- if (strcmp(iot->name, name) == 0)
- return iot;
- }
- return NULL;
-}
-
-struct iotype *get_iotype(const char *name)
-{
- struct iotype *iot;
-
- read_lock(&iotypes_lock);
- iot = find_iotype(name);
- read_unlock(&iotypes_lock);
-
- return iot;
-}
-
-void put_iotype(struct iotype *iot)
-{
- if (!iot)
- return;
- return;
-}
-
-static int register_iotype(struct iotype *iot)
-{
- int err = 0;
- struct iotype *p;
-
- write_lock(&iotypes_lock);
-
- p = find_iotype(iot->name);
- if (p)
- err = -EBUSY;
- else
- list_add_tail(&iot->iot_list, &iotypes);
-
- write_unlock(&iotypes_lock);
-
- return err;
-}
-
-static int unregister_iotype(struct iotype *iot)
-{
- int err = 0;
- struct iotype *p;
-
- write_lock(&iotypes_lock);
-
- p = find_iotype(iot->name);
- if (p && p == iot)
- list_del_init(&iot->iot_list);
- else
- err = -EINVAL;
-
- write_unlock(&iotypes_lock);
-
-
- return err;
-}
-
-struct iotype *iotype_array[] = {
- &fileio,
- &blockio,
- &nullio,
-};
-
-int iotype_init(void)
-{
- int i, err;
-
- for (i = 0; i < ARRAY_SIZE(iotype_array); i++) {
- if (!(err = register_iotype(iotype_array[i])))
- iprintk("Registered io type %s
",
- iotype_array[i]->name);
- else {
- eprintk("Failed to register io type %s
",
- iotype_array[i]->name);
- break;
- }
- }
-
- return err;
-}
-
-void iotype_exit(void)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(iotype_array); i++)
- unregister_iotype(iotype_array[i]);
-}
diff --git a/ubuntu/iscsitarget/iotype.h b/ubuntu/iscsitarget/iotype.h
deleted file mode 100644
index db7956a..0000000
--- a/ubuntu/iscsitarget/iotype.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
- * This code is licenced under the GPL.
- */
-
-#include <linux/ctype.h>
-#include "iscsi.h"
-
-#ifndef __IOTYPE_H__
-#define __IOTYPE_H__
-
-struct iotype {
- const char *name;
- struct list_head iot_list;
-
- int (*attach)(struct iet_volume *dev, char *args);
- int (*make_request)(struct iet_volume *dev, struct tio *tio, int rw);
- int (*sync)(struct iet_volume *dev, struct tio *tio);
- void (*detach)(struct iet_volume *dev);
- void (*show)(struct iet_volume *dev, struct seq_file *seq);
-};
-
-extern struct iotype fileio;
-extern struct iotype nullio;
-extern struct iotype blockio;
-
-extern int iotype_init(void);
-extern void iotype_exit(void);
-
-/* For option parameter parsing.
- * This is slightly iet specific: we only tolower() up to the first '='.
- * Note that this changes *c _in place_, but our parsing
- * routines copy the input to a scratch page before parsing anyways. */
-static inline void iet_strtolower(char *c)
-{
- if (!c)
- return;
- for (; *c && *c != '='; c++)
- *c = tolower(*c);
-}
-
-#endif
diff --git a/ubuntu/iscsitarget/iscsi.c b/ubuntu/iscsitarget/iscsi.c
deleted file mode 100644
index 05197f2..0000000
--- a/ubuntu/iscsitarget/iscsi.c
+++ /dev/null
@@ -1,1967 +0,0 @@
-/*
- * Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>
- * Copyright (C) 2008 Arne Redlich <agr@powerkom-dd.de>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <linux/module.h>
-#include <linux/hash.h>
-#include <net/tcp.h>
-#include <scsi/scsi.h>
-
-#include "iscsi.h"
-#include "iscsi_dbg.h"
-#include "iotype.h"
-
-unsigned long debug_enable_flags;
-unsigned long worker_thread_pool_size;
-
-static struct kmem_cache *iscsi_cmnd_cache;
-static u8 dummy_data[PAGE_SIZE];
-
-static int ctr_major;
-static char ctr_name[] = "ietctl";
-extern struct file_operations ctr_fops;
-
-static u32 cmnd_write_size(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_scsi_cmd_hdr *hdr = cmnd_hdr(cmnd);
-
- if (hdr->flags & ISCSI_CMD_WRITE)
- return be32_to_cpu(hdr->data_length);
- return 0;
-}
-
-static u32 cmnd_read_size(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_scsi_cmd_hdr *hdr = cmnd_hdr(cmnd);
-
- if (hdr->flags & ISCSI_CMD_READ) {
- struct iscsi_rlength_ahdr *ahdr =
- (struct iscsi_rlength_ahdr *)cmnd->pdu.ahs;
-
- if (!(hdr->flags & ISCSI_CMD_WRITE))
- return be32_to_cpu(hdr->data_length);
- if (ahdr && ahdr->ahstype == ISCSI_AHSTYPE_RLENGTH)
- return be32_to_cpu(ahdr->read_length);
- }
- return 0;
-}
-
-static void iscsi_device_queue_cmnd(struct iscsi_cmnd *cmnd)
-{
- set_cmnd_waitio(cmnd);
- wthread_queue(cmnd);
-}
-
-static void iscsi_scsi_queuecmnd(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_queue *queue = &cmnd->lun->queue;
-
- dprintk(D_GENERIC, "%p
", cmnd);
-
- if ((cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) != ISCSI_CMD_UNTAGGED &&
- (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) != ISCSI_CMD_SIMPLE) {
- cmnd->pdu.bhs.flags &= ~ISCSI_CMD_ATTR_MASK;
- cmnd->pdu.bhs.flags |= ISCSI_CMD_UNTAGGED;
- }
-
- spin_lock(&queue->queue_lock);
-
- set_cmnd_queued(cmnd);
-
- switch (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- if (!list_empty(&queue->wait_list) || queue->ordered_cmnd)
- goto pending;
- queue->active_cnt++;
- break;
-
- default:
- BUG();
- }
- spin_unlock(&queue->queue_lock);
-
- iscsi_device_queue_cmnd(cmnd);
- return;
- pending:
- assert(list_empty(&cmnd->list));
-
- list_add_tail(&cmnd->list, &queue->wait_list);
- spin_unlock(&queue->queue_lock);
- return;
-}
-
-static void iscsi_scsi_dequeuecmnd(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_queue *queue;
-
- if (!cmnd->lun)
- return;
- queue = &cmnd->lun->queue;
- spin_lock(&queue->queue_lock);
- switch (cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- --queue->active_cnt;
- break;
- case ISCSI_CMD_ORDERED:
- case ISCSI_CMD_HEAD_OF_QUEUE:
- case ISCSI_CMD_ACA:
- BUG();
- default:
- /* Should the iscsi_scsi_queuecmnd func reject this ? */
- break;
- }
-
- while (!list_empty(&queue->wait_list)) {
- cmnd = list_entry(queue->wait_list.next, struct iscsi_cmnd, list);
- switch ((cmnd->pdu.bhs.flags & ISCSI_CMD_ATTR_MASK)) {
- case ISCSI_CMD_UNTAGGED:
- case ISCSI_CMD_SIMPLE:
- list_del_init(&cmnd->list);
- queue->active_cnt++;
- iscsi_device_queue_cmnd(cmnd);
- break;
- case ISCSI_CMD_ORDERED:
- case ISCSI_CMD_HEAD_OF_QUEUE:
- case ISCSI_CMD_ACA:
- BUG();
- }
- }
-
- spin_unlock(&queue->queue_lock);
-
- return;
-}
-
-/**
- * create a new command.
- *
- * iscsi_cmnd_create -
- * @conn: ptr to connection (for i/o)
- *
- * @return ptr to command or NULL
- */
-
-struct iscsi_cmnd *cmnd_alloc(struct iscsi_conn *conn, int req)
-{
- struct iscsi_cmnd *cmnd;
-
- /* TODO: async interface is necessary ? */
- cmnd = kmem_cache_alloc(iscsi_cmnd_cache, GFP_KERNEL|__GFP_NOFAIL);
-
- memset(cmnd, 0, sizeof(*cmnd));
- INIT_LIST_HEAD(&cmnd->list);
- INIT_LIST_HEAD(&cmnd->pdu_list);
- INIT_LIST_HEAD(&cmnd->conn_list);
- INIT_LIST_HEAD(&cmnd->hash_list);
- cmnd->conn = conn;
- spin_lock(&conn->list_lock);
- atomic_inc(&conn->nr_cmnds);
- if (req)
- list_add_tail(&cmnd->conn_list, &conn->pdu_list);
- spin_unlock(&conn->list_lock);
- cmnd->tio = NULL;
-
- dprintk(D_GENERIC, "%p:%p
", conn, cmnd);
-
- return cmnd;
-}
-
-/**
- * create a new command used as response.
- *
- * iscsi_cmnd_create_rsp_cmnd -
- * @cmnd: ptr to request command
- *
- * @return ptr to response command or NULL
- */
-
-static struct iscsi_cmnd *iscsi_cmnd_create_rsp_cmnd(struct iscsi_cmnd *cmnd, int final)
-{
- struct iscsi_cmnd *rsp = cmnd_alloc(cmnd->conn, 0);
-
- if (final)
- set_cmnd_final(rsp);
- list_add_tail(&rsp->pdu_list, &cmnd->pdu_list);
- rsp->req = cmnd;
- return rsp;
-}
-
-static struct iscsi_cmnd *get_rsp_cmnd(struct iscsi_cmnd *req)
-{
- return list_entry(req->pdu_list.prev, struct iscsi_cmnd, pdu_list);
-}
-
-static void iscsi_cmnds_init_write(struct list_head *send)
-{
- struct iscsi_cmnd *cmnd = list_entry(send->next, struct iscsi_cmnd, list);
- struct iscsi_conn *conn = cmnd->conn;
- struct list_head *pos, *next;
-
- spin_lock(&conn->list_lock);
-
- list_for_each_safe(pos, next, send) {
- cmnd = list_entry(pos, struct iscsi_cmnd, list);
-
- dprintk(D_GENERIC, "%p:%x
", cmnd, cmnd_opcode(cmnd));
-
- list_del_init(&cmnd->list);
- assert(conn == cmnd->conn);
- list_add_tail(&cmnd->list, &conn->write_list);
- }
-
- spin_unlock(&conn->list_lock);
-
- nthread_wakeup(conn->session->target);
-}
-
-static void iscsi_cmnd_init_write(struct iscsi_cmnd *cmnd)
-{
- LIST_HEAD(head);
-
- if (!list_empty(&cmnd->list)) {
- eprintk("%x %x %x %x %lx %u %u %u %u %u %u %u %d %d
",
- cmnd_itt(cmnd), cmnd_ttt(cmnd), cmnd_opcode(cmnd),
- cmnd_scsicode(cmnd), cmnd->flags, cmnd->r2t_sn,
- cmnd->r2t_length, cmnd->is_unsolicited_data,
- cmnd->target_task_tag, cmnd->outstanding_r2t,
- cmnd->hdigest, cmnd->ddigest,
- list_empty(&cmnd->pdu_list), list_empty(&cmnd->hash_list));
-
- assert(list_empty(&cmnd->list));
- }
- list_add(&cmnd->list, &head);
- iscsi_cmnds_init_write(&head);
-}
-
-static void do_send_data_rsp(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct iscsi_cmnd *data_cmnd;
- struct tio *tio = cmnd->tio;
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd);
- struct iscsi_data_in_hdr *rsp;
- u32 pdusize, expsize, scsisize, size, offset, sn;
- LIST_HEAD(send);
-
- dprintk(D_GENERIC, "%p
", cmnd);
- pdusize = conn->session->param.max_xmit_data_length;
- expsize = cmnd_read_size(cmnd);
- size = min(expsize, tio->size);
- offset = 0;
- sn = 0;
-
- while (1) {
- data_cmnd = iscsi_cmnd_create_rsp_cmnd(cmnd, size <= pdusize);
- tio_get(tio);
- data_cmnd->tio = tio;
- rsp = (struct iscsi_data_in_hdr *)&data_cmnd->pdu.bhs;
-
- rsp->opcode = ISCSI_OP_SCSI_DATA_IN;
- rsp->itt = req->itt;
- rsp->ttt = cpu_to_be32(ISCSI_RESERVED_TAG);
- rsp->buffer_offset = offset;
- rsp->data_sn = cpu_to_be32(sn);
-
- if (size <= pdusize) {
- data_cmnd->pdu.datasize = size;
- rsp->flags = ISCSI_FLG_FINAL | ISCSI_FLG_STATUS;
-
- scsisize = tio->size;
- if (scsisize < expsize) {
- rsp->flags |= ISCSI_FLG_RESIDUAL_UNDERFLOW;
- size = expsize - scsisize;
- } else if (scsisize > expsize) {
- rsp->flags |= ISCSI_FLG_RESIDUAL_OVERFLOW;
- size = scsisize - expsize;
- } else
- size = 0;
- rsp->residual_count = cpu_to_be32(size);
- list_add_tail(&data_cmnd->list, &send);
-
- break;
- }
-
- data_cmnd->pdu.datasize = pdusize;
-
- size -= pdusize;
- offset += pdusize;
- sn++;
-
- list_add_tail(&data_cmnd->list, &send);
- }
-
- iscsi_cmnds_init_write(&send);
-}
-
-static struct iscsi_cmnd *create_scsi_rsp(struct iscsi_cmnd *req)
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_scsi_cmd_hdr *req_hdr = cmnd_hdr(req);
- struct iscsi_scsi_rsp_hdr *rsp_hdr;
- struct iscsi_sense_data *sense;
-
- rsp = iscsi_cmnd_create_rsp_cmnd(req, 1);
-
- rsp_hdr = (struct iscsi_scsi_rsp_hdr *)&rsp->pdu.bhs;
- rsp_hdr->opcode = ISCSI_OP_SCSI_RSP;
- rsp_hdr->flags = ISCSI_FLG_FINAL;
- rsp_hdr->response = ISCSI_RESPONSE_COMMAND_COMPLETED;
- rsp_hdr->cmd_status = req->status;
- rsp_hdr->itt = req_hdr->itt;
-
- if (req->status == SAM_STAT_CHECK_CONDITION) {
- assert(!rsp->tio);
- rsp->tio = tio_alloc(1);
- sense = (struct iscsi_sense_data *)
- page_address(rsp->tio->pvec[0]);
-
- assert(sense);
- clear_page(sense);
- sense->length = cpu_to_be16(IET_SENSE_BUF_SIZE);
-
- memcpy(sense->data, req->sense_buf, IET_SENSE_BUF_SIZE);
- rsp->pdu.datasize = sizeof(struct iscsi_sense_data) +
- IET_SENSE_BUF_SIZE;
-
- rsp->tio->size = (rsp->pdu.datasize + 3) & -4;
- rsp->tio->offset = 0;
- }
-
- return rsp;
-}
-
-void iscsi_cmnd_set_sense(struct iscsi_cmnd *cmnd, u8 sense_key, u8 asc,
- u8 ascq)
-{
- cmnd->status = SAM_STAT_CHECK_CONDITION;
-
- cmnd->sense_buf[0] = 0xf0;
- cmnd->sense_buf[2] = sense_key;
- cmnd->sense_buf[7] = 6; // Additional sense length
- cmnd->sense_buf[12] = asc;
- cmnd->sense_buf[13] = ascq;
-
- /* Call to ACA/UAI handler */
-}
-
-static struct iscsi_cmnd *create_sense_rsp(struct iscsi_cmnd *req,
- u8 sense_key, u8 asc, u8 ascq)
-{
- iscsi_cmnd_set_sense(req, sense_key, asc, ascq);
- return create_scsi_rsp(req);
-}
-
-void send_scsi_rsp(struct iscsi_cmnd *req, void (*func)(struct iscsi_cmnd *))
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_scsi_rsp_hdr *rsp_hdr;
- u32 size;
-
- func(req);
- rsp = create_scsi_rsp(req);
-
- switch (req->status) {
- case SAM_STAT_GOOD:
- case SAM_STAT_RESERVATION_CONFLICT:
- rsp_hdr = (struct iscsi_scsi_rsp_hdr *) &rsp->pdu.bhs;
- if ((size = cmnd_read_size(req)) != 0) {
- rsp_hdr->flags |= ISCSI_FLG_RESIDUAL_UNDERFLOW;
- rsp_hdr->residual_count = cpu_to_be32(size);
- }
- break;
- default:
- break;
- }
-
- iscsi_cmnd_init_write(rsp);
-}
-
-void send_data_rsp(struct iscsi_cmnd *req, void (*func)(struct iscsi_cmnd *))
-{
- struct iscsi_cmnd *rsp;
-
- func(req);
-
- if (req->status == SAM_STAT_GOOD)
- do_send_data_rsp(req);
- else {
- rsp = create_scsi_rsp(req);
- iscsi_cmnd_init_write(rsp);
- }
-}
-
-/**
- * Free a command.
- * Also frees the additional header.
- *
- * iscsi_cmnd_remove -
- * @cmnd: ptr to command
- */
-
-static void iscsi_cmnd_remove(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn;
-
- if (!cmnd)
- return;
-
- if (cmnd_timer_active(cmnd)) {
- clear_cmnd_timer_active(cmnd);
- del_timer_sync(&cmnd->timer);
- }
-
- dprintk(D_GENERIC, "%p
", cmnd);
- conn = cmnd->conn;
- kfree(cmnd->pdu.ahs);
-
- if (!list_empty(&cmnd->list)) {
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd);
-
- eprintk("cmnd %p still on some list?, %x, %x, %x, %x, %x, %x, %x %lx
",
- cmnd, req->opcode, req->scb[0], req->flags, req->itt,
- be32_to_cpu(req->data_length),
- req->cmd_sn, be32_to_cpu(cmnd->pdu.datasize),
- conn->state);
-
- if (cmnd->req) {
- struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd->req);
- eprintk("%p %x %u
", req, req->opcode, req->scb[0]);
- }
- dump_stack();
- BUG();
- }
- list_del(&cmnd->list);
- spin_lock(&conn->list_lock);
- atomic_dec(&conn->nr_cmnds);
- list_del(&cmnd->conn_list);
- spin_unlock(&conn->list_lock);
-
- if (cmnd->tio)
- tio_put(cmnd->tio);
-
- kmem_cache_free(iscsi_cmnd_cache, cmnd);
-}
-
-static void cmnd_skip_pdu(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct tio *tio = cmnd->tio;
- char *addr;
- u32 size;
- int i;
-
- eprintk("%x %x %x %u
", cmnd_itt(cmnd), cmnd_opcode(cmnd),
- cmnd_hdr(cmnd)->scb[0], cmnd->pdu.datasize);
-
- if (!(size = cmnd->pdu.datasize))
- return;
-
- if (tio)
- assert(tio->pg_cnt > 0);
- else
- tio = cmnd->tio = tio_alloc(1);
-
- addr = page_address(tio->pvec[0]);
- assert(addr);
- size = (size + 3) & -4;
- conn->read_size = size;
- for (i = 0; size > PAGE_CACHE_SIZE; i++, size -= PAGE_CACHE_SIZE) {
- assert(i < ISCSI_CONN_IOV_MAX);
- conn->read_iov[i].iov_base = addr;
- conn->read_iov[i].iov_len = PAGE_CACHE_SIZE;
- }
- conn->read_iov[i].iov_base = addr;
- conn->read_iov[i].iov_len = size;
- conn->read_msg.msg_iov = conn->read_iov;
- conn->read_msg.msg_iovlen = ++i;
-}
-
-static void iscsi_cmnd_reject(struct iscsi_cmnd *req, int reason)
-{
- struct iscsi_cmnd *rsp;
- struct iscsi_reject_hdr *rsp_hdr;
- struct tio *tio;
- char *addr;
-
- rsp = iscsi_cmnd_create_rsp_cmnd(req, 1);
- rsp_hdr = (struct iscsi_reject_hdr *)&rsp->pdu.bhs;
-
- rsp_hdr->opcode = ISCSI_OP_REJECT;
- rsp_hdr->ffffffff = ISCSI_RESERVED_TAG;
- rsp_hdr->reason = reason;
-
- rsp->tio = tio = tio_alloc(1);
- addr = page_address(tio->pvec[0]);
- clear_page(addr);
- memcpy(addr, &req->pdu.bhs, sizeof(struct iscsi_hdr));
- tio->size = rsp->pdu.datasize = sizeof(struct iscsi_hdr);
- cmnd_skip_pdu(req);
-
- req->pdu.bhs.opcode = ISCSI_OP_PDU_REJECT;
-}
-
-static void cmnd_set_sn(struct iscsi_cmnd *cmnd, int set_stat_sn)
-{
- struct iscsi_conn *conn = cmnd->conn;
- struct iscsi_session *sess = conn->session;
-
- if (set_stat_sn)
- cmnd->pdu.bhs.sn = cpu_to_be32(conn->stat_sn++);
- cmnd->pdu.bhs.exp_sn = cpu_to_be32(sess->exp_cmd_sn);
- cmnd->pdu.bhs.max_sn = cpu_to_be32(sess->exp_cmd_sn + sess->max_queued_cmnds);
-}
-
-static void update_stat_sn(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_conn *conn = cmnd->conn;
- u32 exp_stat_sn;
-
- cmnd->pdu.bhs.exp_sn = exp_stat_sn = be32_to_cpu(cmnd->pdu.bhs.exp_sn);
- dprintk(D_GENERIC, "%x,%x
", cmnd_opcode(cmnd), exp_stat_sn);
- if ((int)(exp_stat_sn - conn->exp_stat_sn) > 0 &&
- (int)(exp_stat_sn - conn->stat_sn) <= 0) {
- // free pdu resources
- cmnd->conn->exp_stat_sn = exp_stat_sn;
- }
-}
-
-static int check_cmd_sn(struct iscsi_cmnd *cmnd)
-{
- struct iscsi_session *session = cmnd->conn->session;
- u32 cmd_sn;
-
- cmnd->pdu.bhs.sn = cmd_sn = be32_to_cpu(cmnd->pdu.bhs.sn);
-
- dprintk(D_GENERIC, "cmd_sn(%u) exp_cmd_sn(%u) max_cmd_sn(%u)
",
- cmd_sn, session->exp_cmd_sn, session->max_cmd_sn);
-
- if (between(cmd_sn, session->exp_cmd_sn, session->max_cmd_sn))
- return 0;
- else if (cmnd_immediate(cmnd))
- return 0;
-
- eprintk("sequence error: cmd_sn(%u) exp_cmd_sn(%u) max_cmd_sn(%u)
",
- cmd_sn, session->exp_cmd_sn, session->max_cmd_sn);
-
- set_cmnd_tmfabort(cmnd);
-
- return -ISCSI_REASON_PROTOCOL_ERROR;
-}
-
-static struct iscsi_cmnd *__cmnd_find_hash(struct iscsi_session *session, u32 itt, u32 ttt)
-{
- struct list_head *head;
- struct iscsi_cmnd *cmnd;
-
- head = &session->cmnd_hash[cmnd_hashfn(itt)];
-
- list_for_each_entry(cmnd, head, hash_list) {
- if (cmnd->pdu.bhs.itt == itt) {
- if ((ttt != ISCSI_RESERVED_TAG) && (ttt != cmnd->target_task_tag))
- continue;
- return cmnd;
- }
- }
-
- return NULL;
-}
-
-static struct iscsi_cmnd *cmnd_find_hash(struct iscsi_session *session, u32 itt, u32 ttt)
-{
- struct iscsi_cmnd *cmnd;
-
- spin_lock(&session->cmnd_hash_lock);
-
- cmnd = __cmnd_find_hash(session, itt, ttt);
-
- spin_unlock(&session->cmnd_hash_lock);
-
- return cmnd;
-}
-
-static int cmnd_insert_hash_ttt(struct iscsi_cmnd *cmnd, u32 ttt)
-{
- struct iscsi_session
 

Thread Tools




All times are GMT. The time now is 11:58 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org