Date: Mon, 31 Jan 2005 14:58:23 +0100 From: Ulrich Spoerlein <q@uni.de> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: freebsd-stable@freebsd.org Subject: Re: Size of metadata required for GBDE Message-ID: <20050131135823.GD828@galgenberg.net> In-Reply-To: <76988.1107123877@critter.freebsd.dk> References: <20050130221803.GB2600@galgenberg.net> <76988.1107123877@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
--bGR76rFJjkSxVeRa Content-Type: multipart/mixed; boundary="3O1VwFp74L81IIeR" Content-Disposition: inline --3O1VwFp74L81IIeR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, 30.01.2005 at 23:24:37 +0100, Poul-Henning Kamp wrote: > The amount of metadata in GBDE is pretty straight forward: >=20 > 1. If do not use off-line keyfiles: deduct one sector. >=20 > 2. Deduct the key sectors (1 to 4) >=20 > 3. Find zone size: >=20 > nsect =3D sectorsize / 16 > nzone =3D nsect + 1 >=20 > 4. Find number of zones: >=20 > z =3D remaining_sectors / nzone >=20 > 5. Find usable size: >=20 > size =3D z * nsect >=20 > 6. Find overhead/metadata as: >=20 > total_sectors - size This translates to: overhead =3D sectors - (sectors-4-1)/((sectorsize/16) + 1) * sectorsize/16 So, if I understand that correctly, I need one additional sector every 16 sectors and 5 sectors for the keys (using all the gbde init defaults). What's wrong with the attached program then? It gives wrong results :( % cc -Wall gbde.c -o gbde && ./gbde $((31744*512)) Wanted size: 16252928 bytes in 31744 sectors (blocksize 512) Needed size: 16763392 bytes in 32741 sectors (blocksize 512) This should be 32768 sectors, as can be seen from my earlier mail. Ulrich Spoerlein --=20 PGP Key ID: F0DB9F44 Encrypted mail welcome! Fingerprint: F1CE D062 0CA9 ADE3 349B 2FE8 980A C6B5 F0DB 9F44 Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn." didn't you understand? --3O1VwFp74L81IIeR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="gbde.c" Content-Transfer-Encoding: quoted-printable #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int okeysec =3D 1; int nkeysec =3D 4; int sectorsize =3D 512; long long size, wanted_sec, needed_sec; if (argc < 2) exit(1); =20 size =3D atoll(argv[1]); if (argc =3D=3D 3) sectorsize =3D atoi(argv[2]); =20 /* Round up to nearest multiple of sectorsize */ if (size % sectorsize) size +=3D sectorsize - size % sectorsize; wanted_sec =3D size / sectorsize; printf("Wanted size: %lld bytes in %lld sectors (blocksize %d)\n", wanted_sec*sectorsize, wanted_sec, sectorsize); needed_sec =3D wanted_sec + (wanted_sec*16)/sectorsize + okeysec + nkeyse= c; printf("Needed size: %lld bytes in %lld sectors (blocksize %d)\n", needed_sec*sectorsize, needed_sec, sectorsize); return (0); } --3O1VwFp74L81IIeR-- --bGR76rFJjkSxVeRa Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFB/jl/mArGtfDbn0QRAsqDAKDRgFtkiZbS1y4GCDXDXqoAxL1/QgCfZ0mE mh1E2CR9aYgwqVJlulowsWk= =Kq+Z -----END PGP SIGNATURE----- --bGR76rFJjkSxVeRa--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050131135823.GD828>