Skip to content

Commit 5a77c19

Browse files
amotintonyhutter
authored andcommitted
BRT: Fix ranges to blocks conversion math
BRT_RANGESIZE_TO_NBLOCKS() takes number of ranges as its argument. To get number of blocks we should multiply it by the entry size, not divide by it, as it was due to missing parentheses. Before #17875 this could cause small memory corruptions for vdevs bigger than 64TB, but the change made the bug more noticeable. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Closes #17886 Closes #17915
1 parent 5f8b3fb commit 5a77c19

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/sys/brt_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ _Static_assert(BRT_RANGESIZE / SPA_MINBLOCKSIZE <= UINT16_MAX,
6464
*/
6565
#define BRT_BLOCKSIZE (32 * 1024)
6666
#define BRT_RANGESIZE_TO_NBLOCKS(size) \
67-
(((size) - 1) / BRT_BLOCKSIZE / sizeof (uint16_t) + 1)
67+
(((size) - 1) / (BRT_BLOCKSIZE / sizeof (uint16_t)) + 1)
6868

6969
#define BRT_LITTLE_ENDIAN 0
7070
#define BRT_BIG_ENDIAN 1

0 commit comments

Comments
 (0)