Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Aug 2003 06:44:41 +0000
From:      "Jingrong Xie" <xjrcool@hotmail.com>
To:        gibbs@scsiguy.com, nate@root.org
Cc:        freebsd-scsi@freebsd.org
Subject:   Re: Re: AIC7899's 2 SCSI channels infect with each other in target mode?
Message-ID:  <Law14-F70RIYkty2dzU00067629@hotmail.com>

next in thread | raw e-mail | index | archive | help
-------------------------------------------------
1.(to Nate) about scsi_target(user-space scsi_disk emulator):

1)applying targ-noloop.diff result:
    scsi_target crashed!
2)applying targ-numctios.diff result:
    not seeing any changes.
3)applying targ-jingrong1.diff result:
    ONLY log something to /var/log/messages, for my convinence ^-^.
4)applying targ-jingrong2.diff result:
    when NOT using it, my prog <test_write_scsi> can only write 9 times 
before ERROR!
    I saw 'IO 0xXXXX out of order' warning is not very friendly and do such, 
it works.
-------------------------------------------------
-------------------
1) targ-noloop.diff
-------------------
Index: src/share/examples/scsi_target/scsi_target.c
===================================================================
RCS file: /home/ncvs/src/share/examples/scsi_target/scsi_target.c,v
retrieving revision 1.14
diff -u -r1.14 scsi_target.c
--- src/share/examples/scsi_target/scsi_target.c        16 Jan 2003 00:24:29 
-0000      1.14
+++ src/share/examples/scsi_target/scsi_target.c        12 Apr 2003 00:28:06 
-0000
@@ -642,6 +642,7 @@

        /* Insert in order, sorted by offset */
        if (!TAILQ_EMPTY(ioq)) {
+#ifdef notyet
                TAILQ_FOREACH_REVERSE(ccb_h, ioq, io_queue, 
periph_links.tqe) {
                        curr_descr = (struct ctio_descr *)ccb_h->targ_descr;
                        if (curr_descr->offset <= c_descr->offset) {
@@ -657,6 +658,7 @@
                        }
                }
        } else {
+#endif
                TAILQ_INSERT_HEAD(ioq, &ctio->ccb_h, periph_links.tqe);
        }
}


-------------------
2) targ-numctios.diff
-------------------
Index: src/share/examples/scsi_target/scsi_target.c
===================================================================
RCS file: /home/ncvs/src/share/examples/scsi_target/scsi_target.c,v
retrieving revision 1.14
diff -u -r1.14 scsi_target.c
--- src/share/examples/scsi_target/scsi_target.c        16 Jan 2003 00:24:29 
-0000      1.14
+++ src/share/examples/scsi_target/scsi_target.c        12 Apr 2003 00:24:33 
-0000
@@ -796,7 +796,7 @@
        struct ctio_descr *c_descr;
        struct sigevent *se;

-       if (num_ctios == MAX_CTIOS)
+       if (num_ctios >= MAX_CTIOS)
                return (NULL);

        ctio = (struct ccb_scsiio *)malloc(sizeof(*ctio));

-------------------
3) targ-jingrong1.diff
-------------------
*** scsi_target.c.orig  Wed Aug 20 13:34:40 2003
--- scsi_target.c       Wed Aug 20 14:12:49 2003
***************
*** 685,691 ****
                c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;

                /* If completed item is in range, call handler */
