Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2004 11:30:57 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        freebsd-geom@freebsd.org
Subject:   GEOM stripe library.
Message-ID:  <20040225103057.GB5506@darkness.comp.waw.pl>

next in thread | raw e-mail | index | archive | help

--tjCHc7DPkfUGtrlw
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 =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)
 *
 * d_slices[1].s_offset =3D 4096
 * d_slices[1].s_length =3D 3072
 * d_slices[1].s_virt_offset =3D 2048	(d_slices[0].s_virt_end)
 * d_slices[1].s_virt_end =3D 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 =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
 *
 * sc_groups[1].g_ndisks =3D 2
 * sc_groups[1].g_disks =3D { 0, 2 }
 * sc_groups[1].g_start_offset =3D 3072
 * sc_groups[1].g_end_offset =3D 6144
 * sc_groups[1].g_start_disk =3D 2560
 *
 * sc_groups[2].g_ndisks =3D 1
 * sc_groups[2].g_disks =3D { 2 }
 * sc_groups[2].g_start_offset =3D 6144
 * sc_groups[2].g_end_offset =3D 6656
 * sc_groups[2].g_start_disk =3D 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 off=
set,
    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);

--=20
Pawel Jakub Dawidek                       http://www.FreeBSD.org
pjd@FreeBSD.org                           http://garage.freebsd.pl
FreeBSD committer                         Am I Evil? Yes, I Am!

--tjCHc7DPkfUGtrlw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAPHlhForvXbEpPzQRAtfnAJ0RsHIql1chTQKBovg1LkjkGj3GOACg9FSE
5TN7Qvuh8ZEBLzF6YuxmNaQ=
=Q54X
-----END PGP SIGNATURE-----

--tjCHc7DPkfUGtrlw--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040225103057.GB5506>