GEOM stripe library.

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Feb 26 12:43:50 PST 2004


In message <20040226203807.GD5720 at darkness.comp.waw.pl>, Pawel Jakub Dawidek wr
ites:

>+> And would look like this in C code:
>+>=20
>+> 	struct stripe *sp;
>+>=20
>+> 	sp =3D g_stripe_new(/* consumers */ 3, /* parts */ 3);
>+>=20
>+> 	sp->consumer[0] =3D c0;
>+> 	sp->consumer[1] =3D c1;
>+> 	sp->consumer[2] =3D c2;
>+> 	sp->slicepart[0].stripes =3D 1024;
>+> 	for (i =3D 0; i < 3; i++) {
>+> 		sp->slicepart[0].components[i].offset =3D 1024;
>+> 		sp->slicepart[0].components[i].bite =3D 1024;
>+> 	}
>+> 	sp->slicepart[1].stripes =3D 3072;
>+> 	sp->slicepart[1].components[0].offset =3D -1; /* autocalculate */
>+> 	sp->slicepart[1].components[0].bite =3D 512;
>+> 	sp->slicepart[1].components[2].offset =3D -1; /* autocalculate */
>+> 	sp->slicepart[1].components[2].bite =3D 512;
>+>=20
>+> 	sp->slicepart[1].stripes =3D 256;
>+> 	sp->slicepart[1].components[2].offset =3D -1; /* autocalculate */
>+> 	sp->slicepart[1].components[2].bite =3D 2048;
>+>=20
>+> 	error =3D g_stripe_calculate(sp);
>+>=20
>+> 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.

The beauty of my model is that there is only two function calls doing
one memory allocation involved in this, rather than a ton of function
calls where you have to check the error code after each and every
one.  (See my daemon-news "blueprint" articles for more on this).

I also think that you should be prepared for non-uniform striping,
even if you think it complicates things, because it exits in real
life, even if you have not seen it.

If you library is insufficiently general, then it will not gain
us enough code reuse to be worth the trouble.


-- 
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