FreeBSD: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
[zfs.git] / include / sys / mmp.h
blob1023334098d87f4a21169563802adba98d3843c1
1 /*
2 * CDDL HEADER START
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.
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.
13 * CDDL HEADER END
16 * Copyright (C) 2017 by Lawrence Livermore National Security, LLC.
19 #ifndef _SYS_MMP_H
20 #define _SYS_MMP_H
22 #include <sys/spa.h>
23 #include <sys/zfs_context.h>
24 #include <sys/uberblock_impl.h>
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 #define MMP_MIN_INTERVAL 100 /* ms */
31 #define MMP_DEFAULT_INTERVAL 1000 /* ms */
32 #define MMP_DEFAULT_IMPORT_INTERVALS 20
33 #define MMP_DEFAULT_FAIL_INTERVALS 10
34 #define MMP_MIN_FAIL_INTERVALS 2 /* min if != 0 */
35 #define MMP_IMPORT_SAFETY_FACTOR 200 /* pct */
36 #define MMP_INTERVAL_OK(interval) MAX(interval, MMP_MIN_INTERVAL)
37 #define MMP_FAIL_INTVS_OK(fails) (fails == 0 ? 0 : MAX(fails, \
38 MMP_MIN_FAIL_INTERVALS))
40 typedef struct mmp_thread {
41 kmutex_t mmp_thread_lock; /* protect thread mgmt fields */
42 kcondvar_t mmp_thread_cv;
43 kthread_t *mmp_thread;
44 uint8_t mmp_thread_exiting;
45 kmutex_t mmp_io_lock; /* protect below */
46 hrtime_t mmp_last_write; /* last successful MMP write */
47 uint64_t mmp_delay; /* decaying avg ns between MMP writes */
48 uberblock_t mmp_ub; /* last ub written by sync */
49 zio_t *mmp_zio_root; /* root of mmp write zios */
50 uint64_t mmp_kstat_id; /* unique id for next MMP write kstat */
51 int mmp_skip_error; /* reason for last skipped write */
52 vdev_t *mmp_last_leaf; /* last mmp write sent here */
53 uint64_t mmp_leaf_last_gen; /* last mmp write sent here */
54 uint32_t mmp_seq; /* intra-second update counter */
55 } mmp_thread_t;
58 extern void mmp_init(struct spa *spa);
59 extern void mmp_fini(struct spa *spa);
60 extern void mmp_thread_start(struct spa *spa);
61 extern void mmp_thread_stop(struct spa *spa);
62 extern void mmp_update_uberblock(struct spa *spa, struct uberblock *ub);
63 extern void mmp_signal_all_threads(void);
65 /* Global tuning */
66 extern int param_set_multihost_interval(ZFS_MODULE_PARAM_ARGS);
67 extern uint64_t zfs_multihost_interval;
68 extern uint_t zfs_multihost_fail_intervals;
69 extern uint_t zfs_multihost_import_intervals;
71 #ifdef __cplusplus
73 #endif
75 #endif /* _SYS_MMP_H */