Deleted Added
sdiff udiff text old ( 265054 ) new ( 298649 )
full compact
1/*-
2 * Copyright (c) 2012 Alexander Motin <mav@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/geom/raid/md_ddf.c 298649 2016-04-26 15:38:17Z pfg $");
29
30#include <sys/param.h>
31#include <sys/bio.h>
32#include <sys/endian.h>
33#include <sys/kernel.h>
34#include <sys/kobj.h>
35#include <sys/limits.h>
36#include <sys/lock.h>

--- 551 unchanged lines hidden (view full) ---

588
589 /* Header */
590 meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK);
591 memset(meta->hdr, 0xff, ss);
592 if (sample) {
593 memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header));
594 if (ss != sample->sectorsize) {
595 SET32(meta, hdr->WorkSpace_Length,
596 howmany(GET32(sample, hdr->WorkSpace_Length) *
597 sample->sectorsize, ss));
598 SET16(meta, hdr->Configuration_Record_Length,
599 howmany(GET16(sample,
600 hdr->Configuration_Record_Length) *
601 sample->sectorsize, ss));
602 SET32(meta, hdr->cd_length,
603 howmany(GET32(sample, hdr->cd_length) *
604 sample->sectorsize, ss));
605 SET32(meta, hdr->pdr_length,
606 howmany(GET32(sample, hdr->pdr_length) *
607 sample->sectorsize, ss));
608 SET32(meta, hdr->vdr_length,
609 howmany(GET32(sample, hdr->vdr_length) *
610 sample->sectorsize, ss));
611 SET32(meta, hdr->cr_length,
612 howmany(GET32(sample, hdr->cr_length) *
613 sample->sectorsize, ss));
614 SET32(meta, hdr->pdd_length,
615 howmany(GET32(sample, hdr->pdd_length) *
616 sample->sectorsize, ss));
617 SET32(meta, hdr->bbmlog_length,
618 howmany(GET32(sample, hdr->bbmlog_length) *
619 sample->sectorsize, ss));
620 SET32(meta, hdr->Diagnostic_Space,
621 howmany(GET32(sample, hdr->bbmlog_length) *
622 sample->sectorsize, ss));
623 SET32(meta, hdr->Vendor_Specific_Logs,
624 howmany(GET32(sample, hdr->bbmlog_length) *
625 sample->sectorsize, ss));
626 }
627 } else {
628 SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE);
629 snprintf(meta->hdr->DDF_Header_GUID, 25, "FreeBSD %08x%08x",
630 (u_int)(ts.tv_sec - DECADE), arc4random());
631 memcpy(meta->hdr->DDF_rev, "02.00.00", 8);
632 SET32(meta, hdr->TimeStamp, (ts.tv_sec - DECADE));
633 SET32(meta, hdr->WorkSpace_Length, 16 * 1024 * 1024 / ss);
634 SET16(meta, hdr->Max_PD_Entries, DDF_MAX_DISKS - 1);
635 SET16(meta, hdr->Max_VD_Entries, DDF_MAX_VDISKS);
636 SET16(meta, hdr->Max_Partitions, DDF_MAX_PARTITIONS);
637 SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS);
638 SET16(meta, hdr->Configuration_Record_Length,
639 howmany(sizeof(struct ddf_vdc_record) + (4 + 8) *
640 GET16(meta, hdr->Max_Primary_Element_Entries), ss));
641 SET32(meta, hdr->cd_length,
642 howmany(sizeof(struct ddf_cd_record), ss));
643 SET32(meta, hdr->pdr_length,
644 howmany(sizeof(struct ddf_pd_record) +
645 sizeof(struct ddf_pd_entry) * GET16(meta,
646 hdr->Max_PD_Entries), ss));
647 SET32(meta, hdr->vdr_length,
648 howmany(sizeof(struct ddf_vd_record) +
649 sizeof(struct ddf_vd_entry) *
650 GET16(meta, hdr->Max_VD_Entries), ss));
651 SET32(meta, hdr->cr_length,
652 GET16(meta, hdr->Configuration_Record_Length) *
653 (GET16(meta, hdr->Max_Partitions) + 1));
654 SET32(meta, hdr->pdd_length,
655 howmany(sizeof(struct ddf_pdd_record), ss));
656 SET32(meta, hdr->bbmlog_length, 0);
657 SET32(meta, hdr->Diagnostic_Space_Length, 0);
658 SET32(meta, hdr->Vendor_Specific_Logs_Length, 0);
659 }
660 pos = 1;
661 SET32(meta, hdr->cd_section, pos);
662 pos += GET32(meta, hdr->cd_length);
663 SET32(meta, hdr->pdr_section, pos);

--- 2422 unchanged lines hidden ---