From owner-freebsd-geom@FreeBSD.ORG Wed Feb 25 02:31:01 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B372916A4CE for ; Wed, 25 Feb 2004 02:31:01 -0800 (PST) Received: from darkness.comp.waw.pl (unknown [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 12F1D43D1F for ; Wed, 25 Feb 2004 02:31:00 -0800 (PST) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id EC1E2AEA50; Wed, 25 Feb 2004 11:30:57 +0100 (CET) Date: Wed, 25 Feb 2004 11:30:57 +0100 From: Pawel Jakub Dawidek To: freebsd-geom@freebsd.org Message-ID: <20040225103057.GB5506@darkness.comp.waw.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tjCHc7DPkfUGtrlw" Content-Disposition: inline User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 Subject: GEOM stripe library. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2004 10:31:02 -0000 --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--