Lines Matching defs:mmp
26 #include <sys/mmp.h>
80 * the mmp write interval.
89 * the pool imported will suspend the pool if no mmp writes land within
150 * Used to control the frequency of mmp writes which are performed when the
154 * On average an mmp write will be issued for each leaf vdev every
171 * Controls the behavior of the pool when mmp write failures or delays are
174 * When zfs_multihost_fail_intervals = 0, mmp write failures or delays are
181 * without a successful mmp write. This guarantees the activity test will see
182 * mmp writes if the pool is imported. A value of 1 is ignored and treated as
195 mmp_thread_t *mmp = &spa->spa_mmp;
197 mutex_init(&mmp->mmp_thread_lock, NULL, MUTEX_DEFAULT, NULL);
198 cv_init(&mmp->mmp_thread_cv, NULL, CV_DEFAULT, NULL);
199 mutex_init(&mmp->mmp_io_lock, NULL, MUTEX_DEFAULT, NULL);
200 mmp->mmp_kstat_id = 1;
206 mmp_thread_t *mmp = &spa->spa_mmp;
208 mutex_destroy(&mmp->mmp_thread_lock);
209 cv_destroy(&mmp->mmp_thread_cv);
210 mutex_destroy(&mmp->mmp_io_lock);
214 mmp_thread_enter(mmp_thread_t *mmp, callb_cpr_t *cpr)
216 CALLB_CPR_INIT(cpr, &mmp->mmp_thread_lock, callb_generic_cpr, FTAG);
217 mutex_enter(&mmp->mmp_thread_lock);
221 mmp_thread_exit(mmp_thread_t *mmp, kthread_t **mpp, callb_cpr_t *cpr)
225 cv_broadcast(&mmp->mmp_thread_cv);
226 CALLB_CPR_EXIT(cpr); /* drops &mmp->mmp_thread_lock */
232 mmp_thread_t *mmp = &spa->spa_mmp;
235 mutex_enter(&mmp->mmp_thread_lock);
236 if (!mmp->mmp_thread) {
237 mmp->mmp_thread = thread_create(NULL, 0, mmp_thread,
242 mutex_exit(&mmp->mmp_thread_lock);
249 mmp_thread_t *mmp = &spa->spa_mmp;
251 mutex_enter(&mmp->mmp_thread_lock);
252 mmp->mmp_thread_exiting = 1;
253 cv_broadcast(&mmp->mmp_thread_cv);
255 while (mmp->mmp_thread) {
256 cv_wait(&mmp->mmp_thread_cv, &mmp->mmp_thread_lock);
258 mutex_exit(&mmp->mmp_thread_lock);
262 ASSERT(mmp->mmp_thread == NULL);
263 mmp->mmp_thread_exiting = 0;
273 * mmp write (if so a new write will also likely block). If there is no usable
350 * If an mmp write was skipped or fails, and we have already waited longer than
417 * in the mmp thread state, used for mmp writes.
422 mmp_thread_t *mmp = &spa->spa_mmp;
424 mutex_enter(&mmp->mmp_io_lock);
425 mmp->mmp_ub = *ub;
426 mmp->mmp_seq = 1;
427 mmp->mmp_ub.ub_timestamp = gethrestime_sec();
429 mutex_exit(&mmp->mmp_io_lock);
441 mmp_thread_t *mmp = &spa->spa_mmp;
455 mutex_enter(&mmp->mmp_io_lock);
469 if (mmp->mmp_skip_error == error) {
470 spa_mmp_history_set_skip(spa, mmp->mmp_kstat_id - 1);
472 mmp->mmp_skip_error = error;
473 spa_mmp_history_add(spa, mmp->mmp_ub.ub_txg,
474 gethrestime_sec(), mmp->mmp_delay, NULL, 0,
475 mmp->mmp_kstat_id++, error);
480 mutex_exit(&mmp->mmp_io_lock);
486 if (mmp->mmp_skip_error != 0) {
487 mmp->mmp_skip_error = 0;
494 if (mmp->mmp_zio_root == NULL)
495 mmp->mmp_zio_root = zio_root(spa, NULL, NULL,
498 if (mmp->mmp_ub.ub_timestamp != gethrestime_sec()) {
504 mmp->mmp_ub.ub_timestamp = gethrestime_sec();
505 mmp->mmp_seq = 1;
508 ub = &mmp->mmp_ub;
510 ub->ub_mmp_delay = mmp->mmp_delay;
511 ub->ub_mmp_config = MMP_SEQ_SET(mmp->mmp_seq) |
516 vd->vdev_mmp_kstat_id = mmp->mmp_kstat_id;
518 zio_t *zio = zio_null(mmp->mmp_zio_root, spa, NULL, NULL, NULL, flags);
524 mmp->mmp_seq++;
525 mmp->mmp_kstat_id++;
526 mutex_exit(&mmp->mmp_io_lock);
533 VDEV_UBERBLOCK_SIZE(vd), mmp_write_done, mmp,
546 mmp_thread_t *mmp = &spa->spa_mmp;
562 mmp_thread_enter(mmp, &cpr);
571 mutex_enter(&mmp->mmp_io_lock);
572 mmp->mmp_last_write = gethrtime();
573 mmp->mmp_delay = MSEC2NSEC(MMP_INTERVAL_OK(zfs_multihost_interval));
574 mutex_exit(&mmp->mmp_io_lock);
576 while (!mmp->mmp_thread_exiting) {
643 mutex_enter(&mmp->mmp_io_lock);
644 mmp->mmp_last_write = gethrtime();
645 mmp->mmp_delay = mmp_interval;
646 mutex_exit(&mmp->mmp_io_lock);
654 mutex_enter(&mmp->mmp_io_lock);
655 mmp->mmp_delay = 0;
656 mutex_exit(&mmp->mmp_io_lock);
664 (gethrtime() - mmp->mmp_last_write) > mmp_fail_ns) {
669 (u_longlong_t)mmp->mmp_last_write,
678 NSEC2MSEC(gethrtime() - mmp->mmp_last_write),
693 (void) cv_timedwait_idle_hires(&mmp->mmp_thread_cv,
694 &mmp->mmp_thread_lock, next_time, USEC2NSEC(100),
696 CALLB_CPR_SAFE_END(&cpr, &mmp->mmp_thread_lock);
700 zio_wait(mmp->mmp_zio_root);
702 mmp->mmp_zio_root = NULL;
703 mmp_thread_exit(mmp, &mmp->mmp_thread, &cpr);
712 * Only signal if the pool is active and mmp thread is
718 mmp_thread_t *mmp = &spa->spa_mmp;
720 mutex_enter(&mmp->mmp_thread_lock);
721 if (mmp->mmp_thread)
722 cv_broadcast(&mmp->mmp_thread_cv);
723 mutex_exit(&mmp->mmp_thread_lock);
741 "Milliseconds between mmp writes to each leaf");
744 "Max allowed period without a successful mmp write");