GEOM stripe library.

Pawel Jakub Dawidek pjd at FreeBSD.org
Thu Feb 26 12:38:11 PST 2004


On Thu, Feb 26, 2004 at 10:47:32AM +0100, Poul-Henning Kamp wrote:
+> > * This disk have two slice:
+> > *
+> > * d_slices[0].s_offset =3D 1024
+> > * d_slices[0].s_length =3D 2048
+> > * d_slices[0].s_virt_offset =3D 0
+> > * d_slices[0].s_virt_end =3D 2048	(s_virt_offset + s_length)
+> 
+> I can't really see what we need s_virt_end for.  If you need it for
+> implementation, then please calculate it as part of setup so that
+> the users of this library will not even see it.

All structures are private for library.
Library's user is not aware of structure g_stripe_slice nor g_stripe_group,
he operates on well-known GEOM structures: g_provider, g_geom.

For slices definitions he use g_stripe_add_slice() function and he don't
touch geom_stripe_lib's structures at all. Defining slices for disks is
one-way operation, so this design should be enough and it is also simple.

Look at geom_raid0 implementaion. It only operates on generic GEOM
structures.

+> >/*
+> > * 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 =3D 3072
+> > *     |1111111|             |1111111|
+> > *     |1111111|             |1111111|
+> > *     |1111111|             |1111111|
+> > *     +-------+             + - - - + 2560       3072 + 1536 * 2 =3D 6144
+> > *                           |2222222|
+> > *                           +-------+ 3072       6144 + 512 * 1 =3D 6656
+> > *
+> > * sc_groups[0].g_ndisks =3D 3
+> > * sc_groups[0].g_disks =3D { 0, 1, 2 }
+> > * sc_groups[0].g_start_offset =3D 0
+> > * sc_groups[0].g_end_offset =3D 3072
+> > * sc_groups[0].g_start_disk =3D 0
+> 
+> Where is the actual stripe-width ?  Shouldn't that be a parameter here ?

This structure is also private. Stripe size is defined while one is
calling g_stripe_create() function.
"Groups" are calculated automatically, when all disks are ready.

+> > * sc_groups[1].g_start_disk =3D 2560
+> 
+> s/2560/1024/ ?
[...]
+> > * sc_groups[2].g_start_disk =3D 3072
+> 
+> s/3072/2560/ ?

Right, sorry for mistake.

+> I have been thinking a bit more about this, and I can see a number of
+> in-use striping geometries you cannot handle with this, in particular
+> non-uniform striping (64k from disk0, 128k from disk1, 64k from disk0,
+> 128k from disk1, ...)  There are also some underspecified parameters
+> and some overspecified ones.

Yes, this is not possible, but I'm also not aware of software that is
doing this. I don't think even veritas gives such possibility.
I think this will only complicate calculations.

+> And would look like this in C code:
+> 
+> 	struct stripe *sp;
+> 
+> 	sp = g_stripe_new(/* consumers */ 3, /* parts */ 3);
+> 
+> 	sp->consumer[0] = c0;
+> 	sp->consumer[1] = c1;
+> 	sp->consumer[2] = c2;
+> 	sp->slicepart[0].stripes = 1024;
+> 	for (i = 0; i < 3; i++) {
+> 		sp->slicepart[0].components[i].offset = 1024;
+> 		sp->slicepart[0].components[i].bite = 1024;
+> 	}
+> 	sp->slicepart[1].stripes = 3072;
+> 	sp->slicepart[1].components[0].offset = -1; /* autocalculate */
+> 	sp->slicepart[1].components[0].bite = 512;
+> 	sp->slicepart[1].components[2].offset = -1; /* autocalculate */
+> 	sp->slicepart[1].components[2].bite = 512;
+> 
+> 	sp->slicepart[1].stripes = 256;
+> 	sp->slicepart[1].components[2].offset = -1; /* autocalculate */
+> 	sp->slicepart[1].components[2].bite = 2048;
+> 
+> 	error = g_stripe_calculate(sp);
+> 
+> Setting offset to -1 means "continue wherever we got to".

I'm not sure how to comments this, because I think you misunderstand
my model.

Here is an example (without errors checking) how to create stripe
using 3 disks: da0, da1, da2. Stripe size is 64kB, metadata are stored
on last disk's sector.

gp = g_stripe_create(mp, "test.stripe", /* ndisks */ 3,
    /* stripesize */ 65536, /* sectorsize */ 512, NULL, orphan_func);

pp = g_provider_by_name("da0");
error = g_stripe_attach(gp, pp, /* disk no */ 0, /* number of slices */ 1);
g_stripe_add_slice(gp, pp, /* offset */ 0,
    /* size */ pp->mediasize - pp->sectorsize);

pp = g_provider_by_name("da1");
error = g_stripe_attach(gp, pp, /* disk no */ 1, /* number of slices */ 1);
g_stripe_add_slice(gp, pp, /* offset */ 0,
    /* size */ pp->mediasize - pp->sectorsize);

pp = g_provider_by_name("da2");
error = g_stripe_attach(gp, pp, /* disk no */ 2, /* number of slices */ 1);
g_stripe_add_slice(gp, pp, /* offset */ 0,
    /* size */ pp->mediasize - pp->sectorsize);

That's all, the whole rest will be calculated and configured
automatically.

-- 
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/20040226/de2f5501/attachment.bin


More information about the freebsd-geom mailing list