summaryrefslogtreecommitdiffstats
path: root/sys/geom/raid/md_ddf.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-26 15:38:17 +0000
committerpfg <pfg@FreeBSD.org>2016-04-26 15:38:17 +0000
commitfc01419148d065603607b1008d536431465f3bc3 (patch)
tree1bff72784c0591a61e4e16e97fae48d0614891dc /sys/geom/raid/md_ddf.c
parent3a3f015eb3ae533a46cf30b5262d15cb4b5db097 (diff)
downloadFreeBSD-src-fc01419148d065603607b1008d536431465f3bc3.zip
FreeBSD-src-fc01419148d065603607b1008d536431465f3bc3.tar.gz
sys: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
Diffstat (limited to 'sys/geom/raid/md_ddf.c')
-rw-r--r--sys/geom/raid/md_ddf.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/sys/geom/raid/md_ddf.c b/sys/geom/raid/md_ddf.c
index eed048d..686bd4d 100644
--- a/sys/geom/raid/md_ddf.c
+++ b/sys/geom/raid/md_ddf.c
@@ -593,35 +593,36 @@ ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample)
memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header));
if (ss != sample->sectorsize) {
SET32(meta, hdr->WorkSpace_Length,
- (GET32(sample, hdr->WorkSpace_Length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->WorkSpace_Length) *
+ sample->sectorsize, ss));
SET16(meta, hdr->Configuration_Record_Length,
- (GET16(sample, hdr->Configuration_Record_Length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET16(sample,
+ hdr->Configuration_Record_Length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->cd_length,
- (GET32(sample, hdr->cd_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->cd_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->pdr_length,
- (GET32(sample, hdr->pdr_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->pdr_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->vdr_length,
- (GET32(sample, hdr->vdr_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->vdr_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->cr_length,
- (GET32(sample, hdr->cr_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->cr_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->pdd_length,
- (GET32(sample, hdr->pdd_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->pdd_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->bbmlog_length,
- (GET32(sample, hdr->bbmlog_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->bbmlog_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->Diagnostic_Space,
- (GET32(sample, hdr->bbmlog_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->bbmlog_length) *
+ sample->sectorsize, ss));
SET32(meta, hdr->Vendor_Specific_Logs,
- (GET32(sample, hdr->bbmlog_length) *
- sample->sectorsize + ss - 1) / ss);
+ howmany(GET32(sample, hdr->bbmlog_length) *
+ sample->sectorsize, ss));
}
} else {
SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE);
@@ -635,24 +636,23 @@ ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample)
SET16(meta, hdr->Max_Partitions, DDF_MAX_PARTITIONS);
SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS);
SET16(meta, hdr->Configuration_Record_Length,
- (sizeof(struct ddf_vdc_record) +
- (4 + 8) * GET16(meta, hdr->Max_Primary_Element_Entries) +
- ss - 1) / ss);
+ howmany(sizeof(struct ddf_vdc_record) + (4 + 8) *
+ GET16(meta, hdr->Max_Primary_Element_Entries), ss));
SET32(meta, hdr->cd_length,
- (sizeof(struct ddf_cd_record) + ss - 1) / ss);
+ howmany(sizeof(struct ddf_cd_record), ss));
SET32(meta, hdr->pdr_length,
- (sizeof(struct ddf_pd_record) +
- sizeof(struct ddf_pd_entry) *
- GET16(meta, hdr->Max_PD_Entries) + ss - 1) / ss);
+ howmany(sizeof(struct ddf_pd_record) +
+ sizeof(struct ddf_pd_entry) * GET16(meta,
+ hdr->Max_PD_Entries), ss));
SET32(meta, hdr->vdr_length,
- (sizeof(struct ddf_vd_record) +
- sizeof(struct ddf_vd_entry) *
- GET16(meta, hdr->Max_VD_Entries) + ss - 1) / ss);
+ howmany(sizeof(struct ddf_vd_record) +
+ sizeof(struct ddf_vd_entry) *
+ GET16(meta, hdr->Max_VD_Entries), ss));
SET32(meta, hdr->cr_length,
GET16(meta, hdr->Configuration_Record_Length) *
(GET16(meta, hdr->Max_Partitions) + 1));
SET32(meta, hdr->pdd_length,
- (sizeof(struct ddf_pdd_record) + ss - 1) / ss);
+ howmany(sizeof(struct ddf_pdd_record), ss));
SET32(meta, hdr->bbmlog_length, 0);
SET32(meta, hdr->Diagnostic_Space_Length, 0);
SET32(meta, hdr->Vendor_Specific_Logs_Length, 0);
OpenPOWER on IntegriCloud