FreeBSD: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
[zfs.git] / include / sys / vdev_removal.h
blob70b743f4ec6b592376f0e791771777440dec314b
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
17 * Copyright (c) 2014, 2019 by Delphix. All rights reserved.
20 #ifndef _SYS_VDEV_REMOVAL_H
21 #define _SYS_VDEV_REMOVAL_H
23 #include <sys/spa.h>
24 #include <sys/bpobj.h>
25 #include <sys/vdev_indirect_mapping.h>
26 #include <sys/vdev_indirect_births.h>
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 typedef struct spa_vdev_removal {
33 uint64_t svr_vdev_id;
34 uint64_t svr_max_offset_to_sync[TXG_SIZE];
35 /* Thread performing a vdev removal. */
36 kthread_t *svr_thread;
37 /* Segments left to copy from the current metaslab. */
38 range_tree_t *svr_allocd_segs;
39 kmutex_t svr_lock;
40 kcondvar_t svr_cv;
41 boolean_t svr_thread_exit;
44 * New mappings to write out each txg.
46 list_t svr_new_segments[TXG_SIZE];
49 * Ranges that were freed while a mapping was in flight. This is
50 * a subset of the ranges covered by vdev_im_new_segments.
52 range_tree_t *svr_frees[TXG_SIZE];
55 * Number of bytes which we have finished our work for
56 * in each txg. This could be data copied (which will be part of
57 * the mappings in vdev_im_new_segments), or data freed before
58 * we got around to copying it.
60 uint64_t svr_bytes_done[TXG_SIZE];
62 /* List of leaf zap objects to be unlinked */
63 nvlist_t *svr_zaplist;
64 } spa_vdev_removal_t;
66 typedef struct spa_condensing_indirect {
68 * New mappings to write out each txg.
70 list_t sci_new_mapping_entries[TXG_SIZE];
72 vdev_indirect_mapping_t *sci_new_mapping;
73 } spa_condensing_indirect_t;
75 extern int spa_remove_init(spa_t *);
76 extern void spa_restart_removal(spa_t *);
77 extern int spa_condense_init(spa_t *);
78 extern void spa_condense_fini(spa_t *);
79 extern void spa_start_indirect_condensing_thread(spa_t *);
80 extern void spa_vdev_condense_suspend(spa_t *);
81 extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t);
82 extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t);
83 extern int spa_removal_get_stats(spa_t *, pool_removal_stat_t *);
84 extern void svr_sync(spa_t *, dmu_tx_t *);
85 extern void spa_vdev_remove_suspend(spa_t *);
86 extern int spa_vdev_remove_cancel(spa_t *);
87 extern void spa_vdev_removal_destroy(spa_vdev_removal_t *);
88 extern uint64_t spa_remove_max_segment(spa_t *);
90 extern uint_t vdev_removal_max_span;
92 #ifdef __cplusplus
94 #endif
96 #endif /* _SYS_VDEV_REMOVAL_H */