1 /* 2 * CDDL HEADER START 3 * 4 * This file and its contents are supplied under the terms of the 5 * Common Development and Distribution License ("CDDL"), version 1.0. 6 * You may only use this file in accordance with the terms of version 7 * 1.0 of the CDDL. 8 * 9 * A full copy of the text of the CDDL should have accompanied this 10 * source. A copy of the CDDL is also available via the Internet at 11 * http://www.illumos.org/license/CDDL. 12 * 13 * CDDL HEADER END 14 */ 15 /* 16 * Copyright (C) 2017 by Lawrence Livermore National Security, LLC. 17 */ 18 19 #ifndef _SYS_MMP_H 20 #define _SYS_MMP_H 21 22 #include <sys/spa.h> 23 #include <sys/zfs_context.h> 24 #include <sys/uberblock_impl.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #define MMP_MIN_INTERVAL 100 /* ms */ 31 #define MMP_DEFAULT_INTERVAL 1000 /* ms */ 32 #define MMP_DEFAULT_IMPORT_INTERVALS 10 33 #define MMP_DEFAULT_FAIL_INTERVALS 5 34 35 typedef struct mmp_thread { 36 kmutex_t mmp_thread_lock; /* protect thread mgmt fields */ 37 kcondvar_t mmp_thread_cv; 38 kthread_t *mmp_thread; 39 uint8_t mmp_thread_exiting; 40 kmutex_t mmp_io_lock; /* protect below */ 41 hrtime_t mmp_last_write; /* last successful MMP write */ 42 uint64_t mmp_delay; /* decaying avg ns between MMP writes */ 43 uberblock_t mmp_ub; /* last ub written by sync */ 44 zio_t *mmp_zio_root; /* root of mmp write zios */ 45 uint64_t mmp_kstat_id; /* unique id for next MMP write kstat */ 46 int mmp_skip_error; /* reason for last skipped write */ 47 vdev_t *mmp_last_leaf; /* last mmp write sent here */ 48 uint64_t mmp_leaf_last_gen; /* last mmp write sent here */ 49 } mmp_thread_t; 50 51 52 extern void mmp_init(struct spa *spa); 53 extern void mmp_fini(struct spa *spa); 54 extern void mmp_thread_start(struct spa *spa); 55 extern void mmp_thread_stop(struct spa *spa); 56 extern void mmp_update_uberblock(struct spa *spa, struct uberblock *ub); 57 extern void mmp_signal_all_threads(void); 58 59 /* Global tuning */ 60 extern ulong_t zfs_multihost_interval; 61 extern uint_t zfs_multihost_fail_intervals; 62 extern uint_t zfs_multihost_import_intervals; 63 64 #ifdef __cplusplus 65 } 66 #endif 67 68 #endif /* _SYS_MMP_H */ 69