Lines Matching refs:md

154 my_g_metadata_store(const char *name, u_char *md, size_t size)
185 bcopy(md, sector, size);
207 struct g_virstor_metadata md;
236 bzero(&md, sizeof(md));
237 strlcpy(md.md_magic, G_VIRSTOR_MAGIC, sizeof(md.md_magic));
238 md.md_version = G_VIRSTOR_VERSION;
244 strlcpy(md.md_name, name, sizeof(md.md_name));
246 md.md_virsize = (off_t)gctl_get_intmax(req, "vir_size");
247 md.md_chunk_size = gctl_get_intmax(req, "chunk_size");
248 md.md_count = nargs - 1;
250 if (md.md_virsize == 0 || md.md_chunk_size == 0) {
255 if (md.md_chunk_size % MAXPHYS != 0) {
258 size_t new_size = rounddown(md.md_chunk_size, MAXPHYS);
259 if (new_size < md.md_chunk_size)
264 md.md_chunk_size = new_size;
267 if (md.md_virsize % md.md_chunk_size != 0) {
268 off_t chunk_count = md.md_virsize / md.md_chunk_size;
269 md.md_virsize = chunk_count * md.md_chunk_size;
273 (size_t)(md.md_virsize/(1024 * 1024)));
299 if (md.md_chunk_size % secsize != 0) {
307 total_chunks = md.md_virsize / md.md_chunk_size;
309 assert(md.md_virsize % md.md_chunk_size == 0);
315 md.md_virsize = (off_t)total_chunks * (off_t)md.md_chunk_size;
320 (uintmax_t)(md.md_virsize / (1024 * 1024)), add_chunks);
326 total_chunks, (size_t)(md.md_chunk_size / (1024 * 1024)),
327 md.md_virsize/(1024 * 1024));
329 if ((off_t)md.md_virsize < msize)
331 "available storage (%ju < %ju)\n", md.md_virsize, msize);
351 if (msize < (off_t) MAX(md.md_chunk_size*4, map_size))
370 map_chunks = map_size/md.md_chunk_size;
371 if (map_size % md.md_chunk_size != 0)
415 md.md_id = arc4random();
429 md.no = i - 1;
431 md.provsize = msize;
433 md.chunk_count = md.provsize / md.md_chunk_size;
435 printf("(%u chunks) ", md.chunk_count);
437 if ((off_t)(md.chunk_count * md.md_chunk_size) > (off_t)(msize-ssize))
438 md.chunk_count--;
439 md.chunk_next = 0;
441 md.chunk_reserved = 0;
442 md.flags = 0;
444 md.chunk_reserved = map_chunks * 2;
445 md.flags = VIRSTOR_PROVIDER_ALLOCATED |
447 md.chunk_next = md.chunk_reserved;
449 printf("(%u reserved) ", md.chunk_reserved);
453 bzero(md.provider, sizeof(md.provider));
457 strlcpy(md.provider, name + sizeof(_PATH_DEV) - 1,
458 sizeof(md.provider));
460 strlcpy(md.provider, name, sizeof(md.provider));
466 virstor_metadata_encode(&md, sect);
530 virstor_metadata_dump(const struct g_virstor_metadata *md)
532 printf(" Magic string: %s\n", md->md_magic);
533 printf(" Metadata version: %u\n", (u_int) md->md_version);
534 printf(" Device name: %s\n", md->md_name);
535 printf(" Device ID: %u\n", (u_int) md->md_id);
536 printf(" Provider index: %u\n", (u_int) md->no);
537 printf(" Active providers: %u\n", (u_int) md->md_count);
539 md->provider[0] != '\0' ? md->provider : "(not hardcoded)");
541 (unsigned int)(md->md_virsize/(1024 * 1024)));
542 printf(" Chunk size: %u kB\n", md->md_chunk_size / 1024);
543 printf(" Chunks on provider: %u\n", md->chunk_count);
544 printf(" Chunks free: %u\n", md->chunk_count - md->chunk_next);
545 printf(" Reserved chunks: %u\n", md->chunk_reserved);
552 struct g_virstor_metadata md;
558 assert(sizeof(tmpmd) >= sizeof(md));
578 virstor_metadata_decode((u_char *) & tmpmd, &md);
580 virstor_metadata_dump(&md);