[Stgt-devel] iscsi target works, minor fixes

Pete Wyckoff pw
Fri Nov 3 01:45:48 CET 2006

I've been playing with the user-space iscsi target, looking at the
latest stgt SVN and linux-2.6-target git today.  One little fix I
need in the userspace code is this:

Index: trunk/usr/bd_aio.c
--- trunk/usr/bd_aio.c	(revision 609)
+++ trunk/usr/bd_aio.c	(working copy)
@@ -74,8 +74,8 @@ static void aio_event_handler(int fd, in
 	for (i = 0; i < nr; i++) {
 		iocb = bai->events[i].obj;
-		dprintf("%p\n", iocb->data);
-		target_cmd_io_done(iocb->data, 0);
+		dprintf("%p\n", bai->events[i].data);
+		target_cmd_io_done(bai->events[i].data, 0);
While I don't understand exactly what's going on, this data pointer
from struct io_event is the correct struct cmd *, and without the
patch, tgtd segfaults trying to access fields in the (bogus) cmd
from iocb->data.

It could be related to the aiopoll-2.6.18-rc4.patch; perhaps that
was the wrong one to apply?  There was one minor reject that was
easy to fix up.  My kernel is v2.6.19-rc4 + the 9 patches in tomo's
linux-2.6-target.git + aiopoll + other minor patches.

You may want this, but it doesn't change any behavior:

diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index e01f458..6e92b97 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -108,7 +108,6 @@ struct scsi_cmnd *scsi_host_get_command(
 	rq->special = cmd;
 	rq->cmd_type = REQ_TYPE_SPECIAL;
-	rq->cmd_flags |= REQ_TYPE_BLOCK_PC;
 	rq->end_io_data = tcmd;

What goes in cmd_flags are bit fields like REQ_SOFTBARRIER.  You're
not supposed to try to put another REQ_TYPE in there.  You do want
SPECIAL, not BLOCK_PC, since you are allocating your own struct
scsi_cmnd and putting it into rq->special.

Basic mkfs and dd seem to work just fine.  Thanks for the code.

		-- Pete

More information about the stgt mailing list