mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Avoid possibility of division by zero
When hz > 1000, msec / (1000 / hz) results in division by zero. I found somewhere in FreeBSD using howmany(msec * hz, 1000) to convert ms to ticks, avoiding the potential for a zero in the divisor. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org> Closes #10894
This commit is contained in:
committed by
Brian Behlendorf
parent
b155a243a6
commit
127daad223
@@ -72,7 +72,7 @@ extern struct mtx zfs_debug_mtx;
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define MSEC_TO_TICK(msec) ((msec) / (MILLISEC / hz))
|
||||
#define MSEC_TO_TICK(msec) (howmany((hrtime_t)(msec) * hz, MILLISEC))
|
||||
extern int hz;
|
||||
extern int tick;
|
||||
typedef int fstrans_cookie_t;
|
||||
|
||||
Reference in New Issue
Block a user