Skip to content

Commit

Permalink
Fix MMP write frequency for large pools
Browse files Browse the repository at this point in the history
When a single pool contains more vdevs than the CONFIG_HZ for
for the kernel the mmp thread will not delay properly.  Switch
to using cv_timedwait_sig_hires() to handle higher resolution
delays.

This issue was reported on Arch Linux where HZ defaults to only
100 and this could be fairly easily reproduced with a reasonably
large pool.  Most distribution kernels set CONFIG_HZ=250 or
CONFIG_HZ=1000 and thus are unlikely to be impacted.

Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: Olaf Faaland <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#7205
Closes openzfs#7289
  • Loading branch information
behlendorf authored and tonyhutter committed Mar 8, 2018
1 parent 20a503a commit 88f792c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/libspl/include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#endif

#ifndef USEC2NSEC
#define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC))
#endif

#ifndef NSEC2SEC
#define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
#endif
Expand Down
6 changes: 3 additions & 3 deletions module/zfs/mmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ mmp_thread(spa_t *spa)
mmp_write_uberblock(spa);

CALLB_CPR_SAFE_BEGIN(&cpr);
(void) cv_timedwait_sig(&mmp->mmp_thread_cv,
&mmp->mmp_thread_lock, ddi_get_lbolt() +
((next_time - gethrtime()) / (NANOSEC / hz)));
(void) cv_timedwait_sig_hires(&mmp->mmp_thread_cv,
&mmp->mmp_thread_lock, next_time, USEC2NSEC(1),
CALLOUT_FLAG_ABSOLUTE);
CALLB_CPR_SAFE_END(&cpr, &mmp->mmp_thread_lock);
}

Expand Down

0 comments on commit 88f792c

Please sign in to comment.