md_ddf.c (265054) | md_ddf.c (298649) |
---|---|
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> | 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 265054 2014-04-28 15:03:52Z mav $"); | 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, | 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 (GET32(sample, hdr->WorkSpace_Length) * 597 sample->sectorsize + ss - 1) / ss); | 596 howmany(GET32(sample, hdr->WorkSpace_Length) * 597 sample->sectorsize, ss)); |
598 SET16(meta, hdr->Configuration_Record_Length, | 598 SET16(meta, hdr->Configuration_Record_Length, |
599 (GET16(sample, hdr->Configuration_Record_Length) * 600 sample->sectorsize + ss - 1) / ss); | 599 howmany(GET16(sample, 600 hdr->Configuration_Record_Length) * 601 sample->sectorsize, ss)); |
601 SET32(meta, hdr->cd_length, | 602 SET32(meta, hdr->cd_length, |
602 (GET32(sample, hdr->cd_length) * 603 sample->sectorsize + ss - 1) / ss); | 603 howmany(GET32(sample, hdr->cd_length) * 604 sample->sectorsize, ss)); |
604 SET32(meta, hdr->pdr_length, | 605 SET32(meta, hdr->pdr_length, |
605 (GET32(sample, hdr->pdr_length) * 606 sample->sectorsize + ss - 1) / ss); | 606 howmany(GET32(sample, hdr->pdr_length) * 607 sample->sectorsize, ss)); |
607 SET32(meta, hdr->vdr_length, | 608 SET32(meta, hdr->vdr_length, |
608 (GET32(sample, hdr->vdr_length) * 609 sample->sectorsize + ss - 1) / ss); | 609 howmany(GET32(sample, hdr->vdr_length) * 610 sample->sectorsize, ss)); |
610 SET32(meta, hdr->cr_length, | 611 SET32(meta, hdr->cr_length, |
611 (GET32(sample, hdr->cr_length) * 612 sample->sectorsize + ss - 1) / ss); | 612 howmany(GET32(sample, hdr->cr_length) * 613 sample->sectorsize, ss)); |
613 SET32(meta, hdr->pdd_length, | 614 SET32(meta, hdr->pdd_length, |
614 (GET32(sample, hdr->pdd_length) * 615 sample->sectorsize + ss - 1) / ss); | 615 howmany(GET32(sample, hdr->pdd_length) * 616 sample->sectorsize, ss)); |
616 SET32(meta, hdr->bbmlog_length, | 617 SET32(meta, hdr->bbmlog_length, |
617 (GET32(sample, hdr->bbmlog_length) * 618 sample->sectorsize + ss - 1) / ss); | 618 howmany(GET32(sample, hdr->bbmlog_length) * 619 sample->sectorsize, ss)); |
619 SET32(meta, hdr->Diagnostic_Space, | 620 SET32(meta, hdr->Diagnostic_Space, |
620 (GET32(sample, hdr->bbmlog_length) * 621 sample->sectorsize + ss - 1) / ss); | 621 howmany(GET32(sample, hdr->bbmlog_length) * 622 sample->sectorsize, ss)); |
622 SET32(meta, hdr->Vendor_Specific_Logs, | 623 SET32(meta, hdr->Vendor_Specific_Logs, |
623 (GET32(sample, hdr->bbmlog_length) * 624 sample->sectorsize + ss - 1) / ss); | 624 howmany(GET32(sample, hdr->bbmlog_length) * 625 sample->sectorsize, ss)); |
625 } 626 } else { 627 SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE); 628 snprintf(meta->hdr->DDF_Header_GUID, 25, "FreeBSD %08x%08x", 629 (u_int)(ts.tv_sec - DECADE), arc4random()); 630 memcpy(meta->hdr->DDF_rev, "02.00.00", 8); 631 SET32(meta, hdr->TimeStamp, (ts.tv_sec - DECADE)); 632 SET32(meta, hdr->WorkSpace_Length, 16 * 1024 * 1024 / ss); 633 SET16(meta, hdr->Max_PD_Entries, DDF_MAX_DISKS - 1); 634 SET16(meta, hdr->Max_VD_Entries, DDF_MAX_VDISKS); 635 SET16(meta, hdr->Max_Partitions, DDF_MAX_PARTITIONS); 636 SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS); 637 SET16(meta, hdr->Configuration_Record_Length, | 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, |
638 (sizeof(struct ddf_vdc_record) + 639 (4 + 8) * GET16(meta, hdr->Max_Primary_Element_Entries) + 640 ss - 1) / ss); | 639 howmany(sizeof(struct ddf_vdc_record) + (4 + 8) * 640 GET16(meta, hdr->Max_Primary_Element_Entries), ss)); |
641 SET32(meta, hdr->cd_length, | 641 SET32(meta, hdr->cd_length, |
642 (sizeof(struct ddf_cd_record) + ss - 1) / ss); | 642 howmany(sizeof(struct ddf_cd_record), ss)); |
643 SET32(meta, hdr->pdr_length, | 643 SET32(meta, hdr->pdr_length, |
644 (sizeof(struct ddf_pd_record) + 645 sizeof(struct ddf_pd_entry) * 646 GET16(meta, hdr->Max_PD_Entries) + ss - 1) / ss); | 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, | 647 SET32(meta, hdr->vdr_length, |
648 (sizeof(struct ddf_vd_record) + 649 sizeof(struct ddf_vd_entry) * 650 GET16(meta, hdr->Max_VD_Entries) + ss - 1) / ss); | 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, | 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 (sizeof(struct ddf_pdd_record) + ss - 1) / ss); | 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 --- | 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 --- |