1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Brian Behlendorf <behlendorf1@llnl.gov>
3 Date: Mon, 12 Mar 2018 11:26:05 -0700
4 Subject: [PATCH] Fix MMP write frequency for large pools
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 When a single pool contains more vdevs than the CONFIG_HZ for
10 for the kernel the mmp thread will not delay properly. Switch
11 to using cv_timedwait_sig_hires() to handle higher resolution
14 This issue was reported on Arch Linux where HZ defaults to only
15 100 and this could be fairly easily reproduced with a reasonably
16 large pool. Most distribution kernels set CONFIG_HZ=250 or
17 CONFIG_HZ=1000 and thus are unlikely to be impacted.
19 Reviewed-by: George Melikov <mail@gmelikov.ru>
20 Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
21 Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
22 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
23 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
26 (cherry picked from commit c30e716c8149b7df7cf968373c22aa00b48d17b8)
27 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
29 lib/libspl/include/sys/time.h | 6 +++++-
30 module/zfs/mmp.c | 6 +++---
31 2 files changed, 8 insertions(+), 4 deletions(-)
33 diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h
34 index f05fcaa1c..dc645fa5c 100644
35 --- a/lib/libspl/include/sys/time.h
36 +++ b/lib/libspl/include/sys/time.h
38 #define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
43 #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
47 +#define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC))
51 #define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
53 diff --git a/module/zfs/mmp.c b/module/zfs/mmp.c
54 index 15eea41ab..dc5c6a74f 100644
55 --- a/module/zfs/mmp.c
56 +++ b/module/zfs/mmp.c
57 @@ -462,9 +462,9 @@ mmp_thread(spa_t *spa)
58 mmp_write_uberblock(spa);
60 CALLB_CPR_SAFE_BEGIN(&cpr);
61 - (void) cv_timedwait_sig(&mmp->mmp_thread_cv,
62 - &mmp->mmp_thread_lock, ddi_get_lbolt() +
63 - ((next_time - gethrtime()) / (NANOSEC / hz)));
64 + (void) cv_timedwait_sig_hires(&mmp->mmp_thread_cv,
65 + &mmp->mmp_thread_lock, next_time, USEC2NSEC(1),
66 + CALLOUT_FLAG_ABSOLUTE);
67 CALLB_CPR_SAFE_END(&cpr, &mmp->mmp_thread_lock);