GEOM stripe library.
Pawel Jakub Dawidek
pjd at FreeBSD.org
Wed Feb 25 02:31:02 PST 2004
Hi.
I finished some time ago GEOM stripe library. It should simplify stripe
implementation. phk@ already looked at it.
I need feedback from responsible parties if this is complete and usable.
So, please look at the code below (from g_stripe.h) and try to fit it
to vinum, ata-raid and simplar stuff, that use striping.
Full code is here:
http://people.freebsd.org/~pjd/geom_stripe_lib.tbz
and an example geom_raid0 implementation is here:
http://people.freebsd.org/~pjd/geom_raid0.tbz
/*
* Structure g_stripe_slice describe single slice on single disk.
* Disk can contains many slices.
*
* DATA OFFSET
* +-----------+ 0
* | meta data | <- should not be touched
* +-----------+ 1024
* | |
* | slice 0 |
* | |
* +-----------+ 3072
* | meta data | <- should not be touched
* +-----------+ 4096
* | |
* | |
* | slice 1 |
* | |
* | |
* +-----------+ 7168
*
* This disk have two slice:
*
* d_slices[0].s_offset = 1024
* d_slices[0].s_length = 2048
* d_slices[0].s_virt_offset = 0
* d_slices[0].s_virt_end = 2048 (s_virt_offset + s_length)
*
* d_slices[1].s_offset = 4096
* d_slices[1].s_length = 3072
* d_slices[1].s_virt_offset = 2048 (d_slices[0].s_virt_end)
* d_slices[1].s_virt_end = 5120 (s_virt_offset + s_length)
*/
struct g_stripe_slice {
off_t s_offset; /* Offset in source disk. */
off_t s_length; /* Slice length. */
off_t s_virt_offset; /* Offset in destination disk. */
off_t s_virt_end; /* End in destination disk. */
};
/*
* Structure g_stripe_group describes group of disks that are used
* on given offset. This allows to create stripe on disks with different
* sizes.
*
* disk 0 disk 1 disk 2 START_DISK START_OFFSET
* +-------+ +-------+ +-------+ 0 0
* |0000000| |0000000| |0000000|
* |0000000| |0000000| |0000000|
* + - - - + +-------+ + - - - + 1024 0 + 1024 * 3 = 3072
* |1111111| |1111111|
* |1111111| |1111111|
* |1111111| |1111111|
* +-------+ + - - - + 2560 3072 + 1536 * 2 = 6144
* |2222222|
* +-------+ 3072 6144 + 512 * 1 = 6656
*
* sc_groups[0].g_ndisks = 3
* sc_groups[0].g_disks = { 0, 1, 2 }
* sc_groups[0].g_start_offset = 0
* sc_groups[0].g_end_offset = 3072
* sc_groups[0].g_start_disk = 0
*
* sc_groups[1].g_ndisks = 2
* sc_groups[1].g_disks = { 0, 2 }
* sc_groups[1].g_start_offset = 3072
* sc_groups[1].g_end_offset = 6144
* sc_groups[1].g_start_disk = 2560
*
* sc_groups[2].g_ndisks = 1
* sc_groups[2].g_disks = { 2 }
* sc_groups[2].g_start_offset = 6144
* sc_groups[2].g_end_offset = 6656
* sc_groups[2].g_start_disk = 3072
*/
struct g_stripe_group {
uint16_t g_ndisks;
struct g_stripe_disk **g_disks;
off_t g_start_offset;
off_t g_end_offset;
off_t g_start_disk;
};
[...]
/* Exported functions: */
struct g_geom *g_stripe_create(struct g_class *mp, const char *name,
uint16_t ndisks, uint32_t stripesize, uint32_t sectorsize, void *priv,
void (*orphan)(struct g_provider *));
void g_stripe_add_slice(struct g_geom *gp, struct g_provider *pp, off_t offset,
off_t length);
int g_stripe_attach(struct g_geom *gp, struct g_provider *pp, uint16_t no,
uint16_t nslices);
int g_stripe_detach(struct g_geom *gp, struct g_provider *pp);
int g_stripe_destroy(struct g_geom *gp, int force);
--
Pawel Jakub Dawidek http://www.FreeBSD.org
pjd at FreeBSD.org http://garage.freebsd.pl
FreeBSD committer Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-geom/attachments/20040225/890c1eb5/attachment.bin
More information about the freebsd-geom
mailing list