Skip to content

Commit 71d191e

Browse files
authored
Allow MMP to bypass waiting for other threads
At our site we have seen cases when multi-modifier protection is enabled (multihost=on) on our pool and the pool gets suspended due to a single disk that is failing and responding very slowly. Our pools have 90 disks in them and we expect disks to fail. The current version of MMP requires that we wait for other writers before moving on. When a disk is responding very slowly, we observed that waiting here was bad enough to cause the pool to suspend. This change allows the MMP thread to bypass waiting for other threads and reduces the chances the pool gets suspended. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Herb Wartens <[email protected]> Closes #14659
1 parent d465783 commit 71d191e

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

include/sys/spa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ extern int spa_import_progress_set_state(uint64_t pool_guid,
977977
extern int spa_config_tryenter(spa_t *spa, int locks, const void *tag,
978978
krw_t rw);
979979
extern void spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw);
980+
extern void spa_config_enter_mmp(spa_t *spa, int locks, const void *tag,
981+
krw_t rw);
980982
extern void spa_config_exit(spa_t *spa, int locks, const void *tag);
981983
extern int spa_config_held(spa_t *spa, int locks, krw_t rw);
982984

module/zfs/mmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ mmp_write_uberblock(spa_t *spa)
445445
uint64_t offset;
446446

447447
hrtime_t lock_acquire_time = gethrtime();
448-
spa_config_enter(spa, SCL_STATE, mmp_tag, RW_READER);
448+
spa_config_enter_mmp(spa, SCL_STATE, mmp_tag, RW_READER);
449449
lock_acquire_time = gethrtime() - lock_acquire_time;
450450
if (lock_acquire_time > (MSEC2NSEC(MMP_MIN_INTERVAL) / 10))
451451
zfs_dbgmsg("MMP SCL_STATE acquisition pool '%s' took %llu ns "

module/zfs/spa_misc.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,9 @@ spa_config_tryenter(spa_t *spa, int locks, const void *tag, krw_t rw)
493493
return (1);
494494
}
495495

496-
void
497-
spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw)
496+
static void
497+
spa_config_enter_impl(spa_t *spa, int locks, const void *tag, krw_t rw,
498+
int mmp_flag)
498499
{
499500
(void) tag;
500501
int wlocks_held = 0;
@@ -509,7 +510,8 @@ spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw)
509510
continue;
510511
mutex_enter(&scl->scl_lock);
511512
if (rw == RW_READER) {
512-
while (scl->scl_writer || scl->scl_write_wanted) {
513+
while (scl->scl_writer ||
514+
(!mmp_flag && scl->scl_write_wanted)) {
513515
cv_wait(&scl->scl_cv, &scl->scl_lock);
514516
}
515517
} else {
@@ -527,6 +529,27 @@ spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw)
527529
ASSERT3U(wlocks_held, <=, locks);
528530
}
529531

532+
void
533+
spa_config_enter(spa_t *spa, int locks, const void *tag, krw_t rw)
534+
{
535+
spa_config_enter_impl(spa, locks, tag, rw, 0);
536+
}
537+
538+
/*
539+
* The spa_config_enter_mmp() allows the mmp thread to cut in front of
540+
* outstanding write lock requests. This is needed since the mmp updates are
541+
* time sensitive and failure to service them promptly will result in a
542+
* suspended pool. This pool suspension has been seen in practice when there is
543+
* a single disk in a pool that is responding slowly and presumably about to
544+
* fail.
545+
*/
546+
547+
void
548+
spa_config_enter_mmp(spa_t *spa, int locks, const void *tag, krw_t rw)
549+
{
550+
spa_config_enter_impl(spa, locks, tag, rw, 1);
551+
}
552+
530553
void
531554
spa_config_exit(spa_t *spa, int locks, const void *tag)
532555
{

0 commit comments

Comments
 (0)