Problem to make mpt driver work fine with SAS controllers

Silas Silva <[email protected]>
Newsgroups gmane.os.netbsd.devel.general
Message-ID <20080318224901.GA199@hope>
Hello all,

Recently, I got a IBM x3200 server (model 4363), i386 arch, with a LSI Logic
1064E SAS controller and an additional HDD. I'm interested about doing RAID 1
in this server.

Garret D'Amore months ago sent a patch that makes the mpt(4) recognizes SAS
controllers like that, but he said that he couldn't make it enable the
write-cache of the controllers. Link to the mail message is here:

http://mail-index.netbsd.org/tech-kern/2007/07/26/0022.html

Then NetBSD 4.0 recognizes it but it is very slooooow to write data to the
disk. I saw that PR 36900 presents this problem. First I thought about waiting
for someone solve this problem, but I couldn't just let the server down all
this time, so I realized: "Why not study NetBSD internals and try to improve
the driver myself?". I have a reasonable knowledge with C and the kernel code
looks really clean. I then started to study the NetBSD driver infrastructure
(NetBSD Device Driver Writing Guide and references - man pages etc.).

I cannot enable the write cache with dkctl(8) nor with scsictl(8) (with
`scsictl sd0 setcache rw`. Talked to a friend (also NetBSD lover) and he
recommended me to try to study the path between scsictl (actually, dkctl, but
I prefered to switch to scsictl) and the kernel. I did it and fell into the
scsipi_ioctl.c file, specially here:

http://opengrok.netbsd.org/source/xref/sys/dev/scsipi/scsipi_ioctl.c#325

In this block, there is a physio() function. The strategy function is
implemented above. My problem is that I don't know what I can do from there.
The function call flow looks like that:

  - physio()
  +- scsistrategy()
   +- scsipi_command()
    +- scsipi_make_xs()
    +- scsipi_execute_xs()

The scsipi_execute_xs() function is interesting because it has this line:

    (chan->chan_bustype->bustype_cmd)(xs);

Ah, a callback? How do the mpt driver sets that? I found the following line in
the mpt_scsipi_attach() function (int mpt_netbsd.c):

    chan->chan_bustype = &scsi_bustype;

This element of the scsi_bustype struct, though, points to the
scsi_scsipi_cmd() function, that doesn't seem to do anything! Or am I so dumb
that I can't understand it at all?

I even don't know if it is a good way to address the problem.  Should I keep
this methodology or have I to deep into the mpt(4) code directly? What do I
have to read/study in order to understand the mpt driver? Do you have any
recommendation?

Thank you very much.

-- 
Silas Silva
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.