mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-29 18:24:11 +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:
committed by
Brian Behlendorf
parent
2566592045
commit
9edf6af4ae
+3
-2
@@ -537,7 +537,8 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
|
||||
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 "
|
||||
@@ -854,7 +855,7 @@ get_next_chunk(dnode_t *dn, uint64_t *start, uint64_t minimum, uint64_t *l1blks)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
Reference in New Issue
Block a user