sizeof (cksum_record_t), offsetof(cksum_record_t, link));
psize = statbuf.st_size;
- psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
+ psize = P2ALIGN_TYPED(psize, sizeof (vdev_label_t), uint64_t);
ashift = SPA_MINBLOCKSHIFT;
/*
ASSERT3P(zio, !=, NULL);
size = doi.doi_data_block_size;
if (ISP2(size)) {
- offset = P2ALIGN(offset, size);
+ offset = P2ALIGN_TYPED(offset, size, uint64_t);
} else {
ASSERT3U(offset, <, size);
offset = 0;
raidvd = vdev_lookup_top(spa, vre->vre_vdev_id);
offset = RRSS_GET_OFFSET(&spa->spa_uberblock);
state = RRSS_GET_STATE(&spa->spa_uberblock);
- write_size = P2ALIGN(VDEV_BOOT_SIZE, 1 << raidvd->vdev_ashift);
+ write_size = P2ALIGN_TYPED(VDEV_BOOT_SIZE, 1 << raidvd->vdev_ashift,
+ uint64_t);
logical_size = write_size * raidvd->vdev_children;
switch (state) {
*/
mutex_enter(&os->os_obj_lock);
object = ztest_random(os->os_obj_next_chunk);
- os->os_obj_next_chunk = P2ALIGN(object, dnodes_per_chunk);
+ os->os_obj_next_chunk = P2ALIGN_TYPED(object, dnodes_per_chunk,
+ uint64_t);
mutex_exit(&os->os_obj_lock);
}
* the end of the disk (vdev_psize) is aligned to
* sizeof (vdev_label_t).
*/
- uint64_t psize = P2ALIGN(fsize, sizeof (vdev_label_t));
+ uint64_t psize = P2ALIGN_TYPED(fsize, sizeof (vdev_label_t),
+ uint64_t);
if ((leaf & 1) == 1 &&
offset + sizeof (bad) > psize - VDEV_LABEL_END_SIZE)
continue;
size_t inc = 64 * ztest_random(size / 67);
/* sometimes add few bytes to test non-simd */
if (ztest_random(100) < 10)
- inc += P2ALIGN(ztest_random(64),
- sizeof (uint32_t));
+ inc += P2ALIGN_TYPED(ztest_random(64),
+ sizeof (uint32_t), uint64_t);
if (inc > (size - pos))
inc = size - pos;
#define readdir64 readdir
#define dirent64 dirent
#endif
-#define P2ALIGN(x, align) ((x) & -(align))
+// Deprecated. Use P2ALIGN_TYPED instead.
+// #define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1)
#define P2PHASE(x, align) ((x) & ((align) - 1))
* eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align)
* eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align)
*/
-#define P2ALIGN(x, align) ((x) & -(align))
+// Deprecated. Use P2ALIGN_TYPED instead.
+// #define P2ALIGN(x, align) ((x) & -(align))
/*
* return x % (mod) align
/*
* Compatibility macros/typedefs needed for Solaris -> Linux port
*/
-#define P2ALIGN(x, align) ((x) & -(align))
+// Deprecated. Use P2ALIGN_TYPED instead.
+// #define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1)
#define P2PHASE(x, align) ((x) & ((align) - 1))
* (for performance reasons). The alignment should match the
* alignment used by the "zpool_label_disk" function.
*/
- limit = P2ALIGN(efi_label->efi_last_lba - nblocks - EFI_MIN_RESV_SIZE,
- PARTITION_END_ALIGNMENT);
+ limit = P2ALIGN_TYPED(efi_label->efi_last_lba - nblocks -
+ EFI_MIN_RESV_SIZE, PARTITION_END_ALIGNMENT, diskaddr_t);
if (data_start + data_size != limit || resv_start != limit)
sync_needed = B_TRUE;
/*
* Compatibility macros/typedefs needed for Solaris -> Linux port
*/
-#define P2ALIGN(x, align) ((x) & -(align))
+// Deprecated. Use P2ALIGN_TYPED instead.
+// #define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) ((((x) - 1) | ((align) - 1)) + 1)
#define P2BOUNDARY(off, len, align) \
if (start_block == MAXOFFSET_T)
start_block = NEW_START_BLOCK;
slice_size -= start_block;
- slice_size = P2ALIGN(slice_size, PARTITION_END_ALIGNMENT);
+ slice_size = P2ALIGN_TYPED(slice_size, PARTITION_END_ALIGNMENT,
+ uint64_t);
vtoc->efi_parts[0].p_start = start_block;
vtoc->efi_parts[0].p_size = slice_size;
ZFS_LOG(1, "Reading config from %s...", pp->name);
psize = pp->mediasize;
- psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
+ psize = P2ALIGN_TYPED(psize, sizeof (vdev_label_t), uint64_t);
size = sizeof (*vdev_lists[0]) + pp->sectorsize -
((sizeof (*vdev_lists[0]) - 1) % pp->sectorsize) - 1;
*/
if (!io_is_secure_erase(bio, rq)) {
start = P2ROUNDUP(start, zv->zv_volblocksize);
- end = P2ALIGN(end, zv->zv_volblocksize);
+ end = P2ALIGN_TYPED(end, zv->zv_volblocksize, uint64_t);
size = end - start;
}
const void *ctx_template, zio_cksum_t *zcp)
{
(void) ctx_template;
- const uint64_t p2size = P2ALIGN(size, FLETCHER_MIN_SIMD_SIZE);
+ const uint64_t p2size = P2ALIGN_TYPED(size, FLETCHER_MIN_SIMD_SIZE,
+ uint64_t);
ASSERT(IS_P2ALIGNED(size, sizeof (uint32_t)));
const void *ctx_template, zio_cksum_t *zcp)
{
(void) ctx_template;
- const uint64_t p2size = P2ALIGN(size, FLETCHER_MIN_SIMD_SIZE);
+ const uint64_t p2size = P2ALIGN_TYPED(size, FLETCHER_MIN_SIMD_SIZE,
+ uint64_t);
ASSERT(IS_P2ALIGNED(size, sizeof (uint32_t)));
fletcher_4_ctx_t *ctx = cdp->acd_ctx;
fletcher_4_ops_t *ops = (fletcher_4_ops_t *)cdp->acd_private;
boolean_t native = cdp->acd_byteorder == ZIO_CHECKSUM_NATIVE;
- uint64_t asize = P2ALIGN(size, FLETCHER_MIN_SIMD_SIZE);
+ uint64_t asize = P2ALIGN_TYPED(size, FLETCHER_MIN_SIMD_SIZE, uint64_t);
ASSERT(IS_P2ALIGNED(size, sizeof (uint32_t)));
zfs_btree_find_in_buf : bt_find_in_buf;
tree->bt_elem_size = size;
tree->bt_leaf_size = lsize;
- tree->bt_leaf_cap = P2ALIGN(esize / size, 2);
+ tree->bt_leaf_cap = P2ALIGN_TYPED(esize / size, 2, size_t);
tree->bt_height = -1;
tree->bt_bulk = NULL;
}
if (dn->dn_datablkshift) {
int blkshift = dn->dn_datablkshift;
nblks = (P2ROUNDUP(offset + length, 1ULL << blkshift) -
- P2ALIGN(offset, 1ULL << blkshift)) >> blkshift;
+ P2ALIGN_TYPED(offset, 1ULL << blkshift, uint64_t))
+ >> blkshift;
} else {
if (offset + length > dn->dn_datablksz) {
zfs_panic_recover("zfs: accessing past end of object "
}
/* set start to the beginning of this L1 indirect */
- *start = P2ALIGN(*start, iblkrange);
+ *start = P2ALIGN_TYPED(*start, iblkrange, uint64_t);
}
if (*start < minimum)
*start = minimum;
* is not suitably aligned.
*/
os->os_obj_next_chunk =
- P2ALIGN(object, dnodes_per_chunk) +
+ P2ALIGN_TYPED(object, dnodes_per_chunk, uint64_t) +
dnodes_per_chunk;
(void) atomic_swap_64(cpuobj, object);
mutex_exit(&os->os_obj_lock);
* metaslabs. We report the expandable space in terms
* of the metaslab size since that's the unit of expansion.
*/
- space += P2ALIGN(tvd->vdev_max_asize - tvd->vdev_asize,
- 1ULL << tvd->vdev_ms_shift);
+ space += P2ALIGN_TYPED(tvd->vdev_max_asize - tvd->vdev_asize,
+ 1ULL << tvd->vdev_ms_shift, uint64_t);
}
spa_config_exit(mc->mc_spa, SCL_VDEV, FTAG);
return (space);
* to the nearest metaslab.
*/
if (vd == vd->vdev_top)
- return (P2ALIGN(vd->vdev_asize, 1ULL << vd->vdev_ms_shift));
+ return (P2ALIGN_TYPED(vd->vdev_asize, 1ULL << vd->vdev_ms_shift,
+ uint64_t));
return (pvd->vdev_ops->vdev_op_min_asize(pvd));
}
}
}
- osize = P2ALIGN(osize, (uint64_t)sizeof (vdev_label_t));
- max_osize = P2ALIGN(max_osize, (uint64_t)sizeof (vdev_label_t));
+ osize = P2ALIGN_TYPED(osize, sizeof (vdev_label_t), uint64_t);
+ max_osize = P2ALIGN_TYPED(max_osize, sizeof (vdev_label_t), uint64_t);
if (vd->vdev_children == 0) {
if (osize < SPA_MINDEVSIZE) {
* can expand.
*/
if (vd->vdev_aux == NULL && tvd != NULL) {
- vs->vs_esize = P2ALIGN(
+ vs->vs_esize = P2ALIGN_TYPED(
vd->vdev_max_asize - vd->vdev_asize,
- 1ULL << tvd->vdev_ms_shift);
+ 1ULL << tvd->vdev_ms_shift, uint64_t);
}
vs->vs_configured_ashift = vd->vdev_top != NULL
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
vdev_t *raidvd = vdev_lookup_top(spa, vre->vre_vdev_id);
int ashift = raidvd->vdev_ashift;
- uint64_t write_size = P2ALIGN(VDEV_BOOT_SIZE, 1 << ashift);
+ uint64_t write_size = P2ALIGN_TYPED(VDEV_BOOT_SIZE, 1 << ashift,
+ uint64_t);
uint64_t logical_size = write_size * raidvd->vdev_children;
uint64_t read_size =
P2ROUNDUP(DIV_ROUND_UP(logical_size, (raidvd->vdev_children - 1)),