GEOM + RAID5 help

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Feb 21 07:45:43 PST 2004


In message <20040221162942.P19540 at leelou.in.tern>, Lukas Ertl writes:
>Hi,
>
>I'm currently implementing the RAID5 bit of geom_vinum, and I could use a
>little help.  One problem I'm faced is that if the subdisk where the
>original request should go to is down, I need to read all the other
>stripes, recalculate the parity with the original data, and then write the
>parity stripe (in the BIO_WRITE case), or read all other stripes plus the
>parity to recalculate the desired data (in the BIO_READ case).
>
>If I'm not mistaken then I'm not allowed to use g_read_data in the IO
>path, so how can I correctly get at the data of the other stripes?  Should
>I create my own bio (how?) with the appropriate bio_cmd and send it down
>the path using g_io_request (where should I issue it?  In my bio_done
>routine?)?

Go look at sys/geom/bde/g_bde_work.c, it does something very similar.

Basically, you need to implement a state engine.

You do not need to have a thread for it like GBDE, because the XOR
is a lot cheaper than a full crypto.

So what you do is you allocate the necessary number of bio structures
fill them in and ship them down.  The biodone routine you specify
should then update status, and when all bits have arrived, do the XOR
and complete the operation.

Read the bit in sys/geom/notes about locking of bio_children carefully
as it will save you a lot of locking worries.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-geom mailing list