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.
This commit is contained in:
parent
c9087a9303
commit
55e0987aea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298649
@ -1699,12 +1699,10 @@ ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
|
|||||||
CAM_DIR_OUT,
|
CAM_DIR_OUT,
|
||||||
0,
|
0,
|
||||||
req->data,
|
req->data,
|
||||||
((ranges + ATA_DSM_BLK_RANGES - 1) /
|
howmany(ranges, ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
|
||||||
ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
|
|
||||||
ada_default_timeout * 1000);
|
ada_default_timeout * 1000);
|
||||||
ata_48bit_cmd(ataio, ATA_DATA_SET_MANAGEMENT,
|
ata_48bit_cmd(ataio, ATA_DATA_SET_MANAGEMENT,
|
||||||
ATA_DSM_TRIM, 0, (ranges + ATA_DSM_BLK_RANGES -
|
ATA_DSM_TRIM, 0, howmany(ranges, ATA_DSM_BLK_RANGES));
|
||||||
1) / ATA_DSM_BLK_RANGES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1720,13 +1718,12 @@ ada_ncq_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio
|
|||||||
CAM_DIR_OUT,
|
CAM_DIR_OUT,
|
||||||
0,
|
0,
|
||||||
req->data,
|
req->data,
|
||||||
((ranges + ATA_DSM_BLK_RANGES - 1) /
|
howmany(ranges, ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
|
||||||
ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
|
|
||||||
ada_default_timeout * 1000);
|
ada_default_timeout * 1000);
|
||||||
ata_ncq_cmd(ataio,
|
ata_ncq_cmd(ataio,
|
||||||
ATA_SEND_FPDMA_QUEUED,
|
ATA_SEND_FPDMA_QUEUED,
|
||||||
0,
|
0,
|
||||||
(ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES);
|
howmany(ranges, ATA_DSM_BLK_RANGES));
|
||||||
ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
|
ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
|
||||||
ataio->ata_flags |= ATA_FLAG_AUX;
|
ataio->ata_flags |= ATA_FLAG_AUX;
|
||||||
ataio->aux = 1;
|
ataio->aux = 1;
|
||||||
|
@ -2868,7 +2868,7 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
|
|||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
block_count = (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES;
|
block_count = howmany(ranges, ATA_DSM_BLK_RANGES);
|
||||||
scsi_ata_trim(&ccb->csio,
|
scsi_ata_trim(&ccb->csio,
|
||||||
/*retries*/da_retry_count,
|
/*retries*/da_retry_count,
|
||||||
/*cbfcnp*/dadone,
|
/*cbfcnp*/dadone,
|
||||||
|
@ -4207,7 +4207,7 @@ KeQueryInterruptTime(void)
|
|||||||
|
|
||||||
ticks = tvtohz(&tv);
|
ticks = tvtohz(&tv);
|
||||||
|
|
||||||
return ticks * ((10000000 + hz - 1) / hz);
|
return ticks * howmany(10000000, hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thread *
|
static struct thread *
|
||||||
|
@ -606,9 +606,8 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp)
|
|||||||
} else {
|
} else {
|
||||||
pmp->pm_rootdirblk = pmp->pm_fatblk +
|
pmp->pm_rootdirblk = pmp->pm_fatblk +
|
||||||
(pmp->pm_FATs * pmp->pm_FATsecs);
|
(pmp->pm_FATs * pmp->pm_FATsecs);
|
||||||
pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry)
|
pmp->pm_rootdirsize = howmany(pmp->pm_RootDirEnts *
|
||||||
+ DEV_BSIZE - 1)
|
sizeof(struct direntry), DEV_BSIZE); /* in blocks */
|
||||||
/ DEV_BSIZE; /* in blocks */
|
|
||||||
pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
|
pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +472,7 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_consumer *cp,
|
|||||||
hdr->hdr_lba_table <= hdr->hdr_lba_end)
|
hdr->hdr_lba_table <= hdr->hdr_lba_end)
|
||||||
goto fail;
|
goto fail;
|
||||||
lba = hdr->hdr_lba_table +
|
lba = hdr->hdr_lba_table +
|
||||||
(hdr->hdr_entries * hdr->hdr_entsz + pp->sectorsize - 1) /
|
howmany(hdr->hdr_entries * hdr->hdr_entsz, pp->sectorsize) - 1;
|
||||||
pp->sectorsize - 1;
|
|
||||||
if (lba >= last)
|
if (lba >= last)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (lba >= hdr->hdr_lba_start && lba <= hdr->hdr_lba_end)
|
if (lba >= hdr->hdr_lba_start && lba <= hdr->hdr_lba_end)
|
||||||
@ -515,7 +514,7 @@ gpt_read_tbl(struct g_part_gpt_table *table, struct g_consumer *cp,
|
|||||||
|
|
||||||
table->state[elt] = GPT_STATE_MISSING;
|
table->state[elt] = GPT_STATE_MISSING;
|
||||||
tblsz = hdr->hdr_entries * hdr->hdr_entsz;
|
tblsz = hdr->hdr_entries * hdr->hdr_entsz;
|
||||||
sectors = (tblsz + pp->sectorsize - 1) / pp->sectorsize;
|
sectors = howmany(tblsz, pp->sectorsize);
|
||||||
buf = g_malloc(sectors * pp->sectorsize, M_WAITOK | M_ZERO);
|
buf = g_malloc(sectors * pp->sectorsize, M_WAITOK | M_ZERO);
|
||||||
for (idx = 0; idx < sectors; idx += MAXPHYS / pp->sectorsize) {
|
for (idx = 0; idx < sectors; idx += MAXPHYS / pp->sectorsize) {
|
||||||
size = (sectors - idx > MAXPHYS / pp->sectorsize) ? MAXPHYS:
|
size = (sectors - idx > MAXPHYS / pp->sectorsize) ? MAXPHYS:
|
||||||
@ -653,8 +652,8 @@ g_part_gpt_create(struct g_part_table *basetable, struct g_part_parms *gpp)
|
|||||||
|
|
||||||
table = (struct g_part_gpt_table *)basetable;
|
table = (struct g_part_gpt_table *)basetable;
|
||||||
pp = gpp->gpp_provider;
|
pp = gpp->gpp_provider;
|
||||||
tblsz = (basetable->gpt_entries * sizeof(struct gpt_ent) +
|
tblsz = howmany(basetable->gpt_entries * sizeof(struct gpt_ent),
|
||||||
pp->sectorsize - 1) / pp->sectorsize;
|
pp->sectorsize);
|
||||||
if (pp->sectorsize < MBRSIZE ||
|
if (pp->sectorsize < MBRSIZE ||
|
||||||
pp->mediasize < (3 + 2 * tblsz + basetable->gpt_entries) *
|
pp->mediasize < (3 + 2 * tblsz + basetable->gpt_entries) *
|
||||||
pp->sectorsize)
|
pp->sectorsize)
|
||||||
@ -1134,8 +1133,8 @@ g_part_gpt_write(struct g_part_table *basetable, struct g_consumer *cp)
|
|||||||
|
|
||||||
pp = cp->provider;
|
pp = cp->provider;
|
||||||
table = (struct g_part_gpt_table *)basetable;
|
table = (struct g_part_gpt_table *)basetable;
|
||||||
tblsz = (table->hdr->hdr_entries * table->hdr->hdr_entsz +
|
tblsz = howmany(table->hdr->hdr_entries * table->hdr->hdr_entsz,
|
||||||
pp->sectorsize - 1) / pp->sectorsize;
|
pp->sectorsize);
|
||||||
|
|
||||||
/* Reconstruct the MBR from the GPT if under Boot Camp. */
|
/* Reconstruct the MBR from the GPT if under Boot Camp. */
|
||||||
if (table->bootcamp)
|
if (table->bootcamp)
|
||||||
@ -1239,8 +1238,8 @@ g_gpt_set_defaults(struct g_part_table *basetable, struct g_provider *pp)
|
|||||||
|
|
||||||
table = (struct g_part_gpt_table *)basetable;
|
table = (struct g_part_gpt_table *)basetable;
|
||||||
last = pp->mediasize / pp->sectorsize - 1;
|
last = pp->mediasize / pp->sectorsize - 1;
|
||||||
tblsz = (basetable->gpt_entries * sizeof(struct gpt_ent) +
|
tblsz = howmany(basetable->gpt_entries * sizeof(struct gpt_ent),
|
||||||
pp->sectorsize - 1) / pp->sectorsize;
|
pp->sectorsize);
|
||||||
|
|
||||||
table->lba[GPT_ELT_PRIHDR] = 1;
|
table->lba[GPT_ELT_PRIHDR] = 1;
|
||||||
table->lba[GPT_ELT_PRITBL] = 2;
|
table->lba[GPT_ELT_PRITBL] = 2;
|
||||||
|
@ -1013,8 +1013,7 @@ ldm_vmdb_parse(struct ldm_db *db, struct g_consumer *cp)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
pp = cp->provider;
|
pp = cp->provider;
|
||||||
size = (db->dh.last_seq * db->dh.size +
|
size = howmany(db->dh.last_seq * db->dh.size, pp->sectorsize);
|
||||||
pp->sectorsize - 1) / pp->sectorsize;
|
|
||||||
size -= 1; /* one sector takes vmdb header */
|
size -= 1; /* one sector takes vmdb header */
|
||||||
for (n = 0; n < size; n += MAXPHYS / pp->sectorsize) {
|
for (n = 0; n < size; n += MAXPHYS / pp->sectorsize) {
|
||||||
offset = db->ph.db_offset + db->th.conf_offset + n + 1;
|
offset = db->ph.db_offset + db->th.conf_offset + n + 1;
|
||||||
|
@ -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));
|
memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header));
|
||||||
if (ss != sample->sectorsize) {
|
if (ss != sample->sectorsize) {
|
||||||
SET32(meta, hdr->WorkSpace_Length,
|
SET32(meta, hdr->WorkSpace_Length,
|
||||||
(GET32(sample, hdr->WorkSpace_Length) *
|
howmany(GET32(sample, hdr->WorkSpace_Length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET16(meta, hdr->Configuration_Record_Length,
|
SET16(meta, hdr->Configuration_Record_Length,
|
||||||
(GET16(sample, hdr->Configuration_Record_Length) *
|
howmany(GET16(sample,
|
||||||
sample->sectorsize + ss - 1) / ss);
|
hdr->Configuration_Record_Length) *
|
||||||
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->cd_length,
|
SET32(meta, hdr->cd_length,
|
||||||
(GET32(sample, hdr->cd_length) *
|
howmany(GET32(sample, hdr->cd_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->pdr_length,
|
SET32(meta, hdr->pdr_length,
|
||||||
(GET32(sample, hdr->pdr_length) *
|
howmany(GET32(sample, hdr->pdr_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->vdr_length,
|
SET32(meta, hdr->vdr_length,
|
||||||
(GET32(sample, hdr->vdr_length) *
|
howmany(GET32(sample, hdr->vdr_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->cr_length,
|
SET32(meta, hdr->cr_length,
|
||||||
(GET32(sample, hdr->cr_length) *
|
howmany(GET32(sample, hdr->cr_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->pdd_length,
|
SET32(meta, hdr->pdd_length,
|
||||||
(GET32(sample, hdr->pdd_length) *
|
howmany(GET32(sample, hdr->pdd_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->bbmlog_length,
|
SET32(meta, hdr->bbmlog_length,
|
||||||
(GET32(sample, hdr->bbmlog_length) *
|
howmany(GET32(sample, hdr->bbmlog_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->Diagnostic_Space,
|
SET32(meta, hdr->Diagnostic_Space,
|
||||||
(GET32(sample, hdr->bbmlog_length) *
|
howmany(GET32(sample, hdr->bbmlog_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
SET32(meta, hdr->Vendor_Specific_Logs,
|
SET32(meta, hdr->Vendor_Specific_Logs,
|
||||||
(GET32(sample, hdr->bbmlog_length) *
|
howmany(GET32(sample, hdr->bbmlog_length) *
|
||||||
sample->sectorsize + ss - 1) / ss);
|
sample->sectorsize, ss));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE);
|
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_Partitions, DDF_MAX_PARTITIONS);
|
||||||
SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS);
|
SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS);
|
||||||
SET16(meta, hdr->Configuration_Record_Length,
|
SET16(meta, hdr->Configuration_Record_Length,
|
||||||
(sizeof(struct ddf_vdc_record) +
|
howmany(sizeof(struct ddf_vdc_record) + (4 + 8) *
|
||||||
(4 + 8) * GET16(meta, hdr->Max_Primary_Element_Entries) +
|
GET16(meta, hdr->Max_Primary_Element_Entries), ss));
|
||||||
ss - 1) / ss);
|
|
||||||
SET32(meta, hdr->cd_length,
|
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,
|
SET32(meta, hdr->pdr_length,
|
||||||
(sizeof(struct ddf_pd_record) +
|
howmany(sizeof(struct ddf_pd_record) +
|
||||||
sizeof(struct ddf_pd_entry) *
|
sizeof(struct ddf_pd_entry) * GET16(meta,
|
||||||
GET16(meta, hdr->Max_PD_Entries) + ss - 1) / ss);
|
hdr->Max_PD_Entries), ss));
|
||||||
SET32(meta, hdr->vdr_length,
|
SET32(meta, hdr->vdr_length,
|
||||||
(sizeof(struct ddf_vd_record) +
|
howmany(sizeof(struct ddf_vd_record) +
|
||||||
sizeof(struct ddf_vd_entry) *
|
sizeof(struct ddf_vd_entry) *
|
||||||
GET16(meta, hdr->Max_VD_Entries) + ss - 1) / ss);
|
GET16(meta, hdr->Max_VD_Entries), ss));
|
||||||
SET32(meta, hdr->cr_length,
|
SET32(meta, hdr->cr_length,
|
||||||
GET16(meta, hdr->Configuration_Record_Length) *
|
GET16(meta, hdr->Configuration_Record_Length) *
|
||||||
(GET16(meta, hdr->Max_Partitions) + 1));
|
(GET16(meta, hdr->Max_Partitions) + 1));
|
||||||
SET32(meta, hdr->pdd_length,
|
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->bbmlog_length, 0);
|
||||||
SET32(meta, hdr->Diagnostic_Space_Length, 0);
|
SET32(meta, hdr->Diagnostic_Space_Length, 0);
|
||||||
SET32(meta, hdr->Vendor_Specific_Logs_Length, 0);
|
SET32(meta, hdr->Vendor_Specific_Logs_Length, 0);
|
||||||
|
@ -773,7 +773,7 @@ intel_meta_write(struct g_consumer *cp, struct intel_raid_conf *meta)
|
|||||||
meta->checksum = checksum;
|
meta->checksum = checksum;
|
||||||
|
|
||||||
/* Create and fill buffer. */
|
/* Create and fill buffer. */
|
||||||
sectors = (meta->config_size + pp->sectorsize - 1) / pp->sectorsize;
|
sectors = howmany(meta->config_size, pp->sectorsize);
|
||||||
buf = malloc(sectors * pp->sectorsize, M_MD_INTEL, M_WAITOK | M_ZERO);
|
buf = malloc(sectors * pp->sectorsize, M_MD_INTEL, M_WAITOK | M_ZERO);
|
||||||
if (sectors > 1) {
|
if (sectors > 1) {
|
||||||
memcpy(buf, ((char *)meta) + pp->sectorsize,
|
memcpy(buf, ((char *)meta) + pp->sectorsize,
|
||||||
|
@ -195,9 +195,8 @@ g_uzip_cached(struct g_geom *gp, struct bio *bp)
|
|||||||
|
|
||||||
#define TOFF_2_BOFF(sc, pp, bi) ((sc)->toc[(bi)].offset - \
|
#define TOFF_2_BOFF(sc, pp, bi) ((sc)->toc[(bi)].offset - \
|
||||||
(sc)->toc[(bi)].offset % (pp)->sectorsize)
|
(sc)->toc[(bi)].offset % (pp)->sectorsize)
|
||||||
#define TLEN_2_BLEN(sc, pp, bp, ei) ((BLK_ENDS((sc), (ei)) - \
|
#define TLEN_2_BLEN(sc, pp, bp, ei) roundup(BLK_ENDS((sc), (ei)) - \
|
||||||
(bp)->bio_offset + (pp)->sectorsize - 1) / \
|
(bp)->bio_offset, (pp)->sectorsize)
|
||||||
(pp)->sectorsize * (pp)->sectorsize)
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
g_uzip_request(struct g_geom *gp, struct bio *bp)
|
g_uzip_request(struct g_geom *gp, struct bio *bp)
|
||||||
@ -220,7 +219,7 @@ g_uzip_request(struct g_geom *gp, struct bio *bp)
|
|||||||
ofs = bp->bio_offset + bp->bio_completed;
|
ofs = bp->bio_offset + bp->bio_completed;
|
||||||
start_blk = ofs / sc->blksz;
|
start_blk = ofs / sc->blksz;
|
||||||
KASSERT(start_blk < sc->nblocks, ("start_blk out of range"));
|
KASSERT(start_blk < sc->nblocks, ("start_blk out of range"));
|
||||||
end_blk = (ofs + bp->bio_resid + sc->blksz - 1) / sc->blksz;
|
end_blk = howmany(ofs + bp->bio_resid, sc->blksz);
|
||||||
KASSERT(end_blk <= sc->nblocks, ("end_blk out of range"));
|
KASSERT(end_blk <= sc->nblocks, ("end_blk out of range"));
|
||||||
|
|
||||||
for (; BLK_IS_NIL(sc, start_blk) && start_blk < end_blk; start_blk++) {
|
for (; BLK_IS_NIL(sc, start_blk) && start_blk < end_blk; start_blk++) {
|
||||||
|
@ -625,11 +625,10 @@ tvtohz(tv)
|
|||||||
#endif
|
#endif
|
||||||
ticks = 1;
|
ticks = 1;
|
||||||
} else if (sec <= LONG_MAX / 1000000)
|
} else if (sec <= LONG_MAX / 1000000)
|
||||||
ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1))
|
ticks = howmany(sec * 1000000 + (unsigned long)usec, tick) + 1;
|
||||||
/ tick + 1;
|
|
||||||
else if (sec <= LONG_MAX / hz)
|
else if (sec <= LONG_MAX / hz)
|
||||||
ticks = sec * hz
|
ticks = sec * hz
|
||||||
+ ((unsigned long)usec + (tick - 1)) / tick + 1;
|
+ howmany((unsigned long)usec, tick) + 1;
|
||||||
else
|
else
|
||||||
ticks = LONG_MAX;
|
ticks = LONG_MAX;
|
||||||
if (ticks > INT_MAX)
|
if (ticks > INT_MAX)
|
||||||
|
@ -337,7 +337,7 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
|
|||||||
sbt -= SBT_1S;
|
sbt -= SBT_1S;
|
||||||
}
|
}
|
||||||
/* Do the delay remainder, if any */
|
/* Do the delay remainder, if any */
|
||||||
sbt = (sbt + SBT_1US - 1) / SBT_1US;
|
sbt = howmany(sbt, SBT_1US);
|
||||||
if (sbt > 0)
|
if (sbt > 0)
|
||||||
DELAY(sbt);
|
DELAY(sbt);
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -453,7 +453,7 @@ kern_clock_getres(struct thread *td, clockid_t clock_id, struct timespec *ts)
|
|||||||
case CLOCK_VIRTUAL:
|
case CLOCK_VIRTUAL:
|
||||||
case CLOCK_PROF:
|
case CLOCK_PROF:
|
||||||
/* Accurately round up here because we can do so cheaply. */
|
/* Accurately round up here because we can do so cheaply. */
|
||||||
ts->tv_nsec = (1000000000 + hz - 1) / hz;
|
ts->tv_nsec = howmany(1000000000, hz);
|
||||||
break;
|
break;
|
||||||
case CLOCK_SECOND:
|
case CLOCK_SECOND:
|
||||||
ts->tv_sec = 1;
|
ts->tv_sec = 1;
|
||||||
|
@ -1464,11 +1464,11 @@ adjust_timeout_calltodo(struct timeval *time_change)
|
|||||||
if (time_change->tv_sec < 0)
|
if (time_change->tv_sec < 0)
|
||||||
return;
|
return;
|
||||||
else if (time_change->tv_sec <= LONG_MAX / 1000000)
|
else if (time_change->tv_sec <= LONG_MAX / 1000000)
|
||||||
delta_ticks = (time_change->tv_sec * 1000000 +
|
delta_ticks = howmany(time_change->tv_sec * 1000000 +
|
||||||
time_change->tv_usec + (tick - 1)) / tick + 1;
|
time_change->tv_usec, tick) + 1;
|
||||||
else if (time_change->tv_sec <= LONG_MAX / hz)
|
else if (time_change->tv_sec <= LONG_MAX / hz)
|
||||||
delta_ticks = time_change->tv_sec * hz +
|
delta_ticks = time_change->tv_sec * hz +
|
||||||
(time_change->tv_usec + (tick - 1)) / tick + 1;
|
howmany(time_change->tv_usec, tick) + 1;
|
||||||
else
|
else
|
||||||
delta_ticks = LONG_MAX;
|
delta_ticks = LONG_MAX;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#define PCTRIE_COUNT (1 << PCTRIE_WIDTH)
|
#define PCTRIE_COUNT (1 << PCTRIE_WIDTH)
|
||||||
#define PCTRIE_MASK (PCTRIE_COUNT - 1)
|
#define PCTRIE_MASK (PCTRIE_COUNT - 1)
|
||||||
#define PCTRIE_LIMIT (howmany((sizeof(uint64_t) * NBBY), PCTRIE_WIDTH) - 1)
|
#define PCTRIE_LIMIT (howmany(sizeof(uint64_t) * NBBY, PCTRIE_WIDTH) - 1)
|
||||||
|
|
||||||
/* Flag bits stored in node pointers. */
|
/* Flag bits stored in node pointers. */
|
||||||
#define PCTRIE_ISLEAF 0x1
|
#define PCTRIE_ISLEAF 0x1
|
||||||
|
@ -1542,7 +1542,7 @@ pipe_stat(fp, ub, active_cred, td)
|
|||||||
ub->st_size = pipe->pipe_map.cnt;
|
ub->st_size = pipe->pipe_map.cnt;
|
||||||
else
|
else
|
||||||
ub->st_size = pipe->pipe_buffer.cnt;
|
ub->st_size = pipe->pipe_buffer.cnt;
|
||||||
ub->st_blocks = (ub->st_size + ub->st_blksize - 1) / ub->st_blksize;
|
ub->st_blocks = howmany(ub->st_size, ub->st_blksize);
|
||||||
ub->st_atim = pipe->pipe_atime;
|
ub->st_atim = pipe->pipe_atime;
|
||||||
ub->st_mtim = pipe->pipe_mtime;
|
ub->st_mtim = pipe->pipe_mtime;
|
||||||
ub->st_ctim = pipe->pipe_ctime;
|
ub->st_ctim = pipe->pipe_ctime;
|
||||||
|
@ -842,7 +842,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgflg, mtype)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz;
|
segs_needed = howmany(msgsz, msginfo.msgssz);
|
||||||
DPRINTF(("msgsz=%zu, msgssz=%d, segs_needed=%d\n", msgsz,
|
DPRINTF(("msgsz=%zu, msgssz=%d, segs_needed=%d\n", msgsz,
|
||||||
msginfo.msgssz, segs_needed));
|
msginfo.msgssz, segs_needed));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -380,7 +380,7 @@ shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
|
|||||||
bzero(sb, sizeof(*sb));
|
bzero(sb, sizeof(*sb));
|
||||||
sb->st_blksize = PAGE_SIZE;
|
sb->st_blksize = PAGE_SIZE;
|
||||||
sb->st_size = shmfd->shm_size;
|
sb->st_size = shmfd->shm_size;
|
||||||
sb->st_blocks = (sb->st_size + sb->st_blksize - 1) / sb->st_blksize;
|
sb->st_blocks = howmany(sb->st_size, sb->st_blksize);
|
||||||
mtx_lock(&shm_timestamp_lock);
|
mtx_lock(&shm_timestamp_lock);
|
||||||
sb->st_atim = shmfd->shm_atime;
|
sb->st_atim = shmfd->shm_atime;
|
||||||
sb->st_ctim = shmfd->shm_ctime;
|
sb->st_ctim = shmfd->shm_ctime;
|
||||||
|
@ -1745,7 +1745,7 @@ vtruncbuf(struct vnode *vp, struct ucred *cred, off_t length, int blksize)
|
|||||||
/*
|
/*
|
||||||
* Round up to the *next* lbn.
|
* Round up to the *next* lbn.
|
||||||
*/
|
*/
|
||||||
trunclbn = (length + blksize - 1) / blksize;
|
trunclbn = howmany(length, blksize);
|
||||||
|
|
||||||
ASSERT_VOP_LOCKED(vp, "vtruncbuf");
|
ASSERT_VOP_LOCKED(vp, "vtruncbuf");
|
||||||
restart:
|
restart:
|
||||||
|
@ -202,8 +202,7 @@ krb5_derive_key(struct krb5_key_state *inkey,
|
|||||||
* Generate enough bytes for keybits rounded up to a multiple
|
* Generate enough bytes for keybits rounded up to a multiple
|
||||||
* of blocklen.
|
* of blocklen.
|
||||||
*/
|
*/
|
||||||
randomlen = ((ec->ec_keybits/8 + ec->ec_blocklen - 1) / ec->ec_blocklen)
|
randomlen = roundup(ec->ec_keybits / 8, ec->ec_blocklen);
|
||||||
* ec->ec_blocklen;
|
|
||||||
bytes = malloc(randomlen, M_GSSAPI, M_WAITOK);
|
bytes = malloc(randomlen, M_GSSAPI, M_WAITOK);
|
||||||
MGET(m, M_WAITOK, MT_DATA);
|
MGET(m, M_WAITOK, MT_DATA);
|
||||||
m->m_len = ec->ec_blocklen;
|
m->m_len = ec->ec_blocklen;
|
||||||
|
@ -274,7 +274,7 @@ arc_frag_next(struct ifnet *ifp)
|
|||||||
return m;
|
return m;
|
||||||
|
|
||||||
++ac->ac_seqid; /* make the seqid unique */
|
++ac->ac_seqid; /* make the seqid unique */
|
||||||
tfrags = (m->m_pkthdr.len + ARC_MAX_DATA - 1) / ARC_MAX_DATA;
|
tfrags = howmany(m->m_pkthdr.len, ARC_MAX_DATA);
|
||||||
ac->fsflag = 2 * tfrags - 3;
|
ac->fsflag = 2 * tfrags - 3;
|
||||||
ac->sflag = 0;
|
ac->sflag = 0;
|
||||||
ac->rsflag = ac->fsflag;
|
ac->rsflag = ac->fsflag;
|
||||||
|
@ -846,7 +846,7 @@ ng_pptpgre_start_recv_ack_timer(hpriv_p hpriv)
|
|||||||
remain = 0;
|
remain = 0;
|
||||||
|
|
||||||
/* Be conservative: timeout can happen up to 1 tick early */
|
/* Be conservative: timeout can happen up to 1 tick early */
|
||||||
ticks = (((remain * hz) + PPTP_TIME_SCALE - 1) / PPTP_TIME_SCALE) + 1;
|
ticks = howmany(remain * hz, PPTP_TIME_SCALE) + 1;
|
||||||
ng_callout(&hpriv->rackTimer, hpriv->node, hpriv->hook,
|
ng_callout(&hpriv->rackTimer, hpriv->node, hpriv->hook,
|
||||||
ticks, ng_pptpgre_recv_ack_timeout, hpriv, 0);
|
ticks, ng_pptpgre_recv_ack_timeout, hpriv, 0);
|
||||||
}
|
}
|
||||||
@ -894,7 +894,7 @@ ng_pptpgre_start_send_ack_timer(hpriv_p hpriv)
|
|||||||
ackTimeout = PPTP_MAX_ACK_DELAY;
|
ackTimeout = PPTP_MAX_ACK_DELAY;
|
||||||
|
|
||||||
/* Be conservative: timeout can happen up to 1 tick early */
|
/* Be conservative: timeout can happen up to 1 tick early */
|
||||||
ticks = (((ackTimeout * hz) + PPTP_TIME_SCALE - 1) / PPTP_TIME_SCALE);
|
ticks = howmany(ackTimeout * hz, PPTP_TIME_SCALE);
|
||||||
ng_callout(&hpriv->sackTimer, hpriv->node, hpriv->hook,
|
ng_callout(&hpriv->sackTimer, hpriv->node, hpriv->hook,
|
||||||
ticks, ng_pptpgre_send_ack_timeout, hpriv, 0);
|
ticks, ng_pptpgre_send_ack_timeout, hpriv, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user