mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
Replace P2ALIGN with P2ALIGN_TYPED and delete P2ALIGN.
In P2ALIGN, the result would be incorrect when align is unsigned integer and x is larger than max value of the type of align. In that case, -(align) would be a positive integer, which means high bits would be zero and finally stay zero after '&' when align is converted to a larger integer type. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Youzhong Yang <yyang@mathworks.com> Signed-off-by: Qiuhao Chen <chenqiuhao1997@gmail.com> Closes #15940
This commit is contained in:
+6
-5
@@ -348,7 +348,8 @@ vdev_get_min_asize(vdev_t *vd)
|
||||
* 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));
|
||||
}
|
||||
@@ -2115,8 +2116,8 @@ vdev_open(vdev_t *vd)
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -4764,9 +4765,9 @@ vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user