[linux-lvm] Re: raid 1 on a single disk

Peter T. Breuer ptb at lab.it.uc3m.es
Sun Nov 14 18:04:10 UTC 2004


ashwin chaugule <ashwin.chaugule at gmail.com> wrote:
> ok , here is what ive done ...

How about you ceasing top posting in favour of posting comprehensibly.
I've asked several times, no? It's extremely irritating - I'll do my
best to fix this post, again ... (it takes work!)
 
> On Sun, 14 Nov 2004 12:28:32 +0100, Peter T. Breuer <ptb at lab.it.uc3m.es> wrote:
> > ashwin chaugule <ashwin.chaugule at gmail.com> wrote:
> > > I've also managed to hack into the kernel IDE susbsys. (ide-disk.c) to
> > > duplicate the writes and reads for this particular disk.
> > 
> > It's extremely unlikely you got this right. Recall that the driver has
> > to work when out of memory, and that if you generate another write
> > request like the request you received, then you will need another
> > request struct and another bh struct for each one in the original. You
> > also have to point them at the buffers in the original request, and
> > make sue that the original request's end_bh (end_bio :) functions do
> > not free the original buffers, but wait till your extra request has
> > completed too. Those structs take memory, and have to come from
> > somewhere.

> for my particular disk : when there's a write request, I duplicate the
> req struct first(using kmalloc ),

Request structs come from a kernel pool. You make them by simply
submitting buffer heads to the kernel (submit_bh, make_request, etc.).
The kernel will aggregate buffer heads submitted as it thinks fit into
request structures, which it will send to the appropriate device queue.

You should not be making your own request struct, because it may
accidently be grabbed by the kernel mechanisms that assemble and
disassemble these, and then There Will Be Tears.


> call a function to put in custom
> values into the respective registers ( LBA format) using 'block' .

Registers?  What registers? Do you mean "fields"?

> Then I set the interupt handler to a custom routine, where it will put
> the correct desired LBA addr into the IDE_DATA_REG ( by calling
> ata_output_data) ...

This sounds like stuff you do in the driver , on receipt of your special
request.  Is that so and how do you recognize it

> after which without calling end_request i let the
> _original_ request struct do its thing , by calling the default
> interrupt handler which later calls an end_request.

Default interrupt handler? What? Are you talking about end_io? Your
driver will call end_request on a request (which will call end_io
on its buffer heads) when it thinks the request has been handled by the
device.



> That way , on one knows(or atleast i hope)  that i've performed a
> duplicate write. Ive verified this, the file gets duplicated.

It sounds to me that when you receive a request at very low level in
the driver, you change certain offsets that affect the handling of the
request, then change them back, and that way catch the original request
too. I am unclear as to whether you duplicate requests and submit them
twice to the driver queue, or whether you only have one request hit the
driver and when it hits you simply treat it twice, having
copied its structure for safety. I think the latter.

How do you get the requests to the driver, ensure that treatment of
your clones occurs when you think it does, etc?

> BUT ! for some unknown reason, when I unmount the partition , it hangs ! 

Probably because some stuff is returned to kernel pools and messes them
up completely.

> Why would this be happening ? Why should the filesystem be affected,

Because your code, like your description, is an uncontrolled mess,
probably.

> if it doesnt even know that i've performed a duplicate write !

Nobody knows anything.

Puhleeeeze. Please just use raid.



Peter




More information about the linux-lvm mailing list