Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Kernel Team (http://www.linux-archive.org/ubuntu-kernel-team/)
-   -   Update for iscsitarget in hardy lum. (http://www.linux-archive.org/ubuntu-kernel-team/66937-update-iscsitarget-hardy-lum.html)

"Chuck Short" 04-09-2008 05:02 PM

Update for iscsitarget in hardy lum.
 
Here is the fix for 2.6.24. Please apply.

Thanks
chuck
From 48bd0467ae86fa3896b87305bcd1068a3ada3345 Mon Sep 17 00:00:00 2001
From: Chuck Short <chuck.short@canonical.com>
Date: Wed, 9 Apr 2008 12:57:22 -0400
Subject: [PATCH] UBUNTU: Update iscsitarget drive
OriginalAuthor: Chuck Short <chuck.short@canonical.com>
Bug: 208281

Signed-off-by: Chuck Short <chuck.short@canonical.com>
---
ubuntu/block/iscsitarget/block-io.c | 16 ++-----
ubuntu/block/iscsitarget/config.c | 2 +-
ubuntu/block/iscsitarget/digest.c | 17 ++++----
ubuntu/block/iscsitarget/event.c | 17 +------
ubuntu/block/iscsitarget/iotype.c | 6 ++-
ubuntu/block/iscsitarget/iscsi.c | 69 ++++++++++++++++++++++++++++----
ubuntu/block/iscsitarget/iscsi.h | 5 --
ubuntu/block/iscsitarget/iscsi_dbg.h | 33 +++++++++------
ubuntu/block/iscsitarget/nthread.c | 2 -
ubuntu/block/iscsitarget/null-io.c | 12 ++++--
ubuntu/block/iscsitarget/target.c | 1 -
ubuntu/block/iscsitarget/target_disk.c | 11 +++--
ubuntu/block/iscsitarget/tio.c | 3 +-
ubuntu/block/iscsitarget/volume.c | 2 +
14 files changed, 119 insertions(+), 77 deletions(-)

diff --git a/ubuntu/block/iscsitarget/block-io.c b/ubuntu/block/iscsitarget/block-io.c
index b8d56b8..492cc20 100644
--- a/ubuntu/block/iscsitarget/block-io.c
+++ b/ubuntu/block/iscsitarget/block-io.c
@@ -28,15 +28,10 @@ struct tio_work {
struct completion tio_complete;
};

-static int
-blockio_bio_endio(struct bio *bio, unsigned int bytes_done, int error)
+static void blockio_bio_endio(struct bio *bio, int error)
{
struct tio_work *tio_work = bio->bi_private;

- /* Ignore partials */
- if (bio->bi_size)
- return 1;
-
error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;

if (error)
@@ -47,8 +42,6 @@ blockio_bio_endio(struct bio *bio, unsigned int bytes_done, int error)
complete(&tio_work->tio_complete);

bio_put(bio);
-
- return 0;
}

/*
@@ -169,8 +162,8 @@ blockio_open_path(struct iet_volume *volume, const char *path)

bdev = open_bdev_excl(path, flags, THIS_MODULE);
if (IS_ERR(bdev)) {
- err = PTR_ERR (bdev);
- eprintk("Can't open device %s
", path);
+ err = PTR_ERR(bdev);
+ eprintk("Can't open device %s, error %d
", path, err);
bio_data->bdev = NULL;
} else {
bio_data->bdev = bdev;
@@ -217,7 +210,7 @@ gen_scsiid(struct iet_volume *volume, struct inode *inode)
p = (u32 *) (volume->scsi_id + VENDOR_ID_LEN);
*(p + 0) = volume->target->trgt_param.target_type;
*(p + 1) = volume->target->tid;
- *(p + 2) = (unsigned int) inode->i_ino;
+ *(p + 2) = volume->lun;
*(p + 3) = (unsigned int) inode->i_sb->s_dev;
}

@@ -319,6 +312,7 @@ blockio_detach(struct iet_volume *volume)

if (bio_data->bdev)
close_bdev_excl(bio_data->bdev);
+ kfree(bio_data->path);

kfree(volume->private);
}
diff --git a/ubuntu/block/iscsitarget/config.c b/ubuntu/block/iscsitarget/config.c
index 17664c4..d6c4b5e 100644
--- a/ubuntu/block/iscsitarget/config.c
+++ b/ubuntu/block/iscsitarget/config.c
@@ -40,7 +40,7 @@ int iet_procfs_init(void)
int i;
struct proc_dir_entry *ent;

- if (!(proc_iet_dir = proc_mkdir("net/iet", 0)))
+ if (!(proc_iet_dir = proc_mkdir("iet", init_net.proc_net)))
goto err;

proc_iet_dir->owner = THIS_MODULE;
diff --git a/ubuntu/block/iscsitarget/digest.c b/ubuntu/block/iscsitarget/digest.c
index cfa7a44..969ef17 100644
--- a/ubuntu/block/iscsitarget/digest.c
+++ b/ubuntu/block/iscsitarget/digest.c
@@ -161,21 +161,17 @@ static inline void __dbg_simulate_data_digest_error(struct iscsi_cmnd *cmnd)
}
}

-/* Copied from linux-iscsi initiator and slightly adjusted */
-#define SETSG(sg, p, l) do {
- sg_set_page(&(sg), virt_to_page(p), (l),
- ((unsigned long)(p) & ~PAGE_CACHE_MASK));
-} while (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);

- SETSG(sg[0], &pdu->bhs, nbytes);
+ sg_init_table(sg, pdu->ahssize ? 2 : 1);
+
+ sg_set_buf(&sg[0], &pdu->bhs, nbytes);
if (pdu->ahssize) {
- SETSG(sg[1], pdu->ahs, pdu->ahssize);
+ sg_set_buf(&sg[1], pdu->ahs, pdu->ahssize);
nbytes += pdu->ahssize;
}

@@ -217,8 +213,9 @@ static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
count = get_pgcnt(size, offset);
assert(idx + count <= tio->pg_cnt);

- assert(count < ISCSI_CONN_IOV_MAX);
+ 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++) {
@@ -232,6 +229,8 @@ static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
offset = 0;
}

+ sg_mark_end(&sg[i - 1]);
+
crypto_hash_update(hash, sg, nbytes);
crypto_hash_final(hash, crc);
}
diff --git a/ubuntu/block/iscsitarget/event.c b/ubuntu/block/iscsitarget/event.c
index cd22da8..e45ed67 100644
--- a/ubuntu/block/iscsitarget/event.c
+++ b/ubuntu/block/iscsitarget/event.c
@@ -37,7 +37,7 @@ static void event_recv_skb(struct sk_buff *skb)
while (skb->len >= NLMSG_SPACE(0)) {
nlh = (struct nlmsghdr *)skb->data;
if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
- return;
+ break;
rlen = NLMSG_ALIGN(nlh->nlmsg_len);
if (rlen > skb->len)
rlen = skb->len;
@@ -49,18 +49,6 @@ static void event_recv_skb(struct sk_buff *skb)
}
}

-/*static void event_recv(struct sock *sk, int length)
-{
- struct sk_buff *skb;
-
- while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
- if (event_recv_skb(skb) && skb->len)
- skb_queue_head(&sk->sk_receive_queue, skb);
- else
- kfree_skb(skb);
- }
-}
-*/
static int notify(void *data, int len, int gfp_mask)
{
struct sk_buff *skb;
@@ -94,7 +82,8 @@ int event_send(u32 tid, u64 sid, u32 cid, u32 state, int atomic)

int event_init(void)
{
- nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb, NULL,THIS_MODULE);
+ nl = netlink_kernel_create(&init_net, NETLINK_IET, 1, event_recv_skb,
+ NULL, THIS_MODULE);
if (!nl)
return -ENOMEM;
else
diff --git a/ubuntu/block/iscsitarget/iotype.c b/ubuntu/block/iscsitarget/iotype.c
index f8c5b03..b3d6117 100644
--- a/ubuntu/block/iscsitarget/iotype.c
+++ b/ubuntu/block/iscsitarget/iotype.c
@@ -89,9 +89,11 @@ int iotype_init(void)

for (i = 0; i < ARRAY_SIZE(iotype_array); i++) {
if (!(err = register_iotype(iotype_array[i])))
- eprintk("register %s
", iotype_array[i]->name);
+ iprintk("Registered io type %s
",
+ iotype_array[i]->name);
else {
- eprintk("failed to register %s
", iotype_array[i]->name);
+ eprintk("Failed to register io type %s
",
+ iotype_array[i]->name);
break;
}
}
diff --git a/ubuntu/block/iscsitarget/iscsi.c b/ubuntu/block/iscsitarget/iscsi.c
index 1ae1532..9143254 100644
--- a/ubuntu/block/iscsitarget/iscsi.c
+++ b/ubuntu/block/iscsitarget/iscsi.c
@@ -726,13 +726,18 @@ static void set_offset_and_length(struct iet_volume *lu, u8 *cmd, loff_t *off, u
case READ_10:
case WRITE_10:
case WRITE_VERIFY:
- *off = be32_to_cpu(*(u32 *)&cmd[2]);
+ *off = (u32)cmd[2] << 24 | (u32)cmd[3] << 16 |
+ (u32)cmd[4] << 8 | (u32)cmd[5];
*len = (cmd[7] << 8) + cmd[8];
break;
case READ_16:
case WRITE_16:
- *off = be64_to_cpu(*(u64 *)&cmd[2]);
- *len = be32_to_cpu(*(u32 *)&cmd[10]);
+ *off = (u64)cmd[2] << 56 | (u64)cmd[3] << 48 |
+ (u64)cmd[4] << 40 | (u64)cmd[5] << 32 |
+ (u64)cmd[6] << 24 | (u64)cmd[7] << 16 |
+ (u64)cmd[8] << 8 | (u64)cmd[9];
+ *len = (u32)cmd[10] << 24 | (u32)cmd[11] << 16 |
+ (u32)cmd[12] << 8 | (u32)cmd[13];
break;
default:
BUG();
@@ -1191,10 +1196,56 @@ static void task_set_abort(struct iscsi_cmnd *req)
}
}

+static inline char *tmf_desc(int fun)
+{
+ static char *tmf_desc[] = {
+ "Unknown Function",
+ "Abort Task",
+ "Abort Task Set",
+ "Clear ACA",
+ "Clear Task Set",
+ "Logical Unit Reset",
+ "Target Warm Reset",
+ "Target Cold Reset",
+ "Task Reassign",
+ };
+
+ if ((fun < ISCSI_FUNCTION_ABORT_TASK) ||
+ (fun > ISCSI_FUNCTION_TASK_REASSIGN))
+ fun = 0;
+
+ return tmf_desc[fun];
+}
+
+static inline char *rsp_desc(int rsp)
+{
+ static char *rsp_desc[] = {
+ "Function Complete",
+ "Unknown Task",
+ "Unknown LUN",
+ "Task Allegiant",
+ "Failover Unsupported",
+ "Function Unsupported",
+ "No Authorization",
+ "Function Rejected",
+ "Unknown Response",
+ };
+
+ if (((rsp < ISCSI_RESPONSE_FUNCTION_COMPLETE) ||
+ (rsp > ISCSI_RESPONSE_NO_AUTHORIZATION)) &&
+ (rsp != ISCSI_RESPONSE_FUNCTION_REJECTED))
+ rsp = 8;
+ else if (rsp == ISCSI_RESPONSE_FUNCTION_REJECTED)
+ rsp = 7;
+
+ return rsp_desc[rsp];
+}
+
static void execute_task_management(struct iscsi_cmnd *req)
{
struct iscsi_conn *conn = req->conn;
- struct iscsi_target *target = conn->session->target;
+ struct iscsi_session *session = conn->session;
+ struct iscsi_target *target = session->target;
struct iscsi_cmnd *rsp;
struct iscsi_task_mgt_hdr *req_hdr = (struct iscsi_task_mgt_hdr *)&req->pdu.bhs;
struct iscsi_task_rsp_hdr *rsp_hdr;
@@ -1209,8 +1260,6 @@ static void execute_task_management(struct iscsi_cmnd *req)
rsp_hdr->itt = req_hdr->itt;
rsp_hdr->response = ISCSI_RESPONSE_FUNCTION_COMPLETE;

- eprintk("%x %d %x
", cmnd_itt(req), function, req_hdr->rtt);
-
switch (function) {
case ISCSI_FUNCTION_ABORT_TASK:
case ISCSI_FUNCTION_ABORT_TASK_SET:
@@ -1255,6 +1304,11 @@ static void execute_task_management(struct iscsi_cmnd *req)
break;
}
out:
+ iprintk("%s (%02x) issued on tid:%d lun:%d by sid:%llu (%s)
",
+ tmf_desc(function), function, target->tid,
+ translate_lun(req_hdr->lun), session->sid,
+ rsp_desc(rsp_hdr->response));
+
iscsi_cmnd_init_write(rsp);
}

@@ -1708,8 +1762,7 @@ static int iscsi_init(void)
if ((err = event_init()) < 0)
goto err;

- iscsi_cmnd_cache = kmem_cache_create("iscsi_cmnd", sizeof(struct iscsi_cmnd),
- 0, 0, NULL);
+ iscsi_cmnd_cache = KMEM_CACHE(iscsi_cmnd, 0);
if (!iscsi_cmnd_cache)
goto err;

diff --git a/ubuntu/block/iscsitarget/iscsi.h b/ubuntu/block/iscsitarget/iscsi.h
index b66a2b7..5248024 100644
--- a/ubuntu/block/iscsitarget/iscsi.h
+++ b/ubuntu/block/iscsitarget/iscsi.h
@@ -116,9 +116,6 @@ struct iscsi_target {
struct worker_thread_info wthread_info;

struct semaphore target_sem;
-
- struct list_head initiator_list;
- u32 initiator_iid_count;
};

struct iscsi_queue {
@@ -189,8 +186,6 @@ struct iscsi_session {
struct list_head cmnd_hash[1 << IET_HASH_ORDER];

u32 next_ttt;
-
- struct iscsi_initiator *rinitiator;
};

enum connection_state_bit {
diff --git a/ubuntu/block/iscsitarget/iscsi_dbg.h b/ubuntu/block/iscsitarget/iscsi_dbg.h
index 4399dcb..bc83b54 100644
--- a/ubuntu/block/iscsitarget/iscsi_dbg.h
+++ b/ubuntu/block/iscsitarget/iscsi_dbg.h
@@ -15,21 +15,25 @@

extern unsigned long debug_enable_flags;

-#define dprintk(debug, fmt, args...)
-do {
- if ((debug) & debug_enable_flags) {
- printk("%s(%d) " fmt, __FUNCTION__, __LINE__, args);
- }
+#define PFX "iscsi_trgt: "
+
+#define dprintk(debug, fmt, args...) do {
+ if ((debug) & debug_enable_flags) {
+ printk(KERN_DEBUG PFX "%s(%d) " fmt, __FUNCTION__,
+ __LINE__, args);
+ }
} while (0)

-#define eprintk(fmt, args...)
-do {
- printk("%s(%d) " fmt, __FUNCTION__, __LINE__, args);
+#define eprintk(fmt, args...) do {
+ printk(KERN_ERR PFX "%s(%d) " fmt, __FUNCTION__,
+ __LINE__, args);
} while (0)

+#define iprintk(X...) printk(KERN_INFO PFX X)
+
#define assert(p) do {
if (!(p)) {
- printk(KERN_CRIT "BUG at %s:%d assert(%s)
",
+ printk(KERN_CRIT PFX "BUG at %s:%d assert(%s)
",
__FILE__, __LINE__, #p);
dump_stack();
BUG();
@@ -40,9 +44,10 @@ do {
static inline void iscsi_dump_iov(struct msghdr *msg)
{
int i;
- printk("%p, %d
", msg->msg_iov, msg->msg_iovlen);
+ printk(PFX "%p, %d
", msg->msg_iov, msg->msg_iovlen);
for (i = 0; i < min_t(size_t, msg->msg_iovlen, ISCSI_CONN_IOV_MAX); i++)
- printk("%d: %p,%d
", i, msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
+ printk(PFX "%d: %p,%d
", i, msg->msg_iov[i].iov_base,
+ msg->msg_iov[i].iov_len);
}
#else
#define iscsi_dump_iov(x) do {} while (0)
@@ -84,18 +89,18 @@ static inline void iscsi_dump_pdu(struct iscsi_pdu *pdu)
int i;

buf = (void *)&pdu->bhs;
- printk("BHS: (%p,%d)
", buf, sizeof(pdu->bhs));
+ printk(PFX "BHS: (%p,%d)
", buf, sizeof(pdu->bhs));
for (i = 0; i < sizeof(pdu->bhs); i++)
iscsi_dump_char(*buf++);
iscsi_dump_char(-1);

buf = (void *)pdu->ahs;
- printk("AHS: (%p,%d)
", buf, pdu->ahssize);
+ printk(PFX "AHS: (%p,%d)
", buf, pdu->ahssize);
for (i = 0; i < pdu->ahssize; i++)
iscsi_dump_char(*buf++);
iscsi_dump_char(-1);

- printk("Data: (%d)
", pdu->datasize);
+ printk(PFX "Data: (%d)
", pdu->datasize);
}

#else
diff --git a/ubuntu/block/iscsitarget/nthread.c b/ubuntu/block/iscsitarget/nthread.c
index b102a7f..9c1c883 100644
--- a/ubuntu/block/iscsitarget/nthread.c
+++ b/ubuntu/block/iscsitarget/nthread.c
@@ -13,8 +13,6 @@
#include "iscsi_dbg.h"
#include "digest.h"

-DECLARE_WAIT_QUEUE_HEAD(iscsi_ctl_wait);
-
enum daemon_state_bit {
D_ACTIVE,
D_DATA_READY,
diff --git a/ubuntu/block/iscsitarget/null-io.c b/ubuntu/block/iscsitarget/null-io.c
index 64c23d9..cbc10a0 100644
--- a/ubuntu/block/iscsitarget/null-io.c
+++ b/ubuntu/block/iscsitarget/null-io.c
@@ -16,7 +16,7 @@
#include "iotype.h"

struct nullio_data {
- u32 sectors;
+ u64 sectors;
};

enum {
@@ -32,7 +32,7 @@ static match_table_t tokens = {
static int parse_nullio_params(struct iet_volume *volume, char *params)
{
int err = 0;
- char *p;
+ char *p, *q;
struct nullio_data *data = volume->private;

while ((p = strsep(&params, ",")) != NULL) {
@@ -43,7 +43,11 @@ static int parse_nullio_params(struct iet_volume *volume, char *params)
token = match_token(p, tokens, args);
switch (token) {
case Opt_sectors:
- match_int(&args[0], &data->sectors);
+ q = match_strdup(&args[0]);
+ if (!q)
+ return -ENOMEM;
+ data->sectors = simple_strtoull(q, NULL, 10);
+ kfree(q);
break;
case Opt_ignore:
break;
@@ -97,7 +101,7 @@ out:
void nullio_show(struct iet_volume *lu, struct seq_file *seq)
{
struct nullio_data *p = lu->private;
- seq_printf(seq, " sectors:%u
", p->sectors);
+ seq_printf(seq, " sectors:%llu
", p->sectors);
}

struct iotype nullio =
diff --git a/ubuntu/block/iscsitarget/target.c b/ubuntu/block/iscsitarget/target.c
index 908ad60..17135b6 100644
--- a/ubuntu/block/iscsitarget/target.c
+++ b/ubuntu/block/iscsitarget/target.c
@@ -148,7 +148,6 @@ static int iscsi_target_create(struct target_info *info, u32 tid)

INIT_LIST_HEAD(&target->session_list);
INIT_LIST_HEAD(&target->volumes);
- INIT_LIST_HEAD(&target->initiator_list);

atomic_set(&target->nr_volumes, 0);

diff --git a/ubuntu/block/iscsitarget/target_disk.c b/ubuntu/block/iscsitarget/target_disk.c
index 1580d5e..6b685c6 100644
--- a/ubuntu/block/iscsitarget/target_disk.c
+++ b/ubuntu/block/iscsitarget/target_disk.c
@@ -66,13 +66,15 @@ static int insert_geo_m_pg(u8 *ptr, u64 sec)
unsigned char geo_m_pg[] = {0x04, 0x16, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3a, 0x98, 0x00, 0x00};
- u32 ncyl, *p;
+ u32 ncyl;
+ u32 n;

/* assume 0xff heads, 15krpm. */
memcpy(ptr, geo_m_pg, sizeof(geo_m_pg));
ncyl = sec >> 14; /* 256 * 64 */
- p = (u32 *)(ptr + 1);
- *p = *p | cpu_to_be32(ncyl);
+ memcpy(&n, ptr+1, sizeof(u32));
+ n = n | cpu_to_be32(ncyl);
+ memcpy(ptr+1, &n, sizeof(u32));
return sizeof(geo_m_pg);
}

@@ -249,7 +251,8 @@ static int build_report_luns_response(struct iscsi_cmnd *cmnd)
struct iet_volume *lun;
int rest, idx = 0;

- size = be32_to_cpu(*(u32 *)&req->scb[6]);
+ size = (u32)req->scb[6] << 24 | (u32)req->scb[7] << 16 |
+ (u32)req->scb[8] << 8 | (u32)req->scb[9];
if (size < 16)
return -1;

diff --git a/ubuntu/block/iscsitarget/tio.c b/ubuntu/block/iscsitarget/tio.c
index dea4e6c..4220391 100644
--- a/ubuntu/block/iscsitarget/tio.c
+++ b/ubuntu/block/iscsitarget/tio.c
@@ -110,8 +110,7 @@ int tio_sync(struct iet_volume *lu, struct tio *tio)

int tio_init(void)
{
- tio_cache = kmem_cache_create("tio", sizeof(struct tio),
- 0, 0, NULL);
+ tio_cache = KMEM_CACHE(tio, 0);
return tio_cache ? 0 : -ENOMEM;
}

diff --git a/ubuntu/block/iscsitarget/volume.c b/ubuntu/block/iscsitarget/volume.c
index 3330b44..b807035 100644
--- a/ubuntu/block/iscsitarget/volume.c
+++ b/ubuntu/block/iscsitarget/volume.c
@@ -132,6 +132,8 @@ int volume_add(struct iscsi_target *target, struct volume_info *info)
list_add_tail(&volume->list, &target->volumes);
atomic_inc(&target->nr_volumes);

+ kfree(args);
+
return 0;
free_args:
kfree(args);
--
1.5.4.rc4

--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team

Stefan Bader 04-09-2008 05:53 PM

Update for iscsitarget in hardy lum.
 
Chuck Short wrote:
> Here is the fix for 2.6.24. Please apply.
>
> Thanks
> chuck
>
applied

--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team


All times are GMT. The time now is 07:54 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.