scsi adapter module over block device - need help

Greg Freemyer greg.freemyer at gmail.com
Sat Oct 6 19:39:43 EDT 2012


On Sat, Oct 6, 2012 at 9:28 AM, Dmitry Filippov <filippovd20 at gmail.com> wrote:
> Hi all,
>
> i'm just learning kernel and not experienced in writing code for it.
> I'm going to write kernel module in studying purposes and i hope
> someone from you could help me with it and in best case guide me
> through overall process.
>
> I want to write module that implements SCSI-disk logic, keeping its
> data on block device. For example partition of existing disk. So i
> want to pass the name of block device as parameter to my module while
> loading to kernel.
>
> So it will be some kind of virtual(pseudo) scsi device that appears in
> /dev as scsi disk and in fact some block device as backend. I want it
> to be as simple as possible... keeping just essential parts... and it
> is not intended to be some kind of production driver... i want it to
> be just as simple as sbull from LDD)))
>
> As from my point of view there are 2 major parts, with which i'm
> completely not confident and doesn't know from where to start...
> 1. scsi subsystem... so how to write my module to interact with scsi
> subsystem in this case and to not reinvent the wheel. using scsi
> kernel API as much as possible.
> i have found interesting thing in kernel source scsi_debug module...
> which represent scsi disk and have ram as backend (so some kind of
> sbull but with scsi). However i got overwhelmed with its code. It is
> very difficult for me to sort out with it by my own... maybe someone
> can help?
>
> 2. module code interaction with existing block device... that is i
> completely don't understand how to achieve. ok.. i have device name in
> kernel space... whats then? how i can access this device?
> so how i can write some adapter for existing device and transit some
> writes/reads and other fops from my device to existing... I saw same
> questions on forums... and the only answer is to use sys_write... or
> vfs_write... to existing block device node... if it is most
> simple/correct way?
>
> i hope someone could help me sort out in those things eventually.
> Really need your help!
>
> thanks in advance,
> -Dmitry Filippov

Dmitry,

I might be able to give some high-level guidance.

The first thing you need to know is the "network stack".

I'm assuming you know ethernet => IP => TCP type of levels for networking.

Can you provide a similar set of layers for scsi.  As an example USB
external drives actually fit into the SCSI stack, not the IDE or SATA
stack.  Can you list the layering starting with the filesystem?

Greg



More information about the Kernelnewbies mailing list