Size of metadata required for GBDE
Ulrich Spoerlein
q at uni.de
Mon Jan 31 05:58:26 PST 2005
On Sun, 30.01.2005 at 23:24:37 +0100, Poul-Henning Kamp wrote:
> The amount of metadata in GBDE is pretty straight forward:
>
> 1. If do not use off-line keyfiles: deduct one sector.
>
> 2. Deduct the key sectors (1 to 4)
>
> 3. Find zone size:
>
> nsect = sectorsize / 16
> nzone = nsect + 1
>
> 4. Find number of zones:
>
> z = remaining_sectors / nzone
>
> 5. Find usable size:
>
> size = z * nsect
>
> 6. Find overhead/metadata as:
>
> total_sectors - size
This translates to:
overhead = 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
--
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?
-------------- next part --------------
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char **argv) {
int okeysec = 1;
int nkeysec = 4;
int sectorsize = 512;
long long size, wanted_sec, needed_sec;
if (argc < 2)
exit(1);
size = atoll(argv[1]);
if (argc == 3)
sectorsize = atoi(argv[2]);
/* Round up to nearest multiple of sectorsize */
if (size % sectorsize)
size += sectorsize - size % sectorsize;
wanted_sec = size / sectorsize;
printf("Wanted size: %lld bytes in %lld sectors (blocksize %d)\n",
wanted_sec*sectorsize, wanted_sec, sectorsize);
needed_sec = wanted_sec + (wanted_sec*16)/sectorsize + okeysec + nkeysec;
printf("Needed size: %lld bytes in %lld sectors (blocksize %d)\n",
needed_sec*sectorsize, needed_sec, sectorsize);
return (0);
}
-------------- 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-stable/attachments/20050131/0a08326c/attachment.bin
More information about the freebsd-stable
mailing list