!               if ( 1 || (c_descr->event == AIO_DONE && //Avoiding 'IO ... 
out of order' warning.
                    c_descr->offset == a_descr->base_off + 
a_descr->targ_ack)
                 || (c_descr->event == CTIO_DONE &&
                    c_descr->offset == a_descr->base_off + 
a_descr->init_ack)) {
--- 685,691 ----
                c_descr = (struct ctio_descr *)ctio->ccb_h.targ_descr;

                /* If completed item is in range, call handler */
!               if ((c_descr->event == AIO_DONE &&
                    c_descr->offset == a_descr->base_off + 
a_descr->targ_ack)
                 || (c_descr->event == CTIO_DONE &&
                    c_descr->offset == a_descr->base_off + 
a_descr->init_ack)) {

-------------------
4) targ-jingrong2.diff
-------------------
*** scsi_cmds.c.orig    Tue Aug 19 19:34:52 2003
--- scsi_cmds.c Wed Aug 20 13:35:20 2003
***************
*** 602,607 ****
--- 602,615 ----
                        a_descr->targ_req += ctio->dxfer_len;
                        if (aio_write(&c_descr->aiocb) < 0)
                                err(1, "aio_write"); /* XXX */
+                       {//Jingrong add for test.
+                       #include <syslog.h>
+                       #include <stdarg.h>
+                       static unsigned long g_count=0;
+                       g_count++;
+                       if( g_count % 100 == 0)
+                               syslog(LOG_ERR,"====write %ld blocks!\n", 
g_count);
+                       }
                } else {
                        if (debug)
                                warnx("CTIO done freeing CTIO");



-------------------------------------------------
2. test_write_wscsi.c
-------------------------------------------------
#include <stdio.h>
#include <fcntl.h>

int main(int argc, char **argv)
{
        int fd = 0;
        FILE *fp2 = 0;
        int ret = 0;
        char buf[10240];
        fd = open("/dev/da0", O_RDWR);

        if(argc<2){
                printf("usage: %s <filename>\n", argv[0]);
                return 1;
        }
        fp2 = fopen(argv[1], "r+");
        if(fp2 <=0){
                perror("fopen");
                exit(1);
        }

        memset(buf, 0, 10240);
        ret = fread( buf, 10240, 1, fp2);

        lseek(fd,10240, SEEK_SET);
        write(fd, buf, 10240);

        return 0;
}


-------------------------------------------------
3. test.sh
-------------------------------------------------
TOTALCOUNT=$1
SLEEPTIME=$2
COUNT=0

while true ; do
  echo "count = $COUNT, totalcount= $TOTALCOUNT"
  if [ $COUNT -gt $TOTALCOUNT ] ; then
        break ;
  fi

  ./test_write_scsi test_write_wscsi.c
  sleep $SLEEPTIME

  COUNT=`expr $COUNT + 1`
done


-------------------------------------------------
4. Test:
   On IA, using './test.sh 1000000 0', test for 3 days and about 1Tbytes 
data, no problem.
   On OA, also.
   but when the two do at the same time, IA or OA will crash down soon.
-------------------------------------------------
OA# dd if=/dev/zero of=testfile bs=1024 count=102400
OA# ./scsi_target -S -W 16 0:5:0 testfile

IA# camcontrol rescan 0
IA# ./test.sh 1000000 0

IA# dd if=/dev/zero of=testfile bs=1024 count=102400
IA# ./scsi_target -S -W 16 1:5:0 testfile

OA# camcontrol rescan 1
OA# ./test.sh 1000000 0

-------------------------------------------------
5. Also about Justin's advice:
-------------------------------------------------
>You shouldn't be able to do this since ahc(4) does not support
>simultaneous target/initiator mode.

It can, you just need to disable the multi-target-id feature to do
it.  I should probably modify the driver so that it will allow dual
mode operation so long as only one target-id is set and it corresponds
to the initiator's id.

Q: How could I disable the multi-target-id feature? Is the following 
correct?

Beforing this advice, i use 0x27 to enable 0,1,2,5 as target-id,
GENERIC_IA: options         AHC_TMODE_ENABLE=0x27
GENERIC_OA: options         AHC_TMODE_ENABLE=0x27
and this is the kernel output for scsi_target:
IA#
  (targbh0:ahc0:0:-1:-1): Lun now enabled for target mode
  (targbh1:ahc1:0:-1:-1): Lun now enabled for target mode
OA#
  (targbh0:ahc0:0:-1:-1): Lun now enabled for target mode
  (targbh1:ahc1:0:-1:-1): Lun now enabled for target mode

I changed to disable the multi-target-id feature:
GENERIC_IA: options         AHC_TMODE_ENABLE=0x21  #only enable 0,5 as 
target-id
GENERIC_OA: options         AHC_TMODE_ENABLE=0x22  #only enable 1,5 as 
target-id
and this is the kernel output for scsi_target:
IA#
  (targbh0:ahc0:0:-1:-1): Lun now enabled for target mode
OA#
  (targbh1:ahc1:0:-1:-1): Lun now enabled for target mode


I tried 'AHC_TMODE_ENABLE=0x20' to enable only 5 as target-id, but failed! 
kernel says it dont support target-mode when i using scsi_target.


thanks very much!


Regards,

Jingrong

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Law14-F70RIYkty2dzU00067629